From 1b606f99f849d9061b9bb9e6e379a0f74b0403b2 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 3 Feb 2023 16:43:14 +0530 Subject: [PATCH] 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')