148fe633430979f600c37ec9c707d9e4834500ee
[civicrm-core.git] / ext / search / ang / crmSearchActions / crmSearchActionDelete.ctrl.js
1 (function(angular, $, _) {
2 "use strict";
3
4 angular.module('crmSearchActions').controller('crmSearchActionDelete', function($scope, dialogService) {
5 var ts = $scope.ts = CRM.ts(),
6 model = $scope.model,
7 ctrl = this;
8
9 this.entityTitle = model.ids.length === 1 ? model.entityInfo.title : model.entityInfo.title_plural;
10
11 this.cancel = function() {
12 dialogService.cancel('crmSearchAction');
13 };
14
15 this.delete = function() {
16 $('.ui-dialog-titlebar button').hide();
17 ctrl.run = {};
18 };
19
20 this.onSuccess = function() {
21 CRM.alert(ts('Successfully deleted %1 %2.', {1: model.ids.length, 2: ctrl.entityTitle}), ts('Deleted'), 'success');
22 dialogService.close('crmSearchAction');
23 };
24
25 this.onError = function() {
26 CRM.alert(ts('An error occurred while attempting to delete %1 %2.', {1: model.ids.length, 2: ctrl.entityTitle}), ts('Error'), 'error');
27 dialogService.close('crmSearchAction');
28 };
29
30 });
31 })(angular, CRM.$, CRM._);