CRM-15097 - crmCaseType - Allow reverting changes to case-types
authorTim Otten <totten@civicrm.org>
Tue, 12 Aug 2014 08:02:51 +0000 (01:02 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 12 Aug 2014 08:17:23 +0000 (01:17 -0700)
css/angular-crmCaseType.css
js/angular-crm-ui.js
js/angular-crmCaseType.js
partials/crmCaseType/list.html

index 3bac19f5f441b1cc444ec18873f3bd281cc60b30..b6035ebfed74f25bb04c97e8cb2006d1cc233575 100644 (file)
@@ -31,4 +31,8 @@
 
 .crmCaseType table td select {
     width: 10em;
+}
+
+tr.forked {
+    font-weight: bold;
 }
\ No newline at end of file
index 211a2aa861cae06cbb12ed5c9961ce44d8253b0e..c4def7015c34d11c3f581d7f1ba974c654d1e2cf 100644 (file)
             })
           };
         },
+        '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?'),
index 3238260a7a27261faf0698636ceb62b76f76a5a4..1841cb459db68f62ac441b0e8323d7ba22be1bd1 100644 (file)
           }
         });
     };
+    $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
index 4305201020154dbd72eb7c948908430cb9cd4b90..1f3bf76a7ca1c4009e4a9cda6f15851c6e3f2270 100644 (file)
@@ -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}">
     <td>{{caseType.title}}</td>
     <td>{{caseType.name}}</td>
     <td>{{caseType.description}}</td>
@@ -46,6 +46,13 @@ Required vars: caseTypes
                 Disable
               </a>
             </li>
+            <li ng-show="caseType.is_forked">
+              <a class="action-item crm-hover-button"
+                 crm-confirm="{type: 'revert', obj: caseType}"
+                 on-yes="revertCaseType(caseType)">
+                Revert
+              </a>
+            </li>
             <li>
               <a class="action-item crm-hover-button"
                  crm-confirm="{type: 'delete', obj: caseType}"