From 1cb3b051140c6a999fec16028a66db902679c433 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 9 Sep 2022 23:16:45 +0530 Subject: [PATCH] fix(gui): avoid linking if new record Signed-off-by: Pranav C --- .../nc-gui/components/smartsheet/expanded-form/Header.vue | 4 +++- packages/nc-gui/components/smartsheet/expanded-form/index.vue | 1 + .../nc-gui/components/virtual-cell/components/ListItems.vue | 1 + packages/nc-gui/composables/useExpandedFormStore.ts | 2 -- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue index 0ef3fe57b0..cf42db3df6 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue @@ -11,11 +11,13 @@ const { isNew, syncLTARRefs } = useSmartsheetRowStoreOrThrow() const { isUIAllowed } = useUIPermission() +const reloadTrigger = inject(ReloadViewDataHookInj)! + const save = async () => { if (isNew.value) { const data = await _save() await syncLTARRefs(data) - await loadRow() + reloadTrigger?.trigger() } else { await _save() } diff --git a/packages/nc-gui/components/smartsheet/expanded-form/index.vue b/packages/nc-gui/components/smartsheet/expanded-form/index.vue index 9c99a9882b..b05a37c9a3 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/index.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/index.vue @@ -86,6 +86,7 @@ const reloadTrigger = inject(ReloadViewDataHookInj)! const reloadHook = createEventHook() reloadHook.on(() => { + if (isNew.value) return loadRow() reloadTrigger?.trigger() }) diff --git a/packages/nc-gui/components/virtual-cell/components/ListItems.vue b/packages/nc-gui/components/virtual-cell/components/ListItems.vue index e6fdb82f5c..d0295fc950 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListItems.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListItems.vue @@ -64,6 +64,7 @@ const expandedFormDlg = ref(false) /** populate initial state for a new row which is parent/child of current record */ const newRowState = computed(() => { + if(isNew.value) return {} const colOpt = (column?.value as ColumnType)?.colOptions as LinkToAnotherRecordType const colInRelatedTable: ColumnType | undefined = relatedTableMeta?.value?.columns?.find((col) => { if (col.uidt !== UITypes.LinkToAnotherRecord) return false diff --git a/packages/nc-gui/composables/useExpandedFormStore.ts b/packages/nc-gui/composables/useExpandedFormStore.ts index b45dd1b501..b6664cf0a3 100644 --- a/packages/nc-gui/composables/useExpandedFormStore.ts +++ b/packages/nc-gui/composables/useExpandedFormStore.ts @@ -30,7 +30,6 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m const { project } = useProject() const rowStore = useProvideSmartsheetRowStore(meta, row) const { sharedView } = useSharedView() as Record - const reloadTrigger = inject(ReloadViewDataHookInj)! // todo // const activeView = inject(ActiveViewInj) @@ -170,7 +169,6 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m message.success(`${primaryValue.value || 'Row'} updated successfully.`) changedColumns.value = new Set() - reloadTrigger?.trigger() } catch (e: any) { message.error(`${t('msg.error.rowUpdateFailed')}: ${await extractSdkResponseErrorMsg(e)}`) }