ngx-render-material-forms 2.5.5 → 2.5.6
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.
- package/esm2020/lib/components/common.service.mjs +10 -7
- package/esm2020/lib/components/select/select.component.mjs +11 -86
- package/fesm2015/ngx-render-material-forms.js +20 -94
- package/fesm2015/ngx-render-material-forms.mjs.map +1 -1
- package/fesm2020/ngx-render-material-forms.js +19 -91
- package/fesm2020/ngx-render-material-forms.mjs.map +1 -1
- package/lib/components/select/select.component.d.ts +0 -4
- package/package.json +1 -1
|
@@ -2685,6 +2685,7 @@ class CommonService {
|
|
|
2685
2685
|
}
|
|
2686
2686
|
}
|
|
2687
2687
|
loadProducts(pageNumber, pazeSize, search = '', onlyActive = true, description = false, levelOneId, levelTwoId, levelThreeId, levelFourId) {
|
|
2688
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2688
2689
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2689
2690
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2690
2691
|
const programId = this.getValueByKey(this.paramsData, 'programId');
|
|
@@ -2695,6 +2696,7 @@ class CommonService {
|
|
|
2695
2696
|
return this.http.get(apiUrl);
|
|
2696
2697
|
}
|
|
2697
2698
|
listSubCategory(category) {
|
|
2699
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2698
2700
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2699
2701
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2700
2702
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductsSubCategory?vendorId=${vendorId}&categoryName=${category}`);
|
|
@@ -2716,26 +2718,31 @@ class CommonService {
|
|
|
2716
2718
|
return queryString;
|
|
2717
2719
|
}
|
|
2718
2720
|
listProductCategory() {
|
|
2721
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2719
2722
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2720
2723
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2721
2724
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductsCategory?vendorId=${vendorId}`);
|
|
2722
2725
|
}
|
|
2723
2726
|
productLevelOne() {
|
|
2727
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2724
2728
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2725
2729
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2726
2730
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductLevelOne?vendorId=${vendorId}`);
|
|
2727
2731
|
}
|
|
2728
2732
|
productLevelTwo(levelOneId) {
|
|
2733
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2729
2734
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2730
2735
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2731
2736
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductLevelTwo?levelOneId=${levelOneId}&vendorId=${vendorId}`);
|
|
2732
2737
|
}
|
|
2733
2738
|
productLevelThree(levelOneId, levelTwoId) {
|
|
2739
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2734
2740
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2735
2741
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2736
2742
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductLevelThree?levelOneId=${levelOneId}&levelTwoId=${levelTwoId}&vendorId=${vendorId}`);
|
|
2737
2743
|
}
|
|
2738
2744
|
productLevelFour(levelOneId, levelTwoId, levelThreeId) {
|
|
2745
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2739
2746
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2740
2747
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2741
2748
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductLevelFour?levelOneId=${levelOneId}&levelTwoId=${levelTwoId}&levelThreeId=${levelThreeId}&vendorId=${vendorId}`);
|
|
@@ -2769,12 +2776,8 @@ class CommonService {
|
|
|
2769
2776
|
}
|
|
2770
2777
|
/*Funtion to check if property is matched with given attributes in formBuilder or not */
|
|
2771
2778
|
checkIsAttributeTrue(newProductPickerFlag, attributeName) {
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
// newProductPickerFlag[key].toLowerCase() === "true"
|
|
2775
|
-
// );
|
|
2776
|
-
return newProductPickerFlag && Object.keys(newProductPickerFlag).some(key => key.trim().toLowerCase() === attributeName.trim().toLowerCase() &&
|
|
2777
|
-
String(newProductPickerFlag[key]).trim().toLowerCase() === "true");
|
|
2779
|
+
return newProductPickerFlag && Object.keys(newProductPickerFlag).some(key => key.toLocaleLowerCase() === attributeName.toLowerCase() &&
|
|
2780
|
+
newProductPickerFlag[key].toLowerCase() === "true");
|
|
2778
2781
|
}
|
|
2779
2782
|
getglobedata() {
|
|
2780
2783
|
const hostMappings = {
|
|
@@ -2839,8 +2842,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2839
2842
|
this.storeDependentItems = [];
|
|
2840
2843
|
this.executionFlag = false;
|
|
2841
2844
|
this.apiCounter = 0;
|
|
2842
|
-
this.lastOptionsHash = '';
|
|
2843
|
-
this.hasInitializedOptions = false;
|
|
2844
2845
|
}
|
|
2845
2846
|
onInputChange(event) {
|
|
2846
2847
|
if (this.instance.component.key.toLowerCase() === 'vendorproductid' && event.target.value === '') {
|
|
@@ -3043,7 +3044,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3043
3044
|
const vendorId = this.getValueByKey(paramsData, 'vendorId');
|
|
3044
3045
|
const dealId = this.getValueByKey(paramsData, 'dealId');
|
|
3045
3046
|
const isEdit = this.getValueByKey(paramsData, 'isEdit');
|
|
3046
|
-
this.isEditFlag = isEdit;
|
|
3047
3047
|
let finalParams;
|
|
3048
3048
|
this.instance?.parent?.components?.length && this.instance.parent.components.forEach(items => {
|
|
3049
3049
|
if (this.checkVendorRefItems(items)) {
|
|
@@ -3098,8 +3098,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3098
3098
|
// If the object doesn't exist, add it to the array
|
|
3099
3099
|
finalParams.push({ key: 'dataValue', value: value });
|
|
3100
3100
|
}
|
|
3101
|
-
this.secondDropdownItems = [];
|
|
3102
|
-
this.commonService.setDropdownItems(this.secondDropdownItems);
|
|
3103
3101
|
this.commonService.initializeApiPath(apiEndPoint, finalParams).subscribe(response => {
|
|
3104
3102
|
if (response && response.code === 200) {
|
|
3105
3103
|
this.secondDropdownItems = response.data;
|
|
@@ -3134,87 +3132,21 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3134
3132
|
});
|
|
3135
3133
|
}
|
|
3136
3134
|
if (this.checkVendorRefItems(this.instance) && checkInvokeFromLibrary) {
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
// });
|
|
3143
|
-
// }
|
|
3144
|
-
// if (!this.commonService.getDropDownFlag()) {
|
|
3145
|
-
// this.storeDependentItems = this.instance.component.data.values;
|
|
3146
|
-
// }
|
|
3147
|
-
// this.filteredOptions = Promise.resolve(this.storeDependentItems);
|
|
3148
|
-
// this.selectOptions = Promise.resolve(this.storeDependentItems);
|
|
3149
|
-
// this.selectOptions.then(result => {
|
|
3150
|
-
// this.filteredOptionsLength = result.length
|
|
3151
|
-
// });
|
|
3152
|
-
const incomingItems = this.commonService.getDropdownItems();
|
|
3153
|
-
const seen = new Set();
|
|
3154
|
-
const newOptions = [];
|
|
3155
|
-
if (incomingItems?.length) {
|
|
3156
|
-
incomingItems.forEach(item => {
|
|
3157
|
-
const rawValue = this.commonService.onlyNumbers(item['value']) ? item['value'] + ' ' : item['value'];
|
|
3158
|
-
const label = item['text']?.trim();
|
|
3159
|
-
if (label && rawValue) {
|
|
3160
|
-
const key = `${label}-${rawValue}`;
|
|
3161
|
-
if (!seen.has(key)) {
|
|
3162
|
-
seen.add(key);
|
|
3163
|
-
newOptions.push({ label, value: rawValue });
|
|
3164
|
-
}
|
|
3165
|
-
}
|
|
3135
|
+
this.storeDependentItems = [];
|
|
3136
|
+
this.secondDropdownItems = this.commonService.getDropdownItems();
|
|
3137
|
+
if (this.secondDropdownItems?.length) {
|
|
3138
|
+
this.secondDropdownItems.forEach((renderElement, index, array) => {
|
|
3139
|
+
this.storeDependentItems.push({ label: renderElement['text'], value: this.commonService.onlyNumbers(renderElement['value']) ? renderElement['value'] + ' ' : renderElement['value'] });
|
|
3166
3140
|
});
|
|
3167
3141
|
}
|
|
3168
|
-
// compare hashes to avoid unnecessary reassignments
|
|
3169
|
-
const newHash = JSON.stringify(newOptions);
|
|
3170
|
-
//start
|
|
3171
|
-
this.storeDependentItems = newOptions;
|
|
3172
3142
|
if (!this.commonService.getDropDownFlag()) {
|
|
3173
3143
|
this.storeDependentItems = this.instance.component.data.values;
|
|
3174
3144
|
}
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
this.
|
|
3179
|
-
}
|
|
3180
|
-
if (newHash !== this.lastOptionsHash) {
|
|
3181
|
-
this.lastOptionsHash = newHash;
|
|
3182
|
-
this.storeDependentItems = newOptions;
|
|
3183
|
-
if (!this.commonService.getDropDownFlag()) {
|
|
3184
|
-
this.storeDependentItems = this.instance.component.data.values;
|
|
3185
|
-
}
|
|
3186
|
-
const selectedIndex = this.storeDependentItems.findIndex(item => this.compareObjects(item.value, this.control.value));
|
|
3187
|
-
if (selectedIndex < 0) {
|
|
3188
|
-
this.filteredOptions = Promise.resolve(this.storeDependentItems);
|
|
3189
|
-
this.selectOptions = Promise.resolve(this.storeDependentItems);
|
|
3190
|
-
this.selectOptions.then(result => {
|
|
3191
|
-
this.filteredOptionsLength = result.length;
|
|
3192
|
-
});
|
|
3193
|
-
}
|
|
3194
|
-
setTimeout(() => {
|
|
3195
|
-
const panel = this.selectElem?.panel?.nativeElement;
|
|
3196
|
-
if (panel && this.storeDependentItems?.length) {
|
|
3197
|
-
const matOptions = panel.querySelectorAll('.mat-option');
|
|
3198
|
-
const selected = panel.querySelector('.mat-option.mat-selected');
|
|
3199
|
-
if (selected && !selected.classList.contains('mat-active')) {
|
|
3200
|
-
matOptions.forEach(option => option.classList.remove('mat-active'));
|
|
3201
|
-
}
|
|
3202
|
-
const selectedIndex = this.storeDependentItems.findIndex(item => this.compareObjects(item.value, this.control.value));
|
|
3203
|
-
const optionHeight = 48;
|
|
3204
|
-
const visibleTop = panel.scrollTop;
|
|
3205
|
-
const visibleBottom = visibleTop + panel.offsetHeight;
|
|
3206
|
-
const itemTop = selectedIndex * optionHeight;
|
|
3207
|
-
const itemBottom = itemTop + optionHeight;
|
|
3208
|
-
const shouldScroll = selectedIndex >= 0 && (itemTop < visibleTop || itemBottom > visibleBottom);
|
|
3209
|
-
if (selectedIndex >= 0) {
|
|
3210
|
-
panel.scrollTo({
|
|
3211
|
-
top: itemTop,
|
|
3212
|
-
behavior: 'smooth'
|
|
3213
|
-
});
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
}, 150);
|
|
3217
|
-
}
|
|
3145
|
+
this.filteredOptions = Promise.resolve(this.storeDependentItems);
|
|
3146
|
+
this.selectOptions = Promise.resolve(this.storeDependentItems);
|
|
3147
|
+
this.selectOptions.then(result => {
|
|
3148
|
+
this.filteredOptionsLength = result.length;
|
|
3149
|
+
});
|
|
3218
3150
|
}
|
|
3219
3151
|
}
|
|
3220
3152
|
});
|
|
@@ -3298,7 +3230,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3298
3230
|
const dataUrl = instance.component['data']?.url;
|
|
3299
3231
|
const isSelectValuesValid = selectValues != null && selectValues !== '' && selectValues !== undefined;
|
|
3300
3232
|
const isDataUrlInvalid = dataUrl == null || dataUrl === '' || dataUrl === undefined;
|
|
3301
|
-
instance.component.defaultValue = "";
|
|
3302
3233
|
return isSelectValuesValid && isDataUrlInvalid;
|
|
3303
3234
|
}
|
|
3304
3235
|
getVendorRefList(instance) {
|
|
@@ -3315,9 +3246,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3315
3246
|
return false;
|
|
3316
3247
|
}
|
|
3317
3248
|
}
|
|
3318
|
-
isValidData(data) {
|
|
3319
|
-
return !data.some(item => !item.label?.trim() || !item.value?.trim());
|
|
3320
|
-
}
|
|
3321
3249
|
getErrorMessage() {
|
|
3322
3250
|
if (this.instance.error && this.instance.error.messages) {
|
|
3323
3251
|
const { messages } = this.instance.error;
|