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
|
@@ -2687,6 +2687,7 @@ class CommonService {
|
|
|
2687
2687
|
}
|
|
2688
2688
|
}
|
|
2689
2689
|
loadProducts(pageNumber, pazeSize, search = '', onlyActive = true, description = false, levelOneId, levelTwoId, levelThreeId, levelFourId) {
|
|
2690
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2690
2691
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2691
2692
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2692
2693
|
const programId = this.getValueByKey(this.paramsData, 'programId');
|
|
@@ -2697,6 +2698,7 @@ class CommonService {
|
|
|
2697
2698
|
return this.http.get(apiUrl);
|
|
2698
2699
|
}
|
|
2699
2700
|
listSubCategory(category) {
|
|
2701
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2700
2702
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2701
2703
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2702
2704
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductsSubCategory?vendorId=${vendorId}&categoryName=${category}`);
|
|
@@ -2718,26 +2720,31 @@ class CommonService {
|
|
|
2718
2720
|
return queryString;
|
|
2719
2721
|
}
|
|
2720
2722
|
listProductCategory() {
|
|
2723
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2721
2724
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2722
2725
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2723
2726
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductsCategory?vendorId=${vendorId}`);
|
|
2724
2727
|
}
|
|
2725
2728
|
productLevelOne() {
|
|
2729
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2726
2730
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2727
2731
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2728
2732
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductLevelOne?vendorId=${vendorId}`);
|
|
2729
2733
|
}
|
|
2730
2734
|
productLevelTwo(levelOneId) {
|
|
2735
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2731
2736
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2732
2737
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2733
2738
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductLevelTwo?levelOneId=${levelOneId}&vendorId=${vendorId}`);
|
|
2734
2739
|
}
|
|
2735
2740
|
productLevelThree(levelOneId, levelTwoId) {
|
|
2741
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2736
2742
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2737
2743
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2738
2744
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductLevelThree?levelOneId=${levelOneId}&levelTwoId=${levelTwoId}&vendorId=${vendorId}`);
|
|
2739
2745
|
}
|
|
2740
2746
|
productLevelFour(levelOneId, levelTwoId, levelThreeId) {
|
|
2747
|
+
this.paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
|
|
2741
2748
|
const baseApiUrl = this.getBaseApiUrl();
|
|
2742
2749
|
const vendorId = this.getValueByKey(this.paramsData, 'vendorId');
|
|
2743
2750
|
return this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetProductLevelFour?levelOneId=${levelOneId}&levelTwoId=${levelTwoId}&levelThreeId=${levelThreeId}&vendorId=${vendorId}`);
|
|
@@ -2771,12 +2778,8 @@ class CommonService {
|
|
|
2771
2778
|
}
|
|
2772
2779
|
/*Funtion to check if property is matched with given attributes in formBuilder or not */
|
|
2773
2780
|
checkIsAttributeTrue(newProductPickerFlag, attributeName) {
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
// newProductPickerFlag[key].toLowerCase() === "true"
|
|
2777
|
-
// );
|
|
2778
|
-
return newProductPickerFlag && Object.keys(newProductPickerFlag).some(key => key.trim().toLowerCase() === attributeName.trim().toLowerCase() &&
|
|
2779
|
-
String(newProductPickerFlag[key]).trim().toLowerCase() === "true");
|
|
2781
|
+
return newProductPickerFlag && Object.keys(newProductPickerFlag).some(key => key.toLocaleLowerCase() === attributeName.toLowerCase() &&
|
|
2782
|
+
newProductPickerFlag[key].toLowerCase() === "true");
|
|
2780
2783
|
}
|
|
2781
2784
|
getglobedata() {
|
|
2782
2785
|
const hostMappings = {
|
|
@@ -2841,8 +2844,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2841
2844
|
this.storeDependentItems = [];
|
|
2842
2845
|
this.executionFlag = false;
|
|
2843
2846
|
this.apiCounter = 0;
|
|
2844
|
-
this.lastOptionsHash = '';
|
|
2845
|
-
this.hasInitializedOptions = false;
|
|
2846
2847
|
}
|
|
2847
2848
|
onInputChange(event) {
|
|
2848
2849
|
if (this.instance.component.key.toLowerCase() === 'vendorproductid' && event.target.value === '') {
|
|
@@ -3048,7 +3049,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3048
3049
|
const vendorId = this.getValueByKey(paramsData, 'vendorId');
|
|
3049
3050
|
const dealId = this.getValueByKey(paramsData, 'dealId');
|
|
3050
3051
|
const isEdit = this.getValueByKey(paramsData, 'isEdit');
|
|
3051
|
-
this.isEditFlag = isEdit;
|
|
3052
3052
|
let finalParams;
|
|
3053
3053
|
((_c = (_b = (_a = this.instance) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.length) && this.instance.parent.components.forEach(items => {
|
|
3054
3054
|
var _a, _b, _c, _d;
|
|
@@ -3104,8 +3104,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3104
3104
|
// If the object doesn't exist, add it to the array
|
|
3105
3105
|
finalParams.push({ key: 'dataValue', value: value });
|
|
3106
3106
|
}
|
|
3107
|
-
this.secondDropdownItems = [];
|
|
3108
|
-
this.commonService.setDropdownItems(this.secondDropdownItems);
|
|
3109
3107
|
this.commonService.initializeApiPath(apiEndPoint, finalParams).subscribe(response => {
|
|
3110
3108
|
if (response && response.code === 200) {
|
|
3111
3109
|
this.secondDropdownItems = response.data;
|
|
@@ -3125,7 +3123,7 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3125
3123
|
}
|
|
3126
3124
|
}
|
|
3127
3125
|
this.selectElem.openedChange.subscribe((isOpen) => __awaiter(this, void 0, void 0, function* () {
|
|
3128
|
-
var _a, _b;
|
|
3126
|
+
var _a, _b, _c;
|
|
3129
3127
|
let i = 0;
|
|
3130
3128
|
if (isOpen) {
|
|
3131
3129
|
const newProductPickerFlag = (_b = (_a = this.instance) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.attributes;
|
|
@@ -3141,89 +3139,21 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3141
3139
|
});
|
|
3142
3140
|
}
|
|
3143
3141
|
if (this.checkVendorRefItems(this.instance) && checkInvokeFromLibrary) {
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
// });
|
|
3150
|
-
// }
|
|
3151
|
-
// if (!this.commonService.getDropDownFlag()) {
|
|
3152
|
-
// this.storeDependentItems = this.instance.component.data.values;
|
|
3153
|
-
// }
|
|
3154
|
-
// this.filteredOptions = Promise.resolve(this.storeDependentItems);
|
|
3155
|
-
// this.selectOptions = Promise.resolve(this.storeDependentItems);
|
|
3156
|
-
// this.selectOptions.then(result => {
|
|
3157
|
-
// this.filteredOptionsLength = result.length
|
|
3158
|
-
// });
|
|
3159
|
-
const incomingItems = this.commonService.getDropdownItems();
|
|
3160
|
-
const seen = new Set();
|
|
3161
|
-
const newOptions = [];
|
|
3162
|
-
if (incomingItems === null || incomingItems === void 0 ? void 0 : incomingItems.length) {
|
|
3163
|
-
incomingItems.forEach(item => {
|
|
3164
|
-
var _a;
|
|
3165
|
-
const rawValue = this.commonService.onlyNumbers(item['value']) ? item['value'] + ' ' : item['value'];
|
|
3166
|
-
const label = (_a = item['text']) === null || _a === void 0 ? void 0 : _a.trim();
|
|
3167
|
-
if (label && rawValue) {
|
|
3168
|
-
const key = `${label}-${rawValue}`;
|
|
3169
|
-
if (!seen.has(key)) {
|
|
3170
|
-
seen.add(key);
|
|
3171
|
-
newOptions.push({ label, value: rawValue });
|
|
3172
|
-
}
|
|
3173
|
-
}
|
|
3142
|
+
this.storeDependentItems = [];
|
|
3143
|
+
this.secondDropdownItems = this.commonService.getDropdownItems();
|
|
3144
|
+
if ((_c = this.secondDropdownItems) === null || _c === void 0 ? void 0 : _c.length) {
|
|
3145
|
+
this.secondDropdownItems.forEach((renderElement, index, array) => {
|
|
3146
|
+
this.storeDependentItems.push({ label: renderElement['text'], value: this.commonService.onlyNumbers(renderElement['value']) ? renderElement['value'] + ' ' : renderElement['value'] });
|
|
3174
3147
|
});
|
|
3175
3148
|
}
|
|
3176
|
-
// compare hashes to avoid unnecessary reassignments
|
|
3177
|
-
const newHash = JSON.stringify(newOptions);
|
|
3178
|
-
//start
|
|
3179
|
-
this.storeDependentItems = newOptions;
|
|
3180
3149
|
if (!this.commonService.getDropDownFlag()) {
|
|
3181
3150
|
this.storeDependentItems = this.instance.component.data.values;
|
|
3182
3151
|
}
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
this.
|
|
3187
|
-
}
|
|
3188
|
-
if (newHash !== this.lastOptionsHash) {
|
|
3189
|
-
this.lastOptionsHash = newHash;
|
|
3190
|
-
this.storeDependentItems = newOptions;
|
|
3191
|
-
if (!this.commonService.getDropDownFlag()) {
|
|
3192
|
-
this.storeDependentItems = this.instance.component.data.values;
|
|
3193
|
-
}
|
|
3194
|
-
const selectedIndex = this.storeDependentItems.findIndex(item => this.compareObjects(item.value, this.control.value));
|
|
3195
|
-
if (selectedIndex < 0) {
|
|
3196
|
-
this.filteredOptions = Promise.resolve(this.storeDependentItems);
|
|
3197
|
-
this.selectOptions = Promise.resolve(this.storeDependentItems);
|
|
3198
|
-
this.selectOptions.then(result => {
|
|
3199
|
-
this.filteredOptionsLength = result.length;
|
|
3200
|
-
});
|
|
3201
|
-
}
|
|
3202
|
-
setTimeout(() => {
|
|
3203
|
-
var _a, _b, _c;
|
|
3204
|
-
const panel = (_b = (_a = this.selectElem) === null || _a === void 0 ? void 0 : _a.panel) === null || _b === void 0 ? void 0 : _b.nativeElement;
|
|
3205
|
-
if (panel && ((_c = this.storeDependentItems) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
3206
|
-
const matOptions = panel.querySelectorAll('.mat-option');
|
|
3207
|
-
const selected = panel.querySelector('.mat-option.mat-selected');
|
|
3208
|
-
if (selected && !selected.classList.contains('mat-active')) {
|
|
3209
|
-
matOptions.forEach(option => option.classList.remove('mat-active'));
|
|
3210
|
-
}
|
|
3211
|
-
const selectedIndex = this.storeDependentItems.findIndex(item => this.compareObjects(item.value, this.control.value));
|
|
3212
|
-
const optionHeight = 48;
|
|
3213
|
-
const visibleTop = panel.scrollTop;
|
|
3214
|
-
const visibleBottom = visibleTop + panel.offsetHeight;
|
|
3215
|
-
const itemTop = selectedIndex * optionHeight;
|
|
3216
|
-
const itemBottom = itemTop + optionHeight;
|
|
3217
|
-
const shouldScroll = selectedIndex >= 0 && (itemTop < visibleTop || itemBottom > visibleBottom);
|
|
3218
|
-
if (selectedIndex >= 0) {
|
|
3219
|
-
panel.scrollTo({
|
|
3220
|
-
top: itemTop,
|
|
3221
|
-
behavior: 'smooth'
|
|
3222
|
-
});
|
|
3223
|
-
}
|
|
3224
|
-
}
|
|
3225
|
-
}, 150);
|
|
3226
|
-
}
|
|
3152
|
+
this.filteredOptions = Promise.resolve(this.storeDependentItems);
|
|
3153
|
+
this.selectOptions = Promise.resolve(this.storeDependentItems);
|
|
3154
|
+
this.selectOptions.then(result => {
|
|
3155
|
+
this.filteredOptionsLength = result.length;
|
|
3156
|
+
});
|
|
3227
3157
|
}
|
|
3228
3158
|
}
|
|
3229
3159
|
}));
|
|
@@ -3309,7 +3239,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3309
3239
|
const dataUrl = (_a = instance.component['data']) === null || _a === void 0 ? void 0 : _a.url;
|
|
3310
3240
|
const isSelectValuesValid = selectValues != null && selectValues !== '' && selectValues !== undefined;
|
|
3311
3241
|
const isDataUrlInvalid = dataUrl == null || dataUrl === '' || dataUrl === undefined;
|
|
3312
|
-
instance.component.defaultValue = "";
|
|
3313
3242
|
return isSelectValuesValid && isDataUrlInvalid;
|
|
3314
3243
|
}
|
|
3315
3244
|
getVendorRefList(instance) {
|
|
@@ -3327,9 +3256,6 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
3327
3256
|
return false;
|
|
3328
3257
|
}
|
|
3329
3258
|
}
|
|
3330
|
-
isValidData(data) {
|
|
3331
|
-
return !data.some(item => { var _a, _b; return !((_a = item.label) === null || _a === void 0 ? void 0 : _a.trim()) || !((_b = item.value) === null || _b === void 0 ? void 0 : _b.trim()); });
|
|
3332
|
-
}
|
|
3333
3259
|
getErrorMessage() {
|
|
3334
3260
|
if (this.instance.error && this.instance.error.messages) {
|
|
3335
3261
|
const { messages } = this.instance.error;
|