Quellcode durchsuchen

Add link to search header for storing search

John R. Supplee vor 4 Jahren
Ursprung
Commit
7e8475e64d

+ 1 - 0
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

+ 6 - 0
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'),

+ 4 - 3
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',

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