|
|
@ -1064,13 +1064,26 @@ async function resetAndChangePage(row: number, col: number, pageChange?: number) |
|
|
|
scrollToCell?.() |
|
|
|
scrollToCell?.() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const saveOrUpdateRecords = async (args: { metaValue?: TableType; viewMetaValue?: ViewType; data?: any } = {}) => { |
|
|
|
const temporaryNewRowStore = ref<Row[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const saveOrUpdateRecords = async ( |
|
|
|
|
|
|
|
args: { metaValue?: TableType; viewMetaValue?: ViewType; data?: any; keepNewRecords?: boolean } = {}, |
|
|
|
|
|
|
|
) => { |
|
|
|
for (const currentRow of args.data || dataRef.value) { |
|
|
|
for (const currentRow of args.data || dataRef.value) { |
|
|
|
/** if new record save row and save the LTAR cells */ |
|
|
|
/** if new record save row and save the LTAR cells */ |
|
|
|
if (currentRow.rowMeta.new) { |
|
|
|
if (currentRow.rowMeta.new) { |
|
|
|
|
|
|
|
const beforeSave = clone(currentRow) |
|
|
|
const savedRow = await updateOrSaveRow?.(currentRow, '', {}, args) |
|
|
|
const savedRow = await updateOrSaveRow?.(currentRow, '', {}, args) |
|
|
|
await syncLTARRefs?.(currentRow, savedRow, args) |
|
|
|
if (savedRow) { |
|
|
|
currentRow.rowMeta.changed = false |
|
|
|
await syncLTARRefs?.(currentRow, savedRow, args) |
|
|
|
|
|
|
|
currentRow.rowMeta.changed = false |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (args.keepNewRecords) { |
|
|
|
|
|
|
|
if (beforeSave.rowMeta.new && Object.keys(beforeSave.row).length) { |
|
|
|
|
|
|
|
temporaryNewRowStore.value.push(beforeSave) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1332,10 +1345,17 @@ async function reloadViewDataHandler(params: void | { shouldShowLoading?: boolea |
|
|
|
predictedNextColumn.value = predictedNextColumn.value.filter((c) => !fieldsAvailable?.includes(c.title)) |
|
|
|
predictedNextColumn.value = predictedNextColumn.value.filter((c) => !fieldsAvailable?.includes(c.title)) |
|
|
|
} |
|
|
|
} |
|
|
|
// save any unsaved data before reload |
|
|
|
// save any unsaved data before reload |
|
|
|
await saveOrUpdateRecords() |
|
|
|
await saveOrUpdateRecords({ |
|
|
|
|
|
|
|
keepNewRecords: true, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
await loadData?.({ ...(params?.offset !== undefined ? { offset: params.offset } : {}) }) |
|
|
|
await loadData?.({ ...(params?.offset !== undefined ? { offset: params.offset } : {}) }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (temporaryNewRowStore.value.length) { |
|
|
|
|
|
|
|
dataRef.value.push(...temporaryNewRowStore.value) |
|
|
|
|
|
|
|
temporaryNewRowStore.value = [] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
calculateSlices() |
|
|
|
calculateSlices() |
|
|
|
|
|
|
|
|
|
|
|
isViewDataLoading.value = false |
|
|
|
isViewDataLoading.value = false |
|
|
|