Browse Source

fix(gui-v2): disable drag for required fields

pull/3224/head
Wing-Kam Wong 2 years ago
parent
commit
f9d01e9967
  1. 14
      packages/nc-gui-v2/components/smartsheet/Form.vue

14
packages/nc-gui-v2/components/smartsheet/Form.vue

@ -144,8 +144,19 @@ function isDbRequired(column: Record<string, any>) {
return isRequired return isRequired
} }
function onMoveCallback(event: any) {
if (shouldSkipColumn(event.draggedContext.element)) {
return false
}
}
function onMove(event: any) { function onMove(event: any) {
const { newIndex, element, oldIndex } = event.added || event.moved || event.removed const { newIndex, element, oldIndex } = event.added || event.moved || event.removed
console.log(event)
if (shouldSkipColumn(element)) {
console.log('SKIPPED')
return
}
if (event.added) { if (event.added) {
element.show = true element.show = true
@ -199,7 +210,7 @@ async function addAllColumns() {
} }
function shouldSkipColumn(col: Record<string, any>) { function shouldSkipColumn(col: Record<string, any>) {
return isDbRequired(col) || !!col.required return isDbRequired(col) || !!col.required || !!col.rqd
} }
async function removeAllColumns() { async function removeAllColumns() {
@ -508,6 +519,7 @@ onMounted(async () => {
draggable=".item" draggable=".item"
group="form-inputs" group="form-inputs"
class="h-100" class="h-100"
:move="onMoveCallback"
@change="onMove($event)" @change="onMove($event)"
@start="drag = true" @start="drag = true"
@end="drag = false" @end="drag = false"

Loading…
Cancel
Save