|
|
@ -1,16 +1,5 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="formula-wrapper"> |
|
|
|
<div class="formula-wrapper"> |
|
|
|
<v-menu |
|
|
|
|
|
|
|
v-model="autocomplete" |
|
|
|
|
|
|
|
bottom |
|
|
|
|
|
|
|
offset-y |
|
|
|
|
|
|
|
nudge-bottom="-25px" |
|
|
|
|
|
|
|
allow-overflow |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<template #activator="_args"> |
|
|
|
|
|
|
|
<!-- todo: autocomplete based on available functions and metadata --> |
|
|
|
|
|
|
|
<!-- <v-tooltip color="info" right>--> |
|
|
|
|
|
|
|
<!-- <template #activator="{on}">--> |
|
|
|
|
|
|
|
<v-text-field |
|
|
|
<v-text-field |
|
|
|
ref="input" |
|
|
|
ref="input" |
|
|
|
v-model="formula.value" |
|
|
|
v-model="formula.value" |
|
|
@ -19,8 +8,6 @@ |
|
|
|
class="caption" |
|
|
|
class="caption" |
|
|
|
hide-details="auto" |
|
|
|
hide-details="auto" |
|
|
|
label="Formula" |
|
|
|
label="Formula" |
|
|
|
persistent-hint |
|
|
|
|
|
|
|
hint="Hint: If you reference columns, use '$' to wrap the column name, e.g: $column_name$." |
|
|
|
|
|
|
|
:rules="[v => !!v || 'Required', v => parseAndValidateFormula(v)]" |
|
|
|
:rules="[v => !!v || 'Required', v => parseAndValidateFormula(v)]" |
|
|
|
autocomplete="off" |
|
|
|
autocomplete="off" |
|
|
|
@input="handleInputDeb" |
|
|
|
@input="handleInputDeb" |
|
|
@ -28,8 +15,14 @@ |
|
|
|
@keydown.up.prevent="suggestionListUp" |
|
|
|
@keydown.up.prevent="suggestionListUp" |
|
|
|
@keydown.enter.prevent="selectText" |
|
|
|
@keydown.enter.prevent="selectText" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</template> |
|
|
|
<div class="hint"> |
|
|
|
<v-list v-if="suggestion" ref="sugList" dense max-height="50vh" style="overflow: auto"> |
|
|
|
Hint: Use $ to reference columns, e.g: $column_name$. For more, please check out |
|
|
|
|
|
|
|
<a href="https://docs.nocodb.com/setup-and-usages/formulas#available-formula-features" target="_blank">Formulas</a>. |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<v-card v-if="suggestion" class="formula-suggestion"> |
|
|
|
|
|
|
|
<v-card-text>Suggestions</v-card-text> |
|
|
|
|
|
|
|
<v-divider /> |
|
|
|
|
|
|
|
<v-list ref="sugList" dense max-height="50vh" style="overflow: auto"> |
|
|
|
<v-list-item-group |
|
|
|
<v-list-item-group |
|
|
|
v-model="selected" |
|
|
|
v-model="selected" |
|
|
|
color="primary" |
|
|
|
color="primary" |
|
|
@ -42,16 +35,59 @@ |
|
|
|
selectable |
|
|
|
selectable |
|
|
|
@mousedown.prevent="appendText(it)" |
|
|
|
@mousedown.prevent="appendText(it)" |
|
|
|
> |
|
|
|
> |
|
|
|
|
|
|
|
<!-- Function --> |
|
|
|
|
|
|
|
<template v-if="it.type ==='function'"> |
|
|
|
|
|
|
|
<v-list-item-content> |
|
|
|
<span |
|
|
|
<span |
|
|
|
class="caption" |
|
|
|
class="caption primary--text text--lighten-2 font-weight-bold" |
|
|
|
:class="{ |
|
|
|
> |
|
|
|
'primary--text text--lighten-2 font-weight-bold': it.type ==='function' |
|
|
|
{{ it.text }}(...) |
|
|
|
}" |
|
|
|
</span> |
|
|
|
>{{ it.text }}<span v-if="it.type ==='function'">(...)</span></span> |
|
|
|
</v-list-item-content> |
|
|
|
|
|
|
|
<v-list-item-action> |
|
|
|
|
|
|
|
<span class="caption"> |
|
|
|
|
|
|
|
Function |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</v-list-item-action> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Column --> |
|
|
|
|
|
|
|
<template v-if="it.type ==='column'"> |
|
|
|
|
|
|
|
<v-list-item-content> |
|
|
|
|
|
|
|
<span |
|
|
|
|
|
|
|
class="caption text--darken-3 font-weight-bold" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{{ it.text }} |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</v-list-item-content> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<v-list-item-action> |
|
|
|
|
|
|
|
<span class="caption"> |
|
|
|
|
|
|
|
Column |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</v-list-item-action> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Operator --> |
|
|
|
|
|
|
|
<template v-if="it.type ==='op'"> |
|
|
|
|
|
|
|
<v-list-item-content> |
|
|
|
|
|
|
|
<span |
|
|
|
|
|
|
|
class="caption indigo--text text--darken-3 font-weight-bold" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{{ it.text }} |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</v-list-item-content> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<v-list-item-action> |
|
|
|
|
|
|
|
<span class="caption"> |
|
|
|
|
|
|
|
Operator |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</v-list-item-action> |
|
|
|
|
|
|
|
</template> |
|
|
|
</v-list-item> |
|
|
|
</v-list-item> |
|
|
|
</v-list-item-group> |
|
|
|
</v-list-item-group> |
|
|
|
</v-list> |
|
|
|
</v-list> |
|
|
|
</v-menu> |
|
|
|
</v-card> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
@ -87,7 +123,7 @@ export default { |
|
|
|
type: 'function' |
|
|
|
type: 'function' |
|
|
|
})), |
|
|
|
})), |
|
|
|
...this.meta.columns.filter(c => !this.column || this.column.id !== c.id).map(c => ({ |
|
|
|
...this.meta.columns.filter(c => !this.column || this.column.id !== c.id).map(c => ({ |
|
|
|
text: c.title, |
|
|
|
text: '$' + c.title + '$', |
|
|
|
type: 'column', |
|
|
|
type: 'column', |
|
|
|
c |
|
|
|
c |
|
|
|
})), |
|
|
|
})), |
|
|
@ -266,4 +302,17 @@ export default { |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
|
<style scoped lang="scss"> |
|
|
|
|
|
|
|
::v-deep { |
|
|
|
|
|
|
|
.formula-suggestion .v-card__text { |
|
|
|
|
|
|
|
font-size: 0.75rem; |
|
|
|
|
|
|
|
padding: 8px; |
|
|
|
|
|
|
|
text-align: center; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.hint { |
|
|
|
|
|
|
|
font-size: 0.75rem; |
|
|
|
|
|
|
|
line-height: normal; |
|
|
|
|
|
|
|
padding: 10px 5px; |
|
|
|
|
|
|
|
} |
|
|
|
</style> |
|
|
|
</style> |
|
|
|