diff --git a/tailbone/templates/base.mako b/tailbone/templates/base.mako index f4935113..df4451c6 100644 --- a/tailbone/templates/base.mako +++ b/tailbone/templates/base.mako @@ -757,8 +757,27 @@ if (!this.globalSearchTerm.length) { return this.globalSearchData } + + let terms = [] + for (let term of this.globalSearchTerm.toLowerCase().split(' ')) { + term = term.trim() + if (term) { + terms.push(term) + } + } + if (!terms.length) { + return this.globalSearchData + } + + // all terms must match return this.globalSearchData.filter((option) => { - return option.label.toLowerCase().indexOf(this.globalSearchTerm.toLowerCase()) >= 0 + let label = option.label.toLowerCase() + for (let term of terms) { + if (label.indexOf(term) < 0) { + return false + } + } + return true }) },