diff --git a/client/components/main/globalSearch.jade b/client/components/main/globalSearch.jade index ba4ecc892..63bf3b170 100644 --- a/client/components/main/globalSearch.jade +++ b/client/components/main/globalSearch.jade @@ -12,33 +12,42 @@ template(name="globalSearch") .wrapper form.js-search-query-form input(type="text" name="searchQuery" placeholder="{{_ 'search-example'}}" autofocus dir="auto") - if searching.get - +spinner - else if hasResults.get - .global-search-dueat-list-wrapper - h1 Results - each card in results - .global-search-card-wrapper - a.minicard-wrapper.card-title(href=card.absoluteUrl) - +minicard(card) - ul.global-search-context-list - li.global-search-context(title="{{_ 'board'}}") - +viewer - = card.getBoard.title - li.global-search-context.global-search-context-separator - = ' ' - | {{_ 'context-separator'}} - = ' ' - li.global-search-context(title="{{_ 'swimlane'}}") - +viewer - = card.getSwimlane.title - li.global-search-context - = ' ' - | {{_ 'context-separator'}} - = ' ' - li.global-search-context(title="{{_ 'list'}}") - +viewer - = card.getList.title + if searching.get + +spinner + else if hasResults.get + .global-search-dueat-list-wrapper + h1 Results + each card in results + .global-search-card-wrapper + a.minicard-wrapper.card-title(href=card.absoluteUrl) + +minicard(card) + //= card.title + ul.global-search-context-list + li.global-search-context(title="{{_ 'board'}}") + +viewer + = card.getBoard.title + li.global-search-context.global-search-context-separator + = ' ' + | {{_ 'context-separator'}} + = ' ' + li.global-search-context(title="{{_ 'swimlane'}}") + +viewer + = card.getSwimlane.title + li.global-search-context + = ' ' + | {{_ 'context-separator'}} + = ' ' + li.global-search-context(title="{{_ 'list'}}") + +viewer + = card.getList.title + else + h2 Search Operators + +viewer + = '* `@`username\n' + = '* `#`label\n' + = '* `board:` or `board:`""\n' + = '* `swimlane:` or `swimlane:`""\n' + = '* `list:` or `list:`""\n' template(name="globalSearchViewChangePopup") ul.pop-over-list diff --git a/client/components/main/globalSearch.js b/client/components/main/globalSearch.js index d2960afef..343e70801 100644 --- a/client/components/main/globalSearch.js +++ b/client/components/main/globalSearch.js @@ -40,6 +40,7 @@ BlazeComponent.extendComponent({ this.searching = new ReactiveVar(false); this.hasResults = new ReactiveVar(false); this.query = new ReactiveVar(''); + this.queryParams = null; // this.autorun(() => { // const handle = subManager.subscribe('globalSearch'); @@ -53,7 +54,10 @@ BlazeComponent.extendComponent({ }, results() { - return Cards.find(); + if (this.queryParams) { + return Cards.globalSearch(this.queryParams); + } + return []; }, events() { @@ -63,6 +67,12 @@ BlazeComponent.extendComponent({ evt.preventDefault(); this.query.set(evt.target.searchQuery.value); + if (!this.query.get()) { + this.searching.set(false); + this.hasResults.set(false); + return; + } + this.searching.set(true); this.hasResults.set(false); @@ -70,8 +80,8 @@ BlazeComponent.extendComponent({ // eslint-disable-next-line no-console console.log('query:', query); - const reUser = /^@(?\w+)(\s+|$)/; - const reLabel = /^#(?