From 1b606f99f849d9061b9bb9e6e379a0f74b0403b2 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 3 Feb 2023 16:43:14 +0530 Subject: [PATCH 1/2] fix(gui): save new row even if user set LTAR column first Signed-off-by: Pranav C --- packages/nc-gui/components/smartsheet/Grid.vue | 1 + packages/nc-gui/components/smartsheet/VirtualCell.vue | 4 +++- .../nc-gui/components/virtual-cell/components/ListItems.vue | 4 ++++ packages/nc-gui/context/index.ts | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 5a08a9a925..86fb089a36 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -867,6 +867,7 @@ const rowHeight = computed(() => { :row="row" :read-only="readOnly" @navigate="onNavigate" + @save="updateOrSaveRow(row, '', state)" /> () -const emit = defineEmits(['update:modelValue', 'navigate']) +const emit = defineEmits(['update:modelValue', 'navigate', 'save']) const column = toRef(props, 'column') const active = toRef(props, 'active', false) @@ -40,6 +41,7 @@ provide(ColumnInj, column) provide(ActiveCellInj, active) provide(RowInj, row) provide(CellValueInj, toRef(props, 'modelValue')) +provide(SaveRowInj, () => emit('save')) const isGrid = inject(IsGridInj, ref(false)) diff --git a/packages/nc-gui/components/virtual-cell/components/ListItems.vue b/packages/nc-gui/components/virtual-cell/components/ListItems.vue index 448b408b82..97ea11c4bf 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListItems.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListItems.vue @@ -16,6 +16,7 @@ import { useVModel, watch, } from '#imports' +import { SaveRowInj } from '~/context' const props = defineProps<{ modelValue: boolean }>() @@ -43,11 +44,14 @@ const { addLTARRef, isNew } = useSmartsheetRowStoreOrThrow() const isPublic = inject(IsPublicInj, ref(false)) +const saveRow = inject(SaveRowInj, () => {}) + const selectedRowIndex = ref(0) const linkRow = async (row: Record) => { if (isNew.value) { addLTARRef(row, column?.value as ColumnType) + saveRow() } else { await link(row) } diff --git a/packages/nc-gui/context/index.ts b/packages/nc-gui/context/index.ts index 1b7a53e790..f362ea0c57 100644 --- a/packages/nc-gui/context/index.ts +++ b/packages/nc-gui/context/index.ts @@ -33,3 +33,4 @@ export const CellUrlDisableOverlayInj: InjectionKey> = Symbol('cell export const DropZoneRef: InjectionKey> = Symbol('drop-zone-ref') export const ToggleDialogInj: InjectionKey = Symbol('toggle-dialog-injection') export const CellClickHookInj: InjectionKey | undefined> = Symbol('cell-click-injection') +export const SaveRowInj: InjectionKey<(() => void) | undefined> = Symbol('save-row-injection') From 11dc53a1a5991341e12fccbf98c6bf577a3f4096 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 3 Feb 2023 20:08:03 +0530 Subject: [PATCH 2/2] chore: suggested changes Signed-off-by: Pranav C --- packages/nc-gui/components/smartsheet/VirtualCell.vue | 2 +- .../nc-gui/components/virtual-cell/components/ListItems.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/VirtualCell.vue b/packages/nc-gui/components/smartsheet/VirtualCell.vue index 64aa2aca20..48322fb175 100644 --- a/packages/nc-gui/components/smartsheet/VirtualCell.vue +++ b/packages/nc-gui/components/smartsheet/VirtualCell.vue @@ -3,11 +3,11 @@ import type { ColumnType } from 'nocodb-sdk' import { ActiveCellInj, CellValueInj, - SaveRowInj, ColumnInj, IsFormInj, IsGridInj, RowInj, + SaveRowInj, inject, isBarcode, isBt, diff --git a/packages/nc-gui/components/virtual-cell/components/ListItems.vue b/packages/nc-gui/components/virtual-cell/components/ListItems.vue index 97ea11c4bf..2cd3ed1cab 100644 --- a/packages/nc-gui/components/virtual-cell/components/ListItems.vue +++ b/packages/nc-gui/components/virtual-cell/components/ListItems.vue @@ -6,6 +6,7 @@ import { ColumnInj, Empty, IsPublicInj, + SaveRowInj, computed, inject, isDrawerExist, @@ -16,7 +17,6 @@ import { useVModel, watch, } from '#imports' -import { SaveRowInj } from '~/context' const props = defineProps<{ modelValue: boolean }>()