From 470a458eb5ee6b3a73ab74124386474e50b13e71 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 12 Aug 2014 01:02:51 -0700 Subject: [PATCH] CRM-15097 - crmCaseType - Allow reverting changes to case-types --- css/angular-crmCaseType.css | 4 ++++ js/angular-crm-ui.js | 10 ++++++++++ js/angular-crmCaseType.js | 11 +++++++++++ partials/crmCaseType/list.html | 9 ++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/css/angular-crmCaseType.css b/css/angular-crmCaseType.css index 3bac19f5f4..b6035ebfed 100644 --- a/css/angular-crmCaseType.css +++ b/css/angular-crmCaseType.css @@ -31,4 +31,8 @@ .crmCaseType table td select { width: 10em; +} + +tr.forked { + font-weight: bold; } \ No newline at end of file diff --git a/js/angular-crm-ui.js b/js/angular-crm-ui.js index 211a2aa861..c4def7015c 100644 --- a/js/angular-crm-ui.js +++ b/js/angular-crm-ui.js @@ -142,6 +142,16 @@ }) }; }, + 'revert': function (options) { + return { + message: ts('Are you sure you want to revert this?'), + options: {no: ts('Cancel'), yes: ts('Revert')}, + width: 300, + title: ts('Revert %1?', { + 1: options.obj.title || options.obj.label || options.obj.name || ts('the record') + }) + }; + }, 'delete': function (options) { return { message: ts('Are you sure you want to delete this?'), diff --git a/js/angular-crmCaseType.js b/js/angular-crmCaseType.js index 3238260a7a..1841cb459d 100644 --- a/js/angular-crmCaseType.js +++ b/js/angular-crmCaseType.js @@ -315,6 +315,17 @@ } }); }; + $scope.revertCaseType = function (caseType) { + caseType.definition = 'null'; + caseType.is_forked = '0'; + crmApi('CaseType', 'create', caseType, true) + .then(function (data) { + if (data.is_error) { + caseType.is_forked = '1'; // restore + $scope.$digest(); + } + }); + }; }); })(angular, CRM.$, CRM._); \ No newline at end of file diff --git a/partials/crmCaseType/list.html b/partials/crmCaseType/list.html index 4305201020..1f3bf76a7c 100644 --- a/partials/crmCaseType/list.html +++ b/partials/crmCaseType/list.html @@ -21,7 +21,7 @@ Required vars: caseTypes class="crm-entity" ng-class-even="'even-row even'" ng-class-odd="'odd-row odd'" - ng-class="{disabled: 0==caseType.is_active}"> + ng-class="{disabled: 0==caseType.is_active, forked: 1==caseType.is_forked}"> {{caseType.title}} {{caseType.name}} {{caseType.description}} @@ -46,6 +46,13 @@ Required vars: caseTypes Disable +
  • + + Revert + +