浏览代码

Add link to search header for storing search

John R. Supplee 4 年之前
父节点
当前提交
7e8475e64d
共有 4 个文件被更改,包括 13 次插入4 次删除
  1. 1 0
      client/components/main/globalSearch.jade
  2. 6 0
      client/components/main/globalSearch.js
  3. 4 3
      config/router.js
  4. 2 1
      i18n/en.i18n.json

+ 1 - 0
client/components/main/globalSearch.jade

@@ -27,6 +27,7 @@ template(name="globalSearch")
           else
           else
             h1
             h1
               = resultsHeading.get
               = resultsHeading.get
+              a.fa.fa-link(title="{{_ 'link-to-search' }}" href="{{ getSearchHref }}")
             each card in results
             each card in results
               +resultCard(card)
               +resultCard(card)
       else
       else

+ 6 - 0
client/components/main/globalSearch.js

@@ -41,6 +41,7 @@ BlazeComponent.extendComponent({
     this.hasQueryErrors = new ReactiveVar(false);
     this.hasQueryErrors = new ReactiveVar(false);
     this.query = new ReactiveVar('');
     this.query = new ReactiveVar('');
     this.resultsHeading = new ReactiveVar('');
     this.resultsHeading = new ReactiveVar('');
+    this.searchLink = new ReactiveVar(null);
     this.queryParams = null;
     this.queryParams = null;
     this.parsingErrors = [];
     this.parsingErrors = [];
     this.resultsCount = 0;
     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() {
   searchInstructions() {
     tags = {
     tags = {
       operator_board: TAPi18n.__('operator-board'),
       operator_board: TAPi18n.__('operator-board'),

+ 4 - 3
config/router.js

@@ -160,9 +160,10 @@ FlowRouter.route('/global-search', {
     Utils.manageMatomo();
     Utils.manageMatomo();
     DocHead.setTitle(TAPi18n.__('globalSearch-title'));
     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', {
     BlazeLayout.render('defaultLayout', {
       headerBar: 'globalSearchHeaderBar',
       headerBar: 'globalSearchHeaderBar',
       content: 'globalSearch',
       content: 'globalSearch',

+ 2 - 1
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-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-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-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"
 }
 }