|
|
@ -96,6 +96,7 @@ const suggestionsList = computed(() => { |
|
|
|
text: c.title, |
|
|
|
text: c.title, |
|
|
|
type: 'column', |
|
|
|
type: 'column', |
|
|
|
icon: getUIDTIcon(c.uidt), |
|
|
|
icon: getUIDTIcon(c.uidt), |
|
|
|
|
|
|
|
uidt: c.uidt, |
|
|
|
})), |
|
|
|
})), |
|
|
|
...availableBinOps.map((op: string) => ({ |
|
|
|
...availableBinOps.map((op: string) => ({ |
|
|
|
text: op, |
|
|
|
text: op, |
|
|
@ -254,7 +255,7 @@ function validateAgainstMeta(parsedTree: any, errors = new Set(), typeErrors = n |
|
|
|
|
|
|
|
|
|
|
|
if (targetFormulaCol && column?.value.id) { |
|
|
|
if (targetFormulaCol && column?.value.id) { |
|
|
|
formulaPaths.push({ |
|
|
|
formulaPaths.push({ |
|
|
|
[column.value.id]: [targetFormulaCol.id], |
|
|
|
[column?.value?.id as string]: [targetFormulaCol.id], |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
const vertices = formulaPaths.length |
|
|
|
const vertices = formulaPaths.length |
|
|
@ -518,6 +519,7 @@ function appendText(item: Record<string, any>) { |
|
|
|
formState.value.formula_raw = insertAtCursor(formulaRef.value.$el, text, len) |
|
|
|
formState.value.formula_raw = insertAtCursor(formulaRef.value.$el, text, len) |
|
|
|
} |
|
|
|
} |
|
|
|
autocomplete.value = false |
|
|
|
autocomplete.value = false |
|
|
|
|
|
|
|
wordToComplete.value = '' |
|
|
|
if (item.type === 'function' || item.type === 'op') { |
|
|
|
if (item.type === 'function' || item.type === 'op') { |
|
|
|
// if function / operator is chosen, display columns only |
|
|
|
// if function / operator is chosen, display columns only |
|
|
|
suggestion.value = suggestionsList.value.filter((f) => f.type === 'column') |
|
|
|
suggestion.value = suggestionsList.value.filter((f) => f.type === 'column') |
|
|
@ -612,7 +614,7 @@ onMounted(() => { |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="formula-wrapper"> |
|
|
|
<div class="formula-wrapper"> |
|
|
|
<a-form-item v-bind="validateInfos.formula_raw" label="Formula"> |
|
|
|
<a-form-item v-bind="validateInfos.formula_raw" label="Formula"> |
|
|
|
<a-input |
|
|
|
<a-textarea |
|
|
|
ref="formulaRef" |
|
|
|
ref="formulaRef" |
|
|
|
v-model:value="formState.formula_raw" |
|
|
|
v-model:value="formState.formula_raw" |
|
|
|
class="mb-2" |
|
|
|
class="mb-2" |
|
|
@ -622,21 +624,13 @@ onMounted(() => { |
|
|
|
@change="handleInputDeb" |
|
|
|
@change="handleInputDeb" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
<div class="text-gray-600 mt-2 prose-sm"> |
|
|
|
<div class="text-gray-600 mt-2 mb-4 prose-sm"> |
|
|
|
Hint: Use {} to reference columns, e.g: {column_name}. For more, please check out |
|
|
|
Hint: Use {} to reference columns, e.g: {column_name}. For more, please check out |
|
|
|
<a class="prose-sm" href="https://docs.nocodb.com/setup-and-usages/formulas#available-formula-features" target="_blank" |
|
|
|
<a class="prose-sm" href="https://docs.nocodb.com/setup-and-usages/formulas#available-formula-features" target="_blank" |
|
|
|
>Formulas</a |
|
|
|
>Formulas</a |
|
|
|
>. |
|
|
|
>. |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<a-drawer |
|
|
|
<div class="h-[250px] overflow-auto scrollbar-thin-primary"> |
|
|
|
v-model:visible="formulaSuggestionDrawer" |
|
|
|
|
|
|
|
:closable="false" |
|
|
|
|
|
|
|
:mask="false" |
|
|
|
|
|
|
|
:mask-closable="false" |
|
|
|
|
|
|
|
placement="right" |
|
|
|
|
|
|
|
width="500px" |
|
|
|
|
|
|
|
class="h-full overflow-auto" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<a-list ref="sugListRef" :data-source="suggestion" :locale="{ emptyText: 'No suggested formula was found' }"> |
|
|
|
<a-list ref="sugListRef" :data-source="suggestion" :locale="{ emptyText: 'No suggested formula was found' }"> |
|
|
|
<template #renderItem="{ item, index }"> |
|
|
|
<template #renderItem="{ item, index }"> |
|
|
|
<a-list-item |
|
|
|
<a-list-item |
|
|
@ -649,7 +643,13 @@ onMounted(() => { |
|
|
|
@click.prevent.stop="appendText(item)" |
|
|
|
@click.prevent.stop="appendText(item)" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-list-item-meta> |
|
|
|
<a-list-item-meta> |
|
|
|
<template v-if="item.type === 'function'" #description> |
|
|
|
<template #title> |
|
|
|
|
|
|
|
<div class="flex"> |
|
|
|
|
|
|
|
<a-col :span="6"> |
|
|
|
|
|
|
|
<span class="prose-sm text-gray-600">{{ item.text }}</span> |
|
|
|
|
|
|
|
</a-col> |
|
|
|
|
|
|
|
<a-col :span="18"> |
|
|
|
|
|
|
|
<div v-if="item.type === 'function'" class="text-xs text-gray-500"> |
|
|
|
{{ item.description }} <br /><br /> |
|
|
|
{{ item.description }} <br /><br /> |
|
|
|
Syntax: <br /> |
|
|
|
Syntax: <br /> |
|
|
|
{{ item.syntax }} <br /><br /> |
|
|
|
{{ item.syntax }} <br /><br /> |
|
|
@ -657,31 +657,23 @@ onMounted(() => { |
|
|
|
<div v-for="(example, idx) of item.examples" :key="idx"> |
|
|
|
<div v-for="(example, idx) of item.examples" :key="idx"> |
|
|
|
<div>({{ idx + 1 }}): {{ example }}</div> |
|
|
|
<div>({{ idx + 1 }}): {{ example }}</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #title> |
|
|
|
|
|
|
|
<div class="flex"> |
|
|
|
|
|
|
|
<div class="flex-1"> |
|
|
|
|
|
|
|
{{ item.text }} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div v-if="item.type === 'column'" class="float-right mr-5 -mt-2"> |
|
|
|
<div class=""> |
|
|
|
<a-badge-ribbon :text="item.uidt" color="gray"/> |
|
|
|
{{ getFormulaTypeName(item.type) }} |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</a-col> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<template #avatar> |
|
|
|
<template #avatar> |
|
|
|
<MdiFunction v-if="item.type === 'function'" class="text-lg" /> |
|
|
|
<mdi-function v-if="item.type === 'function'" class="text-lg" /> |
|
|
|
|
|
|
|
<mdi-calculator v-if="item.type === 'op'" class="text-lg" /> |
|
|
|
<MdiCalculator v-if="item.type === 'op'" class="text-lg" /> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<component :is="item.icon" v-if="item.type === 'column'" class="text-lg" /> |
|
|
|
<component :is="item.icon" v-if="item.type === 'column'" class="text-lg" /> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</a-list-item-meta> |
|
|
|
</a-list-item-meta> |
|
|
|
</a-list-item> |
|
|
|
</a-list-item> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</a-list> |
|
|
|
</a-list> |
|
|
|
</a-drawer> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|