Search ext: Add searchDisplay and searchPage modules
[civicrm-core.git] / ext / search / ang / searchAdmin / searchList.controller.js
CommitLineData
475029f6
CW
1(function(angular, $, _) {
2 "use strict";
3
44402a2e 4 angular.module('searchAdmin').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) {
9 titles[entity.name] = entity.titlePlural;
10 }, {});
44402a2e
CW
11
12 this.deleteSearch = function(search) {
13 var index = _.findIndex(savedSearches, {id: search.id});
14 if (index > -1) {
15 crmApi4([
16 ['Group', 'delete', {where: [['saved_search_id', '=', search.id]]}],
17 ['SavedSearch', 'delete', {where: [['id', '=', search.id]]}]
18 ]);
19 savedSearches.splice(index, 1);
20 }
21 };
475029f6
CW
22 });
23
24})(angular, CRM.$, CRM._);