b827c3250542f28c07f27a344caadb02546aff98
1 (function(angular
, $, _
) {
3 angular
.module('msgtplui').controller('MsgtpluiListCtrl', function($scope
, $route
, crmApi4
, crmStatus
, crmUiAlert
, crmUiHelp
, records
, $location
) {
4 var ts
= $scope
.ts
= CRM
.ts('msgtplui');
5 var hs
= $scope
.hs
= crmUiHelp({file
: 'CRM/msgtplui/User'}); // See: templates/CRM/msgtplui/User.hlp
6 $scope
.crmUrl
= CRM
.url
;
7 $scope
.crmUiAlert
= crmUiAlert
;
10 ctrl
.records
= records
;
12 ctrl
.editUrl = function(record
, stage
) {
13 var url
= '#/edit?id=' + encodeURIComponent(record
.id
);
14 if (record
['tx.language']) {
15 url
= url
+ '&lang=' + encodeURIComponent(record
['tx.language']);
17 if (stage
=== 'draft') {
18 url
= url
+ '&status=draft';
23 ctrl
.delete = function (record
) {
24 var q
= crmApi4('MessageTemplate', 'delete', {where
: [['id', '=', record
.id
]]}).then(function(){
27 return crmStatus({start
: ts('Deleting...'), success
: ts('Deleted')}, q
);
30 ctrl
.toggle = function (record
) {
31 var wasActive
= !!record
.is_active
;
32 var q
= crmApi4('MessageTemplate', 'update', {where
: [['id', '=', record
.id
]], values
: {is_active
: !wasActive
}})
34 record
.is_active
= !wasActive
;
36 return wasActive
? crmStatus({start
: ts('Disabling...'), success
: ts('Disabled')}, q
)
37 : crmStatus({start
: ts('Enabling...'), success
: ts('Enabled')}, q
);
42 })(angular
, CRM
.$, CRM
._
);