fix: refs #8113 ensure data is an array before assignment and optimize data processing loop
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-26 10:05:18 +01:00
parent bf1b1a8f15
commit 9b86f2ddd7
1 changed files with 3 additions and 3 deletions

View File

@ -289,10 +289,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
store.map = new Map();
}
if (!map && !append) store.data = data;
if (!Array.isArray(data) || (!map && !append)) store.data = data;
else if (!map && append) for (const row of data) store.data.push(row);
else
data.forEach((row) => {
for (const row of data) {
const key = row[store.mapKey];
const val = { ...row, key };
if (store.map.has(key)) {
@ -305,7 +305,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
store.map.set(key, val);
store.data.push(val);
}
});
}
}
const totalRows = computed(() => (store.data && store.data.length) || 0);