SearchKit - Take search filters from the url when viewing a standalone searchDisplay
authorColeman Watts <coleman@civicrm.org>
Tue, 2 Mar 2021 20:37:16 +0000 (15:37 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 4 Mar 2021 20:45:54 +0000 (15:45 -0500)
This passes through all query params from the url fragment as search filters to the display.

ext/search/Civi/Search/Display.php
ext/search/ang/crmSearchPage.module.js

index 1e784ea38a7ddf2c041593801f36b5d604e32711..302164de06632ea59ce64829483bb5f3592ad3eb 100644 (file)
@@ -24,7 +24,7 @@ class Display {
     $partials = [];
     foreach (self::getDisplayTypes(['id', 'name']) as $type) {
       $partials["~/$moduleName/displayType/{$type['id']}.html"] =
-        '<' . $type['name'] . ' api-entity="{{:: $ctrl.apiEntity }}" search="$ctrl.searchName" display="$ctrl.display.name" settings="$ctrl.display.settings"></' . $type['name'] . '>';
+        '<' . $type['name'] . ' api-entity="{{:: $ctrl.apiEntity }}" search="$ctrl.searchName" display="$ctrl.display.name" settings="$ctrl.display.settings" filters="$ctrl.filters"></' . $type['name'] . '>';
     }
     return $partials;
   }
index 42e429e85e33e72448d1831b53d204fa8d9fd069..6a1947395497d0194e5a9f26bcedce9217a6a0d8 100644 (file)
     })
 
     // Controller for displaying a search
-    .controller('crmSearchPageDisplay', function($scope, $routeParams, $location, display) {
+    .controller('crmSearchPageDisplay', function($scope, $location, display) {
+      var ctrl = $scope.$ctrl = this;
       this.display = display;
       this.searchName = display['saved_search.name'];
       this.apiEntity = display['saved_search.api_entity'];
-      $scope.$ctrl = this;
+
+      $scope.$watch(function() {return $location.search();}, function(params) {
+        ctrl.filters = params;
+      });
     });
 
 })(angular, CRM.$, CRM._);