From ae42bf5f14f75f7660ac6f3c46384bf607ea1edb Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 27 Sep 2022 12:18:45 +0800 Subject: [PATCH] fix(nc-gui): grouping field preset logic --- packages/nc-gui/components/dlg/ViewCreate.vue | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/nc-gui/components/dlg/ViewCreate.vue b/packages/nc-gui/components/dlg/ViewCreate.vue index b491cb0fad..f862954f8f 100644 --- a/packages/nc-gui/components/dlg/ViewCreate.vue +++ b/packages/nc-gui/components/dlg/ViewCreate.vue @@ -67,6 +67,8 @@ const form = reactive
({ grp_column_id: null, }) +const singleSelectFieldOptions = ref([]) + const viewNameRules = [ // name is required { required: true, message: `${t('labels.viewName')} ${t('general.required')}` }, @@ -111,6 +113,19 @@ function init() { form.copy_from_id = props.selectedViewId } + // preset the grouping field column + if (form.type === ViewTypes.KANBAN) { + singleSelectFieldOptions.value = fields.value + .filter((el) => el.uidt === UITypes.SingleSelect) + .map((field) => { + return { + value: field.id, + label: field.title, + } + }) + form.grp_column_id = singleSelectFieldOptions.value?.[0]?.value as string + } + nextTick(() => { const el = inputEl?.$el as HTMLInputElement @@ -159,22 +174,6 @@ async function onSubmit() { vModel.value = false } } - -const singleSelectFieldOptions = computed(() => { - return fields.value - .filter((el) => el.uidt === UITypes.SingleSelect) - .map((field) => { - return { - value: field.id, - label: field.title, - } - }) -}) - -if (form.type === ViewTypes.KANBAN) { - // preset the grouping field column - form.grp_column_id = singleSelectFieldOptions.value?.[0]?.value as string -}