|
|
@ -102,16 +102,16 @@ const sortOrder: Record<string, number> = { |
|
|
|
|
|
|
|
|
|
|
|
const suggestionsList = computed(() => { |
|
|
|
const suggestionsList = computed(() => { |
|
|
|
const unsupportedFnList = sqlUi.value.getUnsupportedFnList() |
|
|
|
const unsupportedFnList = sqlUi.value.getUnsupportedFnList() |
|
|
|
return [ |
|
|
|
return ( |
|
|
|
...availableFunctions |
|
|
|
[ |
|
|
|
.filter((fn: string) => !unsupportedFnList.includes(fn)) |
|
|
|
...availableFunctions.map((fn: string) => ({ |
|
|
|
.map((fn: string) => ({ |
|
|
|
|
|
|
|
text: `${fn}()`, |
|
|
|
text: `${fn}()`, |
|
|
|
type: 'function', |
|
|
|
type: 'function', |
|
|
|
description: formulas[fn].description, |
|
|
|
description: formulas[fn].description, |
|
|
|
syntax: formulas[fn].syntax, |
|
|
|
syntax: formulas[fn].syntax, |
|
|
|
examples: formulas[fn].examples, |
|
|
|
examples: formulas[fn].examples, |
|
|
|
docsUrl: formulas[fn].docsUrl, |
|
|
|
docsUrl: formulas[fn].docsUrl, |
|
|
|
|
|
|
|
unsupported: unsupportedFnList.includes(fn), |
|
|
|
})), |
|
|
|
})), |
|
|
|
...supportedColumns.value |
|
|
|
...supportedColumns.value |
|
|
|
.filter((c) => { |
|
|
|
.filter((c) => { |
|
|
@ -132,6 +132,17 @@ const suggestionsList = computed(() => { |
|
|
|
type: 'op', |
|
|
|
type: 'op', |
|
|
|
})), |
|
|
|
})), |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
// move unsupported functions to the end |
|
|
|
|
|
|
|
.sort((a: Record<string, any>, b: Record<string, any>) => { |
|
|
|
|
|
|
|
if (a.unsupported && !b.unsupported) { |
|
|
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!a.unsupported && b.unsupported) { |
|
|
|
|
|
|
|
return -1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// set default suggestion list |
|
|
|
// set default suggestion list |
|
|
@ -214,6 +225,7 @@ function handleInput() { |
|
|
|
function selectText() { |
|
|
|
function selectText() { |
|
|
|
if (suggestion.value && selected.value > -1 && selected.value < suggestionsList.value.length) { |
|
|
|
if (suggestion.value && selected.value > -1 && selected.value < suggestionsList.value.length) { |
|
|
|
if (selected.value < suggestedFormulas.value.length) { |
|
|
|
if (selected.value < suggestedFormulas.value.length) { |
|
|
|
|
|
|
|
if (suggestedFormulas.value[selected.value].unsupported) return |
|
|
|
appendText(suggestedFormulas.value[selected.value]) |
|
|
|
appendText(suggestedFormulas.value[selected.value]) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
appendText(variableList.value[selected.value + suggestedFormulas.value.length]) |
|
|
|
appendText(variableList.value[selected.value + suggestedFormulas.value.length]) |
|
|
@ -276,7 +288,7 @@ onMounted(() => { |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="formula-wrapper relative"> |
|
|
|
<div class="formula-wrapper relative"> |
|
|
|
<div |
|
|
|
<div |
|
|
|
v-if="suggestionPreviewed && suggestionPreviewed.type === 'function'" |
|
|
|
v-if="suggestionPreviewed && !suggestionPreviewed.unsupported && suggestionPreviewed.type === 'function'" |
|
|
|
class="absolute -left-91 w-84 top-0 bg-white z-10 pl-3 pt-3 border-1 shadow-md rounded-xl" |
|
|
|
class="absolute -left-91 w-84 top-0 bg-white z-10 pl-3 pt-3 border-1 shadow-md rounded-xl" |
|
|
|
> |
|
|
|
> |
|
|
|
<div class="pr-3"> |
|
|
|
<div class="pr-3"> |
|
|
@ -357,20 +369,22 @@ onMounted(() => { |
|
|
|
class="cursor-pointer !overflow-hidden hover:bg-gray-50" |
|
|
|
class="cursor-pointer !overflow-hidden hover:bg-gray-50" |
|
|
|
:class="{ |
|
|
|
:class="{ |
|
|
|
'!bg-gray-100': selected === index, |
|
|
|
'!bg-gray-100': selected === index, |
|
|
|
|
|
|
|
'cursor-not-allowed': item.unsupported, |
|
|
|
}" |
|
|
|
}" |
|
|
|
@click.prevent.stop="appendText(item)" |
|
|
|
@click.prevent.stop="!item.unsupported && appendText(item)" |
|
|
|
@mouseenter="suggestionPreviewed = item" |
|
|
|
@mouseenter="suggestionPreviewed = item" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-list-item-meta> |
|
|
|
<a-list-item-meta> |
|
|
|
<template #title> |
|
|
|
<template #title> |
|
|
|
<div class="flex items-center gap-x-1"> |
|
|
|
<div class="flex items-center gap-x-1" :class="{ 'text-gray-400': item.unsupported }"> |
|
|
|
<component :is="iconMap.function" v-if="item.type === 'function'" class="text-lg" /> |
|
|
|
<component :is="iconMap.function" v-if="item.type === 'function'" class="text-lg" /> |
|
|
|
|
|
|
|
|
|
|
|
<component :is="iconMap.calculator" v-if="item.type === 'op'" class="text-lg" /> |
|
|
|
<component :is="iconMap.calculator" 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" /> |
|
|
|
<span class="prose-sm text-gray-600">{{ item.text }}</span> |
|
|
|
<span class="prose-sm" :class="{ 'text-gray-600': !item.unsupported }">{{ item.text }}</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div v-if="item.unsupported" class="ml-5 text-gray-400 text-xs">{{ $t('msg.formulaNotSupported') }}</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</a-list-item-meta> |
|
|
|
</a-list-item-meta> |
|
|
|
</a-list-item> |
|
|
|
</a-list-item> |
|
|
|