Browse Source

fix: add new row from gallery view

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3379/head
mertmit 2 years ago
parent
commit
5e60516d16
  1. 28
      packages/nc-gui-v2/components/smartsheet/Gallery.vue

28
packages/nc-gui-v2/components/smartsheet/Gallery.vue

@ -3,7 +3,17 @@ import { isVirtualCol } from 'nocodb-sdk'
import { inject, provide, useViewData } from '#imports' import { inject, provide, useViewData } from '#imports'
import Row from '~/components/smartsheet/Row.vue' import Row from '~/components/smartsheet/Row.vue'
import type { Row as RowType } from '~/composables' 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' import ImageIcon from '~icons/mdi/file-image-box'
interface Attachment { interface Attachment {
@ -13,12 +23,21 @@ interface Attachment {
const meta = inject(MetaInj) const meta = inject(MetaInj)
const view = inject(ActiveViewInj) const view = inject(ActiveViewInj)
const reloadViewDataHook = inject(ReloadViewDataHookInj) const reloadViewDataHook = inject(ReloadViewDataHookInj)
const openNewRecordFormHook = inject(OpenNewRecordFormHookInj, createEventHook())
const expandedFormDlg = ref(false) const expandedFormDlg = ref(false)
const expandedFormRow = ref<RowType>() const expandedFormRow = ref<RowType>()
const expandedFormRowState = ref<Record<string, any>>() const expandedFormRowState = ref<Record<string, any>>()
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() const { isUIAllowed } = useUIPermission()
@ -68,6 +87,11 @@ const expandForm = (row: RowType, state?: Record<string, any>) => {
expandedFormRowState.value = state expandedFormRowState.value = state
expandedFormDlg.value = true expandedFormDlg.value = true
} }
openNewRecordFormHook?.on(async () => {
const newRow = await addEmptyRow()
expandForm(newRow)
})
</script> </script>
<template> <template>

Loading…
Cancel
Save