Browse Source

enhancement: show column list only when column is the only option

pull/2160/head
Wing-Kam Wong 3 years ago
parent
commit
5dc423a924
  1. 12
      packages/nc-gui/components/project/spreadsheet/components/editColumn/FormulaOptions.vue

12
packages/nc-gui/components/project/spreadsheet/components/editColumn/FormulaOptions.vue

@ -568,9 +568,15 @@ export default {
this.selected = 0 this.selected = 0
this.suggestion = null this.suggestion = null
const query = getWordUntilCaret(this.$refs.input.$el.querySelector('input')) const query = getWordUntilCaret(this.$refs.input.$el.querySelector('input'))
const parts = query.split(/\W+/) // count number of opening curly brackets and closing curly brackets
this.wordToComplete = parts.pop() const cntCurlyBrackets = (this.$refs.input.$el.querySelector('input').value.match(/\{|}/g) || []).reduce((acc, cur) => (acc[cur] = (acc[cur] || 0) + 1, acc), {})
this.suggestion = this.acTree.complete(this.wordToComplete)?.sort((x, y) => this.sortOrder[x.type] - this.sortOrder[y.type]) if (Math.abs((cntCurlyBrackets['{'] || 0) - (cntCurlyBrackets['}'] || 0))) {
this.suggestion = this.suggestionsList.filter(v => v.type === 'column')
} else {
const parts = query.split(/\W+/)
this.wordToComplete = parts.pop()
this.suggestion = this.acTree.complete(this.wordToComplete)?.sort((x, y) => this.sortOrder[x.type] - this.sortOrder[y.type])
}
this.autocomplete = !!this.suggestion.length this.autocomplete = !!this.suggestion.length
}, },
selectText() { selectText() {

Loading…
Cancel
Save