From 46f19611b29c8d409d86e9ef22961b78de518628 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 20 Jan 2023 11:37:01 +0530 Subject: [PATCH] feat: on clear cell set rating and checkbox value 0 and false Signed-off-by: Pranav C --- .../nc-gui/components/smartsheet/Grid.vue | 349 +++++++++--------- 1 file changed, 181 insertions(+), 168 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 049ea163a8..09a9dd5b36 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -156,8 +156,8 @@ const getContainerScrollForElement = ( relativePos.right + (offset?.right || 0) > 0 ? container.scrollLeft + relativePos.right + (offset?.right || 0) : relativePos.left - (offset?.left || 0) < 0 - ? container.scrollLeft + relativePos.left - (offset?.left || 0) - : container.scrollLeft + ? container.scrollLeft + relativePos.left - (offset?.left || 0) + : container.scrollLeft /* * If the element is below the container, scroll down (positive) @@ -167,8 +167,8 @@ const getContainerScrollForElement = ( relativePos.bottom + (offset?.bottom || 0) > 0 ? container.scrollTop + relativePos.bottom + (offset?.bottom || 0) : relativePos.top - (offset?.top || 0) < 0 - ? container.scrollTop + relativePos.top - (offset?.top || 0) - : container.scrollTop + ? container.scrollTop + relativePos.top - (offset?.top || 0) + : container.scrollTop return scroll } @@ -418,7 +418,18 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate = return } - rowObj.row[columnObj.title] = null + // handle Checkbox and rating fields in a special way + switch (columnObj.uidt) { + case UITypes.Checkbox: + rowObj.row[columnObj.title] = false + break + case UITypes.Rating: + rowObj.row[columnObj.title] = 0 + break + default: + rowObj.row[columnObj.title] = null + break + } if (!skipUpdate) { // update/save cell value @@ -661,104 +672,105 @@ const closeAddColumnDropdown = () => { @contextmenu="showContextMenu" > - - -
- + +
+ + +
+ - -
- - + + + + - -
- -
+
+ +
- -
- - + +
+ + - - + + + + +
+ - + {{ $t('activity.addRow') }} -
- - + + + @@ -885,7 +897,8 @@ const closeAddColumnDropdown = () => { - +
{{ $t('general.copy') }}