From 8552ac4e7b37fc997dea078579f93c02f0d9e5eb Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Fri, 22 Dec 2023 16:03:40 +0000 Subject: [PATCH] fix: Formula revamp --- .../smartsheet/column/EditOrAdd.vue | 1 + .../smartsheet/column/FormulaOptions.vue | 155 ++++++++++++------ 2 files changed, 106 insertions(+), 50 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue b/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue index 5f6c190554..e8d74b1959 100644 --- a/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue +++ b/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue @@ -225,6 +225,7 @@ if (props.fromTableExplorer) { 'w-[400px]': !props.embedMode, '!w-146': isTextArea(formState) && formState.meta?.richMode, '!w-[600px]': formState.uidt === UITypes.Formula && !props.embedMode, + 'overflow-visible': formState.uidt === UITypes.Formula, '!w-[500px]': formState.uidt === UITypes.Attachment && !props.embedMode && !appInfo.ee, 'shadow-lg border-1 border-gray-200 shadow-gray-300 rounded-xl p-6': !embedMode, }" diff --git a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue index e52df87238..203a37a57b 100644 --- a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue @@ -55,6 +55,8 @@ const supportedColumns = computed( ) const { getMeta } = useMetas() +const suggestionPreviewed = ref | undefined>() + const validators = { formula_raw: [ { @@ -95,6 +97,8 @@ const sugListRef = ref() const sugOptionsRef = ref<(typeof AntListItem)[]>([]) +const variableListRef = ref<(typeof AntListItem)[]>([]) + const wordToComplete = ref('') const selected = ref(0) @@ -196,6 +200,13 @@ function handleInput() { suggestion.value = acTree.value .complete(wordToComplete.value) ?.sort((x: Record, y: Record) => sortOrder[x.type] - sortOrder[y.type]) + + if (suggestion.value.length > 0 && suggestion.value[0].type !== 'column') { + suggestionPreviewed.value = suggestion.value[0] + } else { + suggestionPreviewed.value = undefined + } + if (!isCurlyBracketBalanced()) { suggestion.value = suggestion.value.filter((v) => v.type === 'column') } @@ -256,7 +267,24 @@ onMounted(() => {