From 1c51efa43b235da0c51610da152479d9dc988aaf Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 8 Mar 2023 21:26:26 +0530 Subject: [PATCH] fix(gui): add confirm option for save when switching to next record Signed-off-by: Pranav C --- .../smartsheet/expanded-form/index.vue | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/expanded-form/index.vue b/packages/nc-gui/components/smartsheet/expanded-form/index.vue index f72807f0cf..35cb7b852f 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/index.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/index.vue @@ -141,8 +141,22 @@ const onDuplicateRow = () => { } const onNext = async () => { - await save() - emits('next') + if (changedColumns.value.size > 0) { + await Modal.confirm({ + title: 'Do you want to save the changes?', + okText: 'Save', + cancelText: 'Discard', + onOk: async () => { + await save() + emits('next') + }, + onCancel: () => { + emits('next') + }, + }) + } else { + emits('next') + } } const reloadParentRowHook = inject(ReloadRowDataHookInj, createEventHook()) @@ -196,7 +210,7 @@ useActiveKeyupListener( emits('prev') } else if (e.key === 'ArrowRight') { e.stopPropagation() - emits('next') + onNext() } // on alt + s save record else if (e.code === 'KeyS') { @@ -319,7 +333,8 @@ export default { :ref="i ? null : (el) => (cellWrapperEl = el)" class="!bg-white rounded px-1 min-h-[35px] flex items-center mt-2 relative" > - +