From f9d01e996701a17a063ddd2f13c155de84a8ee61 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 18 Aug 2022 15:30:40 +0800 Subject: [PATCH] fix(gui-v2): disable drag for required fields --- packages/nc-gui-v2/components/smartsheet/Form.vue | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui-v2/components/smartsheet/Form.vue b/packages/nc-gui-v2/components/smartsheet/Form.vue index 2b587d8b79..2d52528b26 100644 --- a/packages/nc-gui-v2/components/smartsheet/Form.vue +++ b/packages/nc-gui-v2/components/smartsheet/Form.vue @@ -144,8 +144,19 @@ function isDbRequired(column: Record) { return isRequired } +function onMoveCallback(event: any) { + if (shouldSkipColumn(event.draggedContext.element)) { + return false + } +} + function onMove(event: any) { const { newIndex, element, oldIndex } = event.added || event.moved || event.removed + console.log(event) + if (shouldSkipColumn(element)) { + console.log('SKIPPED') + return + } if (event.added) { element.show = true @@ -199,7 +210,7 @@ async function addAllColumns() { } function shouldSkipColumn(col: Record) { - return isDbRequired(col) || !!col.required + return isDbRequired(col) || !!col.required || !!col.rqd } async function removeAllColumns() { @@ -508,6 +519,7 @@ onMounted(async () => { draggable=".item" group="form-inputs" class="h-100" + :move="onMoveCallback" @change="onMove($event)" @start="drag = true" @end="drag = false"