SearchKit - permit selection of current user id for dynamic searches
[civicrm-core.git] / ext / search / ang / crmSearchPage.module.js
CommitLineData
44402a2e
CW
1(function(angular, $, _) {
2 "use strict";
3
4 // Declare module
5 angular.module('crmSearchPage', CRM.angRequires('crmSearchPage'))
6
44402a2e 7 .config(function($routeProvider) {
e7515b5b 8 // Load & render a SearchDisplay
44402a2e
CW
9 $routeProvider.when('/display/:savedSearchName/:displayName', {
10 controller: 'crmSearchPageDisplay',
e7515b5b 11 // Dynamic template generates the directive for each display type
ecb9d1eb
CW
12 template: '<h1 crm-page-title>{{:: $ctrl.display.label }}</h1>\n' +
13 '<div ng-include="\'~/crmSearchPage/displayType/\' + $ctrl.display.type + \'.html\'" id="bootstrap-theme"></div>',
44402a2e
CW
14 resolve: {
15 // Load saved search display
16 display: function($route, crmApi4) {
17 var params = $route.current.params;
18 return crmApi4('SearchDisplay', 'get', {
19 where: [['name', '=', params.displayName], ['saved_search.name', '=', params.savedSearchName]],
406f1014 20 select: ['*', 'saved_search.api_entity', 'saved_search.name']
44402a2e
CW
21 }, 0);
22 }
23 }
24 });
25 })
26
27 // Controller for displaying a search
28 .controller('crmSearchPageDisplay', function($scope, $routeParams, $location, display) {
29 this.display = display;
406f1014 30 this.searchName = display['saved_search.name'];
e7515b5b 31 this.apiEntity = display['saved_search.api_entity'];
44402a2e
CW
32 $scope.$ctrl = this;
33 });
34
35})(angular, CRM.$, CRM._);