@znap/components-vue2 1.1.2 → 1.1.3
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/dist/index.common.js +53 -17
- package/dist/index.common.js.map +1 -1
- package/dist/index.umd.js +53 -17
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/utils/views/generateCrudViewConfigs.d.ts +5 -2
- package/package.json +1 -1
package/dist/index.common.js
CHANGED
|
@@ -50722,8 +50722,11 @@ class CrudViewConfigs {
|
|
|
50722
50722
|
};
|
|
50723
50723
|
}
|
|
50724
50724
|
validateFiltersKeyHaveChange(filters, currentFilters, keysToValidate = ["search", "primary", "secondary"]) {
|
|
50725
|
+
const filtersToCheck = this.getCurrentFilters(filters);
|
|
50725
50726
|
return keysToValidate.some(key => {
|
|
50726
|
-
if (Array.isArray(filters[key]))
|
|
50727
|
+
if (Array.isArray(filters[key])) {
|
|
50728
|
+
return filtersToCheck[key].some((filterValue, index) => filterValue !== currentFilters[key][index]);
|
|
50729
|
+
}
|
|
50727
50730
|
return filters[key] !== currentFilters[key];
|
|
50728
50731
|
});
|
|
50729
50732
|
}
|
|
@@ -50861,30 +50864,63 @@ class CrudViewConfigs {
|
|
|
50861
50864
|
this.currentFilters.search = filters.search;
|
|
50862
50865
|
return this.currentFilters;
|
|
50863
50866
|
}
|
|
50864
|
-
|
|
50867
|
+
getCurrentFilters(filters) {
|
|
50868
|
+
const currentFilters = {
|
|
50869
|
+
primary: [],
|
|
50870
|
+
secondary: [],
|
|
50871
|
+
search: ""
|
|
50872
|
+
};
|
|
50873
|
+
filters?.primary?.forEach(tab => {
|
|
50874
|
+
tab.filters.forEach(filter => {
|
|
50875
|
+
if (filter?.type === "display") return;
|
|
50876
|
+
currentFilters.primary.push(filter.value);
|
|
50877
|
+
});
|
|
50878
|
+
});
|
|
50879
|
+
filters?.secondary?.forEach(tab => {
|
|
50880
|
+
tab.filters.forEach(filter => {
|
|
50881
|
+
if (filter?.type === "display") return;
|
|
50882
|
+
currentFilters.secondary.push(filter.value);
|
|
50883
|
+
});
|
|
50884
|
+
});
|
|
50885
|
+
currentFilters.search = filters.search;
|
|
50886
|
+
return currentFilters;
|
|
50887
|
+
}
|
|
50888
|
+
async fetchTableOption(tableOption, httpFetcher) {
|
|
50889
|
+
if (!tableOption.endpoint?.length || !tableOption?.endpoint[0]) return;
|
|
50890
|
+
try {
|
|
50891
|
+
const response = await httpFetcher.post(tableOption.endpoint[0], tableOption.endpoint[1] ?? {});
|
|
50892
|
+
tableOption.items = response?.data?.rows ?? [];
|
|
50893
|
+
} catch (error) {
|
|
50894
|
+
console.error(error);
|
|
50895
|
+
}
|
|
50896
|
+
}
|
|
50897
|
+
async fetchTableOptionsData(tableOptions, httpFetcher) {
|
|
50865
50898
|
const optionsPromises = [];
|
|
50866
50899
|
tableOptions.forEach(option => {
|
|
50867
|
-
if (!option.endpoint?.length || !option?.endpoint[0]) return optionsPromises.push(null);
|
|
50868
50900
|
if (option?.ignoreOnFetchFunction) return optionsPromises.push(null);
|
|
50869
|
-
optionsPromises.push(
|
|
50870
|
-
});
|
|
50871
|
-
const optionsData = await Promise.all(optionsPromises);
|
|
50872
|
-
optionsData.forEach((option, index) => {
|
|
50873
|
-
tableOptions[index].items = option?.data?.rows ?? [];
|
|
50901
|
+
optionsPromises.push(this.fetchTableOption(option, httpFetcher));
|
|
50874
50902
|
});
|
|
50903
|
+
await Promise.all(optionsPromises);
|
|
50875
50904
|
}
|
|
50876
|
-
async
|
|
50905
|
+
async fetchFormOption(formOption, httpFetcher) {
|
|
50906
|
+
if (!formOption.endpoint?.length || !formOption?.endpoint[0]) return;
|
|
50907
|
+
try {
|
|
50908
|
+
formOption.loading = true;
|
|
50909
|
+
const response = await httpFetcher.post(formOption.endpoint[0], formOption.endpoint[1] ?? {});
|
|
50910
|
+
formOption.items = response?.data?.rows ?? [];
|
|
50911
|
+
} catch (error) {
|
|
50912
|
+
console.error(error);
|
|
50913
|
+
} finally {
|
|
50914
|
+
formOption.loading = false;
|
|
50915
|
+
}
|
|
50916
|
+
}
|
|
50917
|
+
async fetchFormOptionsData(formOptions, httpFetcher) {
|
|
50877
50918
|
const optionsPromises = [];
|
|
50878
50919
|
formOptions.forEach(option => {
|
|
50879
|
-
option.
|
|
50880
|
-
|
|
50881
|
-
optionsPromises.push(httpFetcher.post(option.endpoint[0], option.endpoint[1] ?? null));
|
|
50882
|
-
});
|
|
50883
|
-
const optionsData = await Promise.all(optionsPromises);
|
|
50884
|
-
optionsData.forEach((option, index) => {
|
|
50885
|
-
formOptions[index].items = option?.data?.rows ?? [];
|
|
50886
|
-
formOptions[index].loading = false;
|
|
50920
|
+
if (option.ignoreOnFetchFunction) return;
|
|
50921
|
+
optionsPromises.push(this.fetchFormOption(option, httpFetcher));
|
|
50887
50922
|
});
|
|
50923
|
+
await Promise.all(optionsPromises);
|
|
50888
50924
|
}
|
|
50889
50925
|
async fetchFilter(filter, httpFetcher) {
|
|
50890
50926
|
if (!filter.endpoint?.length || !filter.endpoint[0]) return;
|