From 7c326ce118af868c7f29e3da6a3281f1ef16b216 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 21 Oct 2022 01:14:13 +0200 Subject: [PATCH] fix(nc-gui): Add detached expanded form --- .../smartsheet/expanded-form/Detached.vue | 20 +++++++ .../smartsheet/expanded-form/index.vue | 32 +++++----- .../nc-gui/components/tabs/Smartsheet.vue | 4 ++ .../virtual-cell/components/ItemChip.vue | 39 ++++++++----- .../useExpandedFormDetached/index.ts | 58 +++++++++++++++++++ 5 files changed, 126 insertions(+), 27 deletions(-) create mode 100644 packages/nc-gui/components/smartsheet/expanded-form/Detached.vue create mode 100644 packages/nc-gui/composables/useExpandedFormDetached/index.ts diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Detached.vue b/packages/nc-gui/components/smartsheet/expanded-form/Detached.vue new file mode 100644 index 0000000000..cdc4311005 --- /dev/null +++ b/packages/nc-gui/components/smartsheet/expanded-form/Detached.vue @@ -0,0 +1,20 @@ + + + diff --git a/packages/nc-gui/components/smartsheet/expanded-form/index.vue b/packages/nc-gui/components/smartsheet/expanded-form/index.vue index 3dbb20469f..01c4505cc1 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/index.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/index.vue @@ -9,7 +9,10 @@ import { MetaInj, ReloadRowDataHookInj, computedInject, + createEventHook, + inject, message, + onBeforeMount, provide, ref, toRef, @@ -57,21 +60,23 @@ provide(MetaInj, meta) const { commentsDrawer, changedColumns, state: rowState, isNew, loadRow } = useProvideExpandedFormStore(meta, row) -if (props.loadRow) { - await loadRow() -} +onBeforeMount(async () => { + if (props.loadRow) { + await loadRow() + } -if (props.rowId) { - try { - await loadRow(props.rowId) - } catch (e: any) { - if (e.response?.status === 404) { - // todo: i18n - message.error('Record not found') - router.replace({ query: {} }) - } else throw e + if (props.rowId) { + try { + await loadRow(props.rowId) + } catch (e: any) { + if (e.response?.status === 404) { + // todo: i18n + message.error('Record not found') + router.replace({ query: {} }) + } else throw e + } } -} +}) useProvideSmartsheetStore(ref({}) as Ref, meta) @@ -134,6 +139,7 @@ export default { width="min(90vw,1000px)" :body-style="{ 'padding': 0, 'display': 'flex', 'flex-direction': 'column' }" :closable="false" + destroy-on-close class="nc-drawer-expanded-form" > diff --git a/packages/nc-gui/components/tabs/Smartsheet.vue b/packages/nc-gui/components/tabs/Smartsheet.vue index db6aad701d..38d473de5c 100644 --- a/packages/nc-gui/components/tabs/Smartsheet.vue +++ b/packages/nc-gui/components/tabs/Smartsheet.vue @@ -7,6 +7,7 @@ import { IsLockedInj, MetaInj, OpenNewRecordFormHookInj, + ReadonlyInj, ReloadViewDataHookInj, ReloadViewMetaHookInj, TabMetaInj, @@ -55,6 +56,7 @@ provide(OpenNewRecordFormHookInj, openNewRecordFormHook) provide(FieldsInj, fields) provide(IsFormInj, isForm) provide(TabMetaInj, activeTab) +provide(ReadonlyInj, false)