diff --git a/packages/nc-gui-v2/components/smartsheet/Cell.vue b/packages/nc-gui-v2/components/smartsheet/Cell.vue index 4175fb2b4c..26b9087cdd 100644 --- a/packages/nc-gui-v2/components/smartsheet/Cell.vue +++ b/packages/nc-gui-v2/components/smartsheet/Cell.vue @@ -23,6 +23,7 @@ interface Props { column: ColumnType modelValue: any editEnabled: boolean + readOnly?: boolean rowIndex?: number active?: boolean virtual?: boolean @@ -38,12 +39,18 @@ const active = toRef(props, 'active', false) const virtual = toRef(props, 'virtual', false) +const readOnly = toRef(props, 'readOnly', undefined) + provide(ColumnInj, column) provide(EditModeInj, useVModel(props, 'editEnabled', emit)) provide(ActiveCellInj, active) +if (readOnly?.value) { + provide(ReadonlyInj, readOnly.value) +} + const isForm = inject(IsFormInj, ref(false)) const isPublic = inject(IsPublicInj, ref(false)) diff --git a/packages/nc-gui-v2/components/smartsheet/Gallery.vue b/packages/nc-gui-v2/components/smartsheet/Gallery.vue index 4c5a6bc4e0..f271b87fc6 100644 --- a/packages/nc-gui-v2/components/smartsheet/Gallery.vue +++ b/packages/nc-gui-v2/components/smartsheet/Gallery.vue @@ -2,6 +2,7 @@ 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 ImageIcon from '~icons/mdi/file-image-box' @@ -13,13 +14,19 @@ const meta = inject(MetaInj) const view = inject(ActiveViewInj) const reloadViewDataHook = inject(ReloadViewDataHookInj) +const expandedFormDlg = ref(false) +const expandedFormRow = ref() +const expandedFormRowState = ref>() + const { loadData, paginationData, formattedData: data, loadGalleryData, galleryData, changePage } = useViewData(meta, view as any) +const { isUIAllowed } = useUIPermission() + provide(IsFormInj, ref(false)) provide(IsGridInj, false) provide(PaginationDataInj, paginationData) provide(ChangePageInj, changePage) -provide(ReadonlyInj, true) +provide(ReadonlyInj, !isUIAllowed('xcDatatableEditable')) const fields = inject(FieldsInj, ref([])) @@ -54,12 +61,19 @@ const attachments = (record: any): Array => { reloadViewDataHook?.on(async () => { await loadData() }) + +const expandForm = (row: RowType, state?: Record) => { + if (!isUIAllowed('xcDatatableEditable')) return + expandedFormRow.value = row + expandedFormRowState.value = state + expandedFormDlg.value = true +}