From 9e9053d212ccbe00cde1fd14d9d13c79d8e85635 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 4 Aug 2022 11:56:32 +0530 Subject: [PATCH] refactor(gui-v2): replace with use Signed-off-by: Pranav C --- packages/nc-gui-v2/components/smartsheet/Cell.vue | 14 ++------------ packages/nc-gui-v2/components/smartsheet/Grid.vue | 1 + 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet/Cell.vue b/packages/nc-gui-v2/components/smartsheet/Cell.vue index 8fb5d05bf8..bc725b74fa 100644 --- a/packages/nc-gui-v2/components/smartsheet/Cell.vue +++ b/packages/nc-gui-v2/components/smartsheet/Cell.vue @@ -18,21 +18,11 @@ interface Emits { const { column, ...props } = defineProps() -const emit = defineEmits(['update:modelValue', 'save', 'navigate', 'cancel']) +const emit = defineEmits(['update:modelValue', 'save', 'navigate', 'update:editEnabled']) provide(ColumnInj, column) -provide( - EditModeInj, - computed({ - get() { - return props?.editEnabled - }, - set() { - return emit('cancel') - }, - }), -) +provide(EditModeInj, useVModel(props, 'editEnabled', emit)) let changed = $ref(false) const syncValue = useDebounceFn(function () { diff --git a/packages/nc-gui-v2/components/smartsheet/Grid.vue b/packages/nc-gui-v2/components/smartsheet/Grid.vue index ad60b6d0fd..528ebcba5c 100644 --- a/packages/nc-gui-v2/components/smartsheet/Grid.vue +++ b/packages/nc-gui-v2/components/smartsheet/Grid.vue @@ -286,6 +286,7 @@ const onNavigate = (dir: NavigateDir) => { v-model="row.row[columnObj.title]" :column="columnObj" :edit-enabled="editEnabled && selected.col === colIndex && selected.row === rowIndex" + @update:edit-enabled="editEnabled = false" @save="updateOrSaveRow(row, columnObj.title)" @navigate="onNavigate" @cancel="editEnabled = false"