diff --git a/packages/nc-gui-v2/components/smartsheet-header/Menu.vue b/packages/nc-gui-v2/components/smartsheet-header/Menu.vue index ec34dd7c9c..4c992422e6 100644 --- a/packages/nc-gui-v2/components/smartsheet-header/Menu.vue +++ b/packages/nc-gui-v2/components/smartsheet-header/Menu.vue @@ -67,7 +67,7 @@ const setAsPrimaryValue = async () => { {{ $t('general.edit') }} -
+
diff --git a/packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue b/packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue index a73f2d5195..187b30cb6d 100644 --- a/packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue +++ b/packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue @@ -146,7 +146,7 @@ provide(ColumnInj, column) - +
diff --git a/packages/nc-gui-v2/components/smartsheet/Grid.vue b/packages/nc-gui-v2/components/smartsheet/Grid.vue index e4fb52653d..edfda8754b 100644 --- a/packages/nc-gui-v2/components/smartsheet/Grid.vue +++ b/packages/nc-gui-v2/components/smartsheet/Grid.vue @@ -8,6 +8,7 @@ import { useGridViewColumnWidth, useProvideColumnCreateStore, useViewData, + useSmartsheetStoreOrThrow } from '#imports' import { ActiveViewInj, @@ -16,18 +17,20 @@ import { FieldsInj, IsFormInj, IsGridInj, + IsLockedInj, MetaInj, PaginationDataInj, ReloadViewDataHookInj, } from '~/context' import MdiPlusIcon from '~icons/mdi/plus' +import MdiArrowExpandIcon from '~icons/mdi/arrow-expand' const meta = inject(MetaInj) const view = inject(ActiveViewInj) // keep a root fields variable and will get modified from // fields menu and get used in grid and gallery -const fields = inject(FieldsInj) - +const fields = inject(FieldsInj, ref([])) +const isLocked = inject(IsLockedInj, false) // todo: get from parent ( inject or use prop ) const isPublicView = false @@ -37,15 +40,28 @@ const { sqlUi } = useProject() const { xWhere } = useSmartsheetStoreOrThrow() const addColumnDropdown = ref(false) -const { loadData, paginationData, formattedData: data, updateRowProperty, changePage } = useViewData(meta, view as any, xWhere) +const visibleColLength = computed(() => { + const cols = fields.value + return cols.filter((col) => !isVirtualCol(col)).length +}) + +const { + loadData, + paginationData, + formattedData: data, + updateRowProperty, + changePage, + addRow, + selectedRows, +} = useViewData(meta, view as any, xWhere) const { loadGridViewColumns, updateWidth, resizingColWidth, resizingCol } = useGridViewColumnWidth(view) onMounted(loadGridViewColumns) provide(IsFormInj, false) provide(IsGridInj, true) provide(PaginationDataInj, paginationData) -provide(ChangePageInj, changePage) provide(EditModeInj, editEnabled) +provide(ChangePageInj, changePage) const reloadViewDataHook = inject(ReloadViewDataHookInj) reloadViewDataHook?.on(() => { @@ -124,10 +140,15 @@ if (meta) useProvideColumnCreateStore(meta) - - -
- {{ rowIndex + 1 }} + + +
+
{{ rowIndex + 1 }}
+
+ + +
+ + + + + +
+ + + {{ $t('activity.addRow') }} + +
+ +
+ +
@@ -175,6 +215,10 @@ if (meta) useProvideColumnCreateStore(meta) height: 41px !important; position: relative; padding: 0 5px; + + & > * { + @apply flex align-center h-auto; + } overflow: hidden; } diff --git a/packages/nc-gui-v2/composables/useViewData.ts b/packages/nc-gui-v2/composables/useViewData.ts index 1a31b877f7..c1a843619e 100644 --- a/packages/nc-gui-v2/composables/useViewData.ts +++ b/packages/nc-gui-v2/composables/useViewData.ts @@ -17,8 +17,9 @@ export function useViewData( where?: ComputedRef, ) { const data = ref[]>() - const formattedData = ref<{ row: Record; oldRow: Record; rowMeta?: any }[]>() + const formattedData = ref<{ row: Record; oldRow: Record; rowMeta?: any }[]>([]) const paginationData = ref({ page: 1, pageSize: 25 }) + const selectedRows = reactive([]) const { project } = useProject() const { $api } = useNuxtApp() @@ -101,5 +102,13 @@ export function useViewData( await loadData({ offset: (page - 1) * (paginationData.value.pageSize || 25), where: where?.value } as any) } - return { data, loadData, paginationData, formattedData, insertRow, updateRowProperty, changePage } + const addRow = () => { + formattedData.value.push({ + row: {}, + oldRow: {}, + rowMeta: { new: true }, + }) + } + + return { data, loadData, paginationData, formattedData, insertRow, updateRowProperty, changePage, addRow, selectedRows } }