ngx-render-material-forms 1.4.3 → 1.4.5

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.
@@ -2766,6 +2766,11 @@ class MaterialSelectComponent extends MaterialComponent {
2766
2766
  else {
2767
2767
  this.removePanelScrollEvent();
2768
2768
  this.searching = false;
2769
+ let selectedValue = this.getValue();
2770
+ if (selectedValue.toString().length == 0 && this.searchQuery == '') {
2771
+ this.productList = [];
2772
+ this.loadData(this.pageNumber, this.pageSize, this.searchQuery);
2773
+ }
2769
2774
  }
2770
2775
  });
2771
2776
  }
@@ -3015,13 +3020,11 @@ class CommonService {
3015
3020
  listProductCategory() {
3016
3021
  const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
3017
3022
  const baseApiUrl = this.getBaseApiUrl();
3018
- console.log('categoryVid=>', vendorId);
3019
3023
  return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductsCategory?vendorId=${vendorId}`);
3020
3024
  }
3021
3025
  listSubCategory(category) {
3022
3026
  const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
3023
3027
  const baseApiUrl = this.getBaseApiUrl();
3024
- console.log('subcategoryVid=>', vendorId);
3025
3028
  return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductsSubCategory?vendorId=${vendorId}&categoryName=${category}`);
3026
3029
  }
3027
3030
  // Function to get value by key from the array
@@ -3374,6 +3377,7 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3374
3377
  this.showQuantity = true;
3375
3378
  this.category = '';
3376
3379
  this.subCategory = '';
3380
+ this.hasInitialized = false;
3377
3381
  }
3378
3382
  getColumnLabel(column) {
3379
3383
  return column.label || column.key;
@@ -3382,6 +3386,8 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3382
3386
  return newProductPickerFlag && Object.keys(newProductPickerFlag).some(key => key.toLocaleLowerCase() === attributeName.toLowerCase() &&
3383
3387
  newProductPickerFlag[key].toLowerCase() === "true");
3384
3388
  }
3389
+ // ngOnInit(): void {
3390
+ // }
3385
3391
  setInstance(instance) {
3386
3392
  const newProductPickerFlag = instance?.component?.attributes;
3387
3393
  this.showNewProductPicker = this.checkIsAttributeTrue(newProductPickerFlag, "newproductpicker");
@@ -3390,7 +3396,26 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3390
3396
  this.showPrice = this.checkIsAttributeTrue(newProductPickerFlag, "showPrice");
3391
3397
  this.showQuantity = this.checkIsAttributeTrue(newProductPickerFlag, "showQuantity");
3392
3398
  super.setInstance(instance);
3393
- this.dataSource.data = instance.dataValue;
3399
+ if (this.showNewProductPicker && !this.hasInitialized) {
3400
+ if (!this.showCategory) {
3401
+ this.removeColumn('category');
3402
+ }
3403
+ if (!this.showQuantity) {
3404
+ this.removeColumn('quantity');
3405
+ }
3406
+ if (!this.showPrice) {
3407
+ this.removeColumn('price');
3408
+ }
3409
+ if (!this.showSubcategory) {
3410
+ this.removeColumn('subCategory');
3411
+ }
3412
+ this.dataSourceNew = JSON.parse(localStorage.getItem('selectedProducts')) || [];
3413
+ // Set flag to true to prevent further execution
3414
+ this.hasInitialized = true;
3415
+ }
3416
+ else {
3417
+ this.dataSource.data = instance.dataValue;
3418
+ }
3394
3419
  this.columns = {};
3395
3420
  this.displayedColumns = [];
3396
3421
  this.formColumns = [];
@@ -3431,6 +3456,10 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3431
3456
  }
3432
3457
  addAnother() {
3433
3458
  if (this.showNewProductPicker) {
3459
+ const savedData = JSON.parse(localStorage.getItem('saveCat'));
3460
+ // Use optional chaining and nullish coalescing to set the values
3461
+ this.category = savedData?.category ?? this.category;
3462
+ this.subCategory = savedData?.subCategory ?? this.subCategory;
3434
3463
  const diologeRef = this.dialog.open(AddOnProductsComponent, {
3435
3464
  disableClose: true,
3436
3465
  width: '90%',
@@ -3456,6 +3485,11 @@ class MaterialDataGridComponent extends MaterialNestedComponent {
3456
3485
  this.dataSourceNew = response.data.items.selectedProducts;
3457
3486
  this.category = response.data.items.productCategory;
3458
3487
  this.subCategory = response.data.items.productSubcategory;
3488
+ const catObject = {
3489
+ category: this.category,
3490
+ subCategory: this.subCategory
3491
+ };
3492
+ localStorage.setItem('saveCat', JSON.stringify(catObject));
3459
3493
  this.instance.component.defaultValue = response.data.items.selectedProducts;
3460
3494
  }
3461
3495
  });