|
|
@ -677,9 +677,9 @@ const saveOrUpdateRecords = async (args: { metaValue?: TableType; viewMetaValue? |
|
|
|
index++ |
|
|
|
index++ |
|
|
|
/** 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 syncLTARRefs = rowRefs[index]!.syncLTARRefs |
|
|
|
const syncLTARRefs = rowRefs?.[index]?.syncLTARRefs |
|
|
|
const savedRow = await updateOrSaveRow(currentRow, '', {}, args) |
|
|
|
const savedRow = await updateOrSaveRow(currentRow, '', {}, args) |
|
|
|
await syncLTARRefs(savedRow, args) |
|
|
|
await syncLTARRefs?.(savedRow, args) |
|
|
|
currentRow.rowMeta.changed = false |
|
|
|
currentRow.rowMeta.changed = false |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
@ -700,6 +700,9 @@ const saveOrUpdateRecords = async (args: { metaValue?: TableType; viewMetaValue? |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function reloadViewDataHandler(shouldShowLoading: boolean | void) { |
|
|
|
async function reloadViewDataHandler(shouldShowLoading: boolean | void) { |
|
|
|
|
|
|
|
// save any unsaved data before reload |
|
|
|
|
|
|
|
await saveOrUpdateRecords(); |
|
|
|
|
|
|
|
|
|
|
|
// set value if spinner should be hidden |
|
|
|
// set value if spinner should be hidden |
|
|
|
showLoading.value = !!shouldShowLoading |
|
|
|
showLoading.value = !!shouldShowLoading |
|
|
|
await loadData() |
|
|
|
await loadData() |
|
|
@ -715,9 +718,21 @@ async function openNewRecordHandler() { |
|
|
|
reloadViewDataHook?.on(reloadViewDataHandler) |
|
|
|
reloadViewDataHook?.on(reloadViewDataHandler) |
|
|
|
openNewRecordFormHook?.on(openNewRecordHandler) |
|
|
|
openNewRecordFormHook?.on(openNewRecordHandler) |
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => { |
|
|
|
onBeforeUnmount(async () => { |
|
|
|
/** save/update records before unmounting the component */ |
|
|
|
/** save/update records before unmounting the component */ |
|
|
|
saveOrUpdateRecords() |
|
|
|
const viewMetaValue = view.value |
|
|
|
|
|
|
|
const dataValue = data.value |
|
|
|
|
|
|
|
if (viewMetaValue) { |
|
|
|
|
|
|
|
getMeta(viewMetaValue.fk_model_id).then((res) => { |
|
|
|
|
|
|
|
const metaValue = res |
|
|
|
|
|
|
|
if (!metaValue) return |
|
|
|
|
|
|
|
saveOrUpdateRecords({ |
|
|
|
|
|
|
|
metaValue, |
|
|
|
|
|
|
|
viewMetaValue, |
|
|
|
|
|
|
|
data: dataValue, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// reset hooks |
|
|
|
// reset hooks |
|
|
|
reloadViewDataHook?.off(reloadViewDataHandler) |
|
|
|
reloadViewDataHook?.off(reloadViewDataHandler) |
|
|
|