Commit | Line | Data |
---|---|---|
475029f6 CW |
1 | (function(angular, $, _) { |
2 | "use strict"; | |
3 | ||
493f83d4 | 4 | angular.module('crmSearchAdmin').controller('searchList', function($scope, savedSearches, crmApi4) { |
475029f6 CW |
5 | var ts = $scope.ts = CRM.ts(), |
6 | ctrl = $scope.$ctrl = this; | |
7 | this.savedSearches = savedSearches; | |
8 | this.entityTitles = _.transform(CRM.vars.search.schema, function(titles, entity) { | |
493f83d4 | 9 | titles[entity.name] = entity.title_plural; |
475029f6 | 10 | }, {}); |
44402a2e | 11 | |
7620b30a CW |
12 | this.searchPath = window.location.href.split('#')[0].replace('civicrm/admin/search', 'civicrm/search'); |
13 | ||
44402a2e CW |
14 | this.deleteSearch = function(search) { |
15 | var index = _.findIndex(savedSearches, {id: search.id}); | |
16 | if (index > -1) { | |
17 | crmApi4([ | |
18 | ['Group', 'delete', {where: [['saved_search_id', '=', search.id]]}], | |
19 | ['SavedSearch', 'delete', {where: [['id', '=', search.id]]}] | |
20 | ]); | |
21 | savedSearches.splice(index, 1); | |
22 | } | |
23 | }; | |
475029f6 CW |
24 | }); |
25 | ||
26 | })(angular, CRM.$, CRM._); |