From c4f0573fb0111ae1f4740186617c164ece43cbc4 Mon Sep 17 00:00:00 2001 From: mertmit Date: Wed, 17 Aug 2022 17:35:56 +0300 Subject: [PATCH] fix(gui-v2): field ordering Signed-off-by: mertmit --- .../components/smartsheet-toolbar/FieldsMenu.vue | 14 +++++--------- packages/nc-gui-v2/composables/useViewColumns.ts | 6 +++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue b/packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue index 8212bb7ab7..47d2634586 100644 --- a/packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue +++ b/packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue @@ -50,14 +50,10 @@ const onMove = (event: { moved: { newIndex: number } }) => { if (fields.value.length < 2) return - if (fields.value.length - 1 === event.moved.newIndex) { - fields.value[event.moved.newIndex].order = (fields.value[event.moved.newIndex - 1].order || 1) + 1 - } else if (event.moved.newIndex === 0) { - fields.value[event.moved.newIndex].order = (fields.value[1].order || 1) / 2 - } else { - fields.value[event.moved.newIndex].order = - ((fields.value[event.moved.newIndex - 1].order || 1) + (fields.value[event.moved.newIndex + 1].order || 1)) / 2 - } + fields.value.map((field, index) => { + field.order = index + 1 + return field + }) saveOrUpdate(fields.value[event.moved.newIndex], event.moved.newIndex) @@ -88,7 +84,7 @@ const onMove = (event: { moved: { newIndex: number } }) => {
- +