|
|
@ -145,6 +145,13 @@ const suggestionsList = computed(() => { |
|
|
|
// set default suggestion list |
|
|
|
// set default suggestion list |
|
|
|
const suggestion: Ref<Record<string, any>[]> = ref(suggestionsList.value) |
|
|
|
const suggestion: Ref<Record<string, any>[]> = 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 acTree = computed(() => { |
|
|
|
const ref = new NcAutocompleteTree() |
|
|
|
const ref = new NcAutocompleteTree() |
|
|
|
for (const sug of suggestionsList.value) { |
|
|
|
for (const sug of suggestionsList.value) { |
|
|
@ -214,11 +221,17 @@ function handleInput() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function selectText() { |
|
|
|
function selectText() { |
|
|
|
if (suggestion.value && selected.value > -1 && selected.value < suggestion.value.length) { |
|
|
|
if (suggestion.value && selected.value > -1 && selected.value < suggestionsList.value.length) { |
|
|
|
appendText(suggestion.value[selected.value]) |
|
|
|
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() { |
|
|
|
function suggestionListUp() { |
|
|
|
if (suggestion.value) { |
|
|
|
if (suggestion.value) { |
|
|
|
selected.value = --selected.value > -1 ? selected.value : suggestion.value.length - 1 |
|
|
|
selected.value = --selected.value > -1 ? selected.value : suggestion.value.length - 1 |
|
|
@ -305,7 +318,7 @@ onMounted(() => { |
|
|
|
<a-textarea |
|
|
|
<a-textarea |
|
|
|
ref="formulaRef" |
|
|
|
ref="formulaRef" |
|
|
|
v-model:value="vModel.formula_raw" |
|
|
|
v-model:value="vModel.formula_raw" |
|
|
|
class="mb-2 nc-formula-input" |
|
|
|
class="!mb-4 nc-formula-input !rounded-md" |
|
|
|
@keydown.down.prevent="suggestionListDown" |
|
|
|
@keydown.down.prevent="suggestionListDown" |
|
|
|
@keydown.up.prevent="suggestionListUp" |
|
|
|
@keydown.up.prevent="suggestionListUp" |
|
|
|
@keydown.enter.prevent="selectText" |
|
|
|
@keydown.enter.prevent="selectText" |
|
|
@ -313,24 +326,6 @@ onMounted(() => { |
|
|
|
/> |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<div class="text-gray-600 mt-2 mb-4 prose-sm"> |
|
|
|
|
|
|
|
{{ |
|
|
|
|
|
|
|
// 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}', |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
<a |
|
|
|
|
|
|
|
class="prose-sm" |
|
|
|
|
|
|
|
href="https://docs.nocodb.com/setup-and-usages/formulas#available-formula-features" |
|
|
|
|
|
|
|
target="_blank" |
|
|
|
|
|
|
|
rel="noopener" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{{ $t('msg.formula.hintEnd') }} |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div ref="sugListRef" class="h-[250px] overflow-auto nc-scrollbar-md"> |
|
|
|
<div ref="sugListRef" class="h-[250px] overflow-auto nc-scrollbar-md"> |
|
|
|
<template v-if="suggestedFormulas.length > 0"> |
|
|
|
<template v-if="suggestedFormulas.length > 0"> |
|
|
|
<div class="rounded-t-lg border-1 bg-gray-50 px-3 py-1 uppercase text-gray-600 text-xs">Formulas</div> |
|
|
|
<div class="rounded-t-lg border-1 bg-gray-50 px-3 py-1 uppercase text-gray-600 text-xs">Formulas</div> |
|
|
|