From 770affe3022cd25b3998f008c7a98bb9e6fb0716 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 5 Dec 2022 14:27:01 +0800 Subject: [PATCH 1/2] fix(nc-gui): retrieve the correct column name based on the formula --- .../components/smartsheet/column/FormulaOptions.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue index 1ccb069b43..0ec293ef2f 100644 --- a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue @@ -2,8 +2,8 @@ import type { Ref } from 'vue' import type { ListItem as AntListItem } from 'ant-design-vue' import jsep from 'jsep' -import type { ColumnType } from 'nocodb-sdk' -import { UITypes, jsepCurlyHook } from 'nocodb-sdk' +import type { ColumnType, FormulaType } from 'nocodb-sdk' +import { UITypes, jsepCurlyHook, substituteColumnIdWithAliasInFormula } from 'nocodb-sdk' import { MetaInj, NcAutocompleteTree, @@ -604,7 +604,11 @@ function scrollToSelectedOption() { } // set default value -vModel.value.formula_raw = (column?.value?.colOptions as Record)?.formula_raw || '' +vModel.value.formula_raw = substituteColumnIdWithAliasInFormula( + (column.value?.colOptions as FormulaType)?.formula, + meta?.value?.columns as ColumnType[], + (column.value?.colOptions as any)?.formula_raw, +) // set additional validations setAdditionalValidations({ From 3d90d2d12ff32715884d1c7d36108db710b614a2 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 5 Dec 2022 15:34:52 +0800 Subject: [PATCH 2/2] fix(nc-gui): handle new formula case --- .../smartsheet/column/FormulaOptions.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue index 0ec293ef2f..c55bc8ec85 100644 --- a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue @@ -604,11 +604,16 @@ function scrollToSelectedOption() { } // set default value -vModel.value.formula_raw = substituteColumnIdWithAliasInFormula( - (column.value?.colOptions as FormulaType)?.formula, - meta?.value?.columns as ColumnType[], - (column.value?.colOptions as any)?.formula_raw, -) +if ((column.value?.colOptions as any)?.formula_raw) { + vModel.value.formula_raw = + substituteColumnIdWithAliasInFormula( + (column.value?.colOptions as FormulaType)?.formula, + meta?.value?.columns as ColumnType[], + (column.value?.colOptions as any)?.formula_raw, + ) || '' +} else { + vModel.value.formula_raw = '' +} // set additional validations setAdditionalValidations({