From 7e8475e64db49e82d6880b66cffe805533b98fd7 Mon Sep 17 00:00:00 2001 From: "John R. Supplee" Date: Sun, 17 Jan 2021 21:04:05 +0200 Subject: [PATCH] Add link to search header for storing search --- client/components/main/globalSearch.jade | 1 + client/components/main/globalSearch.js | 6 ++++++ config/router.js | 7 ++++--- i18n/en.i18n.json | 3 ++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/client/components/main/globalSearch.jade b/client/components/main/globalSearch.jade index 0e3e801c4..961c5b436 100644 --- a/client/components/main/globalSearch.jade +++ b/client/components/main/globalSearch.jade @@ -27,6 +27,7 @@ template(name="globalSearch") else h1 = resultsHeading.get + a.fa.fa-link(title="{{_ 'link-to-search' }}" href="{{ getSearchHref }}") each card in results +resultCard(card) else diff --git a/client/components/main/globalSearch.js b/client/components/main/globalSearch.js index 7a6f73d6f..72f8d4380 100644 --- a/client/components/main/globalSearch.js +++ b/client/components/main/globalSearch.js @@ -41,6 +41,7 @@ BlazeComponent.extendComponent({ this.hasQueryErrors = new ReactiveVar(false); this.query = new ReactiveVar(''); this.resultsHeading = new ReactiveVar(''); + this.searchLink = new ReactiveVar(null); this.queryParams = null; this.parsingErrors = []; this.resultsCount = 0; @@ -258,6 +259,11 @@ BlazeComponent.extendComponent({ }); }, + getSearchHref() { + const baseUrl = window.location.href.replace(/([?#].*$|\s*$)/, ''); + return `${baseUrl}?q=${encodeURIComponent(this.query.get())}`; + }, + searchInstructions() { tags = { operator_board: TAPi18n.__('operator-board'), diff --git a/config/router.js b/config/router.js index faaa2aecb..d41097c5f 100644 --- a/config/router.js +++ b/config/router.js @@ -160,9 +160,10 @@ FlowRouter.route('/global-search', { Utils.manageMatomo(); DocHead.setTitle(TAPi18n.__('globalSearch-title')); - // eslint-disable-next-line no-console - console.log('URL Params:', FlowRouter.getQueryParam('q')); - Session.set('globalQuery', decodeURI(FlowRouter.getQueryParam('q'))); + Session.set( + 'globalQuery', + decodeURIComponent(FlowRouter.getQueryParam('q')), + ); BlazeLayout.render('defaultLayout', { headerBar: 'globalSearchHeaderBar', content: 'globalSearch', diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 90392f1eb..b1859ff2b 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -908,5 +908,6 @@ "globalSearch-instructions-notes-2": "Similar operators are *OR*ed together. Cards that match any of the conditions will be returned.\n`__operator_list__:Available __operator_list__:Blocked` would return cards contained in any list named *Blocked* or *Available*.", "globalSearch-instructions-notes-3": "Differing operators are *AND*ed together. Only cards that match all of the differing operators are returned.\n`__operator_list__:Available __operator_label__:red` returns only cards in the list *Available* with a *red* label.", "globalSearch-instructions-notes-4": "Text searches are case insensitive.", - "globalSearch-instructions-notes-5": "Currently archived cards are not searched." + "globalSearch-instructions-notes-5": "Currently archived cards are not searched.", + "link-to-search": "Link to this search" }