From 5e60516d168fdf88e586a0f3bed95cf506e282ae Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 27 Aug 2022 17:01:10 +0300 Subject: [PATCH] fix: add new row from gallery view Signed-off-by: mertmit --- .../components/smartsheet/Gallery.vue | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet/Gallery.vue b/packages/nc-gui-v2/components/smartsheet/Gallery.vue index 91538a992d..a62afae855 100644 --- a/packages/nc-gui-v2/components/smartsheet/Gallery.vue +++ b/packages/nc-gui-v2/components/smartsheet/Gallery.vue @@ -3,7 +3,17 @@ import { isVirtualCol } from 'nocodb-sdk' import { inject, provide, useViewData } from '#imports' import Row from '~/components/smartsheet/Row.vue' import type { Row as RowType } from '~/composables' -import { ActiveViewInj, ChangePageInj, FieldsInj, IsFormInj, IsGridInj, MetaInj, PaginationDataInj, ReadonlyInj } from '~/context' +import { + ActiveViewInj, + ChangePageInj, + FieldsInj, + IsFormInj, + IsGridInj, + MetaInj, + OpenNewRecordFormHookInj, + PaginationDataInj, + ReadonlyInj, +} from '~/context' import ImageIcon from '~icons/mdi/file-image-box' interface Attachment { @@ -13,12 +23,21 @@ interface Attachment { const meta = inject(MetaInj) const view = inject(ActiveViewInj) const reloadViewDataHook = inject(ReloadViewDataHookInj) +const openNewRecordFormHook = inject(OpenNewRecordFormHookInj, createEventHook()) const expandedFormDlg = ref(false) const expandedFormRow = ref() const expandedFormRowState = ref>() -const { loadData, paginationData, formattedData: data, loadGalleryData, galleryData, changePage } = useViewData(meta, view as any) +const { + loadData, + paginationData, + formattedData: data, + loadGalleryData, + galleryData, + changePage, + addEmptyRow, +} = useViewData(meta, view as any) const { isUIAllowed } = useUIPermission() @@ -68,6 +87,11 @@ const expandForm = (row: RowType, state?: Record) => { expandedFormRowState.value = state expandedFormDlg.value = true } + +openNewRecordFormHook?.on(async () => { + const newRow = await addEmptyRow() + expandForm(newRow) +})