@amirjalili1374/ui-kit 1.4.31 → 1.4.33
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/ui-kit.es.js
CHANGED
|
@@ -17533,7 +17533,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
|
|
|
17533
17533
|
return !!props.filterComponent;
|
|
17534
17534
|
});
|
|
17535
17535
|
const fetchData = async (queryParams) => {
|
|
17536
|
-
var _a, _b;
|
|
17536
|
+
var _a, _b, _c;
|
|
17537
17537
|
loading.value = true;
|
|
17538
17538
|
error.value = null;
|
|
17539
17539
|
let params = {
|
|
@@ -17551,7 +17551,20 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
|
|
|
17551
17551
|
size: itemsPerPage.value
|
|
17552
17552
|
} : params;
|
|
17553
17553
|
const response = await api.fetch(requestParams);
|
|
17554
|
-
|
|
17554
|
+
let serverRawData = [];
|
|
17555
|
+
if (shouldPaginate) {
|
|
17556
|
+
serverRawData = ((_a = response.data) == null ? void 0 : _a.content) ?? [];
|
|
17557
|
+
} else {
|
|
17558
|
+
if (Array.isArray(response.data)) {
|
|
17559
|
+
serverRawData = response.data;
|
|
17560
|
+
} else if (((_b = response.data) == null ? void 0 : _b.content) && Array.isArray(response.data.content)) {
|
|
17561
|
+
serverRawData = response.data.content;
|
|
17562
|
+
} else if (response.data && typeof response.data === "object" && !Array.isArray(response.data)) {
|
|
17563
|
+
serverRawData = [response.data];
|
|
17564
|
+
} else {
|
|
17565
|
+
serverRawData = [];
|
|
17566
|
+
}
|
|
17567
|
+
}
|
|
17555
17568
|
const serverData = Array.isArray(serverRawData) ? serverRawData : [];
|
|
17556
17569
|
originalServerData.value = serverData;
|
|
17557
17570
|
items.value = serverData.map((item) => {
|
|
@@ -17567,7 +17580,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
|
|
|
17567
17580
|
});
|
|
17568
17581
|
return newItem;
|
|
17569
17582
|
});
|
|
17570
|
-
if (shouldPaginate && ((
|
|
17583
|
+
if (shouldPaginate && ((_c = response.data) == null ? void 0 : _c.page)) {
|
|
17571
17584
|
totalSize.value = response.data.page.totalElements;
|
|
17572
17585
|
totalPages.value = response.data.page.totalPages;
|
|
17573
17586
|
hasMore.value = currentPage.value < response.data.page.totalPages;
|
|
@@ -17777,6 +17790,78 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
|
|
|
17777
17790
|
console.error(`Error converting date for field ${header.key}:`, error2);
|
|
17778
17791
|
}
|
|
17779
17792
|
}
|
|
17793
|
+
if (hasAutocomplete(header)) {
|
|
17794
|
+
const enhancedHeader = header;
|
|
17795
|
+
const currentValue = dataToSave[header.key];
|
|
17796
|
+
const valueKey = resolveAutocompleteItemValue(header);
|
|
17797
|
+
if (enhancedHeader.autocompleteMultiple && Array.isArray(currentValue)) {
|
|
17798
|
+
const autocompleteItems = resolveAutocompleteItems(header, dataToSave);
|
|
17799
|
+
const processedArray = currentValue.map((item) => {
|
|
17800
|
+
if (item === null || item === void 0) {
|
|
17801
|
+
return null;
|
|
17802
|
+
}
|
|
17803
|
+
if (enhancedHeader.autocompleteReturnObject !== false) {
|
|
17804
|
+
if (typeof item !== "object") {
|
|
17805
|
+
return null;
|
|
17806
|
+
}
|
|
17807
|
+
const itemValue = valueKey && item[valueKey];
|
|
17808
|
+
if (itemValue !== null && itemValue !== void 0) {
|
|
17809
|
+
const fullItem = autocompleteItems.find((autocompleteItem) => {
|
|
17810
|
+
const autocompleteValue = autocompleteItem[valueKey];
|
|
17811
|
+
return autocompleteValue !== null && autocompleteValue !== void 0 && String(autocompleteValue) === String(itemValue);
|
|
17812
|
+
});
|
|
17813
|
+
if (fullItem && typeof fullItem === "object") {
|
|
17814
|
+
return fullItem;
|
|
17815
|
+
}
|
|
17816
|
+
}
|
|
17817
|
+
const propertyValues = Object.values(item);
|
|
17818
|
+
if (propertyValues.length === 0) {
|
|
17819
|
+
return null;
|
|
17820
|
+
}
|
|
17821
|
+
const allPropertiesEmpty = propertyValues.every(
|
|
17822
|
+
(val2) => val2 === null || val2 === void 0 || val2 === ""
|
|
17823
|
+
);
|
|
17824
|
+
if (allPropertiesEmpty) {
|
|
17825
|
+
return null;
|
|
17826
|
+
}
|
|
17827
|
+
return item;
|
|
17828
|
+
}
|
|
17829
|
+
return item !== null && item !== void 0 && item !== "" ? item : null;
|
|
17830
|
+
}).filter((item) => item !== null && item !== void 0);
|
|
17831
|
+
dataToSave[header.key] = processedArray;
|
|
17832
|
+
} else if (currentValue === null || currentValue === void 0 || currentValue === "") {
|
|
17833
|
+
dataToSave[header.key] = null;
|
|
17834
|
+
} else if (enhancedHeader.autocompleteReturnObject !== false && typeof currentValue === "object") {
|
|
17835
|
+
const autocompleteItems = resolveAutocompleteItems(header, dataToSave);
|
|
17836
|
+
const valueKey2 = resolveAutocompleteItemValue(header);
|
|
17837
|
+
const itemValue = valueKey2 && currentValue[valueKey2];
|
|
17838
|
+
if (itemValue !== null && itemValue !== void 0) {
|
|
17839
|
+
const fullItem = autocompleteItems.find((autocompleteItem) => {
|
|
17840
|
+
const autocompleteValue = autocompleteItem[valueKey2];
|
|
17841
|
+
return autocompleteValue !== null && autocompleteValue !== void 0 && String(autocompleteValue) === String(itemValue);
|
|
17842
|
+
});
|
|
17843
|
+
if (fullItem && typeof fullItem === "object") {
|
|
17844
|
+
dataToSave[header.key] = fullItem;
|
|
17845
|
+
}
|
|
17846
|
+
}
|
|
17847
|
+
}
|
|
17848
|
+
}
|
|
17849
|
+
});
|
|
17850
|
+
props.headers.forEach((header) => {
|
|
17851
|
+
if (hasAutocomplete(header) && dataToSave[header.key]) {
|
|
17852
|
+
const enhancedHeader = header;
|
|
17853
|
+
if (enhancedHeader.autocompleteMultiple && Array.isArray(dataToSave[header.key])) {
|
|
17854
|
+
console.log(`[CustomDataTable] Autocomplete field "${header.key}" (${dataToSave[header.key].length} items) before save:`, dataToSave[header.key]);
|
|
17855
|
+
const itemsWithNulls = dataToSave[header.key].filter(
|
|
17856
|
+
(item) => item && typeof item === "object" && Object.values(item).some((val2) => val2 === null)
|
|
17857
|
+
);
|
|
17858
|
+
if (itemsWithNulls.length > 0) {
|
|
17859
|
+
console.warn(`[CustomDataTable] Warning: Found ${itemsWithNulls.length} items with null properties in "${header.key}":`, itemsWithNulls);
|
|
17860
|
+
}
|
|
17861
|
+
} else {
|
|
17862
|
+
console.log(`[CustomDataTable] Autocomplete field "${header.key}" before save:`, dataToSave[header.key]);
|
|
17863
|
+
}
|
|
17864
|
+
}
|
|
17780
17865
|
});
|
|
17781
17866
|
if (isEditing.value && dataToSave.id) {
|
|
17782
17867
|
await api.update(dataToSave);
|