1 (function(angular
, $, _
) {
4 angular
.module('crmSearchAdmin').controller('searchList', function($scope
, savedSearches
, crmApi4
) {
5 var ts
= $scope
.ts
= CRM
.ts(),
6 ctrl
= $scope
.$ctrl
= this;
7 this.savedSearches
= savedSearches
;
8 this.entityTitles
= _
.transform(CRM
.crmSearchAdmin
.schema
, function(titles
, entity
) {
9 titles
[entity
.name
] = entity
.title_plural
;
12 this.searchPath
= window
.location
.href
.split('#')[0].replace('civicrm/admin/search', 'civicrm/search');
14 this.encode = function(params
) {
15 return encodeURI(angular
.toJson(params
));
18 this.deleteSearch = function(search
) {
19 var index
= _
.findIndex(savedSearches
, {id
: search
.id
});
22 ['Group', 'delete', {where
: [['saved_search_id', '=', search
.id
]]}],
23 ['SavedSearch', 'delete', {where
: [['id', '=', search
.id
]]}]
25 savedSearches
.splice(index
, 1);
30 })(angular
, CRM
.$, CRM
._
);