From 6057ee687e65016db488505346162ce5bebfbcf2 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 4 Aug 2022 01:40:49 +0530 Subject: [PATCH] feat(gui-v2): make edit enabled toggle possible Signed-off-by: Pranav C --- packages/nc-gui-v2/components/cell/Text.vue | 2 +- .../nc-gui-v2/components/cell/TextArea.vue | 1 + .../nc-gui-v2/components/smartsheet/Cell.vue | 14 +- .../nc-gui-v2/components/smartsheet/Grid.vue | 192 +++++++++--------- .../components/smartsheet/VirtualCell.vue | 9 +- packages/nc-gui-v2/context/index.ts | 2 +- 6 files changed, 117 insertions(+), 103 deletions(-) diff --git a/packages/nc-gui-v2/components/cell/Text.vue b/packages/nc-gui-v2/components/cell/Text.vue index 2b530448d3..ccd0bca0c7 100644 --- a/packages/nc-gui-v2/components/cell/Text.vue +++ b/packages/nc-gui-v2/components/cell/Text.vue @@ -18,6 +18,6 @@ const focus = (el: HTMLInputElement) => el?.focus() diff --git a/packages/nc-gui-v2/components/cell/TextArea.vue b/packages/nc-gui-v2/components/cell/TextArea.vue index a6d50e9efc..c27933fe56 100644 --- a/packages/nc-gui-v2/components/cell/TextArea.vue +++ b/packages/nc-gui-v2/components/cell/TextArea.vue @@ -24,6 +24,7 @@ const focus = (el: HTMLTextAreaElement) => el?.focus() v-model="vModel" rows="4" class="h-full w-full min-h-[60px] outline-none" + @blur="editEnabled = false" @keydown.alt.enter.stop @keydown.shift.enter.stop /> diff --git a/packages/nc-gui-v2/components/smartsheet/Cell.vue b/packages/nc-gui-v2/components/smartsheet/Cell.vue index b103ca1842..8fb5d05bf8 100644 --- a/packages/nc-gui-v2/components/smartsheet/Cell.vue +++ b/packages/nc-gui-v2/components/smartsheet/Cell.vue @@ -18,11 +18,21 @@ interface Emits { const { column, ...props } = defineProps() -const emit = defineEmits(['update:modelValue', 'save', 'navigate']) +const emit = defineEmits(['update:modelValue', 'save', 'navigate', 'cancel']) provide(ColumnInj, column) -provide(EditModeInj, toRef(props, 'editEnabled')) +provide( + EditModeInj, + computed({ + get() { + return props?.editEnabled + }, + set() { + return emit('cancel') + }, + }), +) 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 ecff0198e1..ad60b6d0fd 100644 --- a/packages/nc-gui-v2/components/smartsheet/Grid.vue +++ b/packages/nc-gui-v2/components/smartsheet/Grid.vue @@ -208,115 +208,117 @@ const onNavigate = (dir: NavigateDir) => { - - + - - - - + + + + + - - + - - + + + + - - + - + + + + +
-
-
#
-
- - +
+
+
#
+
+ + +
- -
- - - - -
- -
- -
-
+ + + + +
+ +
+ +
+
-
-
{{ rowIndex + 1 }}
-
- - -
+
+
{{ rowIndex + 1 }}
+
+ + +
- -
-
- + :data-col="columnObj.id" + @click="selectCell(rowIndex, colIndex)" + @dblclick="editEnabled = true" + @contextmenu="contextMenuTarget = { row: rowIndex, col: colIndex }" + > +
+ - -
-
- -
- - +
+ +
+ + {{ $t('activity.addRow') }} -
- -
-