ngx-render-material-forms 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3015,13 +3015,11 @@ class CommonService {
3015
3015
  listProductCategory() {
3016
3016
  const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
3017
3017
  const baseApiUrl = this.getBaseApiUrl();
3018
- console.log('categoryVid=>', vendorId);
3019
3018
  return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductsCategory?vendorId=${vendorId}`);
3020
3019
  }
3021
3020
  listSubCategory(category) {
3022
3021
  const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
3023
3022
  const baseApiUrl = this.getBaseApiUrl();
3024
- console.log('subcategoryVid=>', vendorId);
3025
3023
  return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductsSubCategory?vendorId=${vendorId}&categoryName=${category}`);
3026
3024
  }
3027
3025
  // Function to get value by key from the array
@@ -3374,6 +3372,7 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3374
3372
  this.showQuantity = true;
3375
3373
  this.category = '';
3376
3374
  this.subCategory = '';
3375
+ this.hasInitialized = false;
3377
3376
  }
3378
3377
  getColumnLabel(column) {
3379
3378
  return column.label || column.key;
@@ -3382,6 +3381,8 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3382
3381
  return newProductPickerFlag && Object.keys(newProductPickerFlag).some(key => key.toLocaleLowerCase() === attributeName.toLowerCase() &&
3383
3382
  newProductPickerFlag[key].toLowerCase() === "true");
3384
3383
  }
3384
+ // ngOnInit(): void {
3385
+ // }
3385
3386
  setInstance(instance) {
3386
3387
  const newProductPickerFlag = instance?.component?.attributes;
3387
3388
  this.showNewProductPicker = this.checkIsAttributeTrue(newProductPickerFlag, "newproductpicker");
@@ -3390,7 +3391,26 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3390
3391
  this.showPrice = this.checkIsAttributeTrue(newProductPickerFlag, "showPrice");
3391
3392
  this.showQuantity = this.checkIsAttributeTrue(newProductPickerFlag, "showQuantity");
3392
3393
  super.setInstance(instance);
3393
- this.dataSource.data = instance.dataValue;
3394
+ if (this.showNewProductPicker && !this.hasInitialized) {
3395
+ if (!this.showCategory) {
3396
+ this.removeColumn('category');
3397
+ }
3398
+ if (!this.showQuantity) {
3399
+ this.removeColumn('quantity');
3400
+ }
3401
+ if (!this.showPrice) {
3402
+ this.removeColumn('price');
3403
+ }
3404
+ if (!this.showSubcategory) {
3405
+ this.removeColumn('subCategory');
3406
+ }
3407
+ this.dataSourceNew = JSON.parse(localStorage.getItem('selectedProducts')) || [];
3408
+ // Set flag to true to prevent further execution
3409
+ this.hasInitialized = true;
3410
+ }
3411
+ else {
3412
+ this.dataSource.data = instance.dataValue;
3413
+ }
3394
3414
  this.columns = {};
3395
3415
  this.displayedColumns = [];
3396
3416
  this.formColumns = [];
@@ -3431,6 +3451,10 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3431
3451
  }
3432
3452
  addAnother() {
3433
3453
  if (this.showNewProductPicker) {
3454
+ const savedData = JSON.parse(localStorage.getItem('saveCat'));
3455
+ // Use optional chaining and nullish coalescing to set the values
3456
+ this.category = savedData?.category ?? this.category;
3457
+ this.subCategory = savedData?.subCategory ?? this.subCategory;
3434
3458
  const diologeRef = this.dialog.open(AddOnProductsComponent, {
3435
3459
  disableClose: true,
3436
3460
  width: '90%',
@@ -3456,6 +3480,11 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3456
3480
  this.dataSourceNew = response.data.items.selectedProducts;
3457
3481
  this.category = response.data.items.productCategory;
3458
3482
  this.subCategory = response.data.items.productSubcategory;
3483
+ const catObject = {
3484
+ category: this.category,
3485
+ subCategory: this.subCategory
3486
+ };
3487
+ localStorage.setItem('saveCat', JSON.stringify(catObject));
3459
3488
  this.instance.component.defaultValue = response.data.items.selectedProducts;
3460
3489
  }
3461
3490
  });