From 2b046b8ceda7b132a06d08f1f15b378ede67e990 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Fri, 22 Dec 2023 16:03:41 +0000 Subject: [PATCH] fix: Fixed issue with formula selection through enter and removed hint for {} variable --- .../smartsheet/column/FormulaOptions.vue | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue index b80e41756e..07863e7567 100644 --- a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue @@ -145,6 +145,13 @@ const suggestionsList = computed(() => { // set default suggestion list const suggestion: Ref[]> = ref(suggestionsList.value) +const suggestedFormulas = computed(() => { + return suggestion.value.filter((s) => s && s.type !== 'column') +}) +const variableList = computed(() => { + return suggestion.value.filter((s) => s && s.type === 'column') +}) + const acTree = computed(() => { const ref = new NcAutocompleteTree() for (const sug of suggestionsList.value) { @@ -214,9 +221,15 @@ function handleInput() { } function selectText() { - if (suggestion.value && selected.value > -1 && selected.value < suggestion.value.length) { - appendText(suggestion.value[selected.value]) + if (suggestion.value && selected.value > -1 && selected.value < suggestionsList.value.length) { + if (selected.value < suggestedFormulas.value.length) { + appendText(suggestedFormulas.value[selected.value]) + } else { + appendText(variableList.value[selected.value + suggestedFormulas.value.length]) + } } + + selected.value = 0 } function suggestionListUp() { @@ -305,7 +318,7 @@ onMounted(() => { { /> -
- {{ - // As using {} in translation will be treated as placeholder, and this translation contain {} as part of th text - $t('msg.formula.hintStart', { - placeholder1: '{}', - placeholder2: '{column_name}', - }) - }} - - {{ $t('msg.formula.hintEnd') }} - -
-