CRM-14798 - crmCaseType - Fix leak of activity-types when making multiple case-types
authorTim Otten <totten@civicrm.org>
Thu, 3 Jul 2014 01:54:19 +0000 (18:54 -0700)
committerTim Otten <totten@civicrm.org>
Thu, 3 Jul 2014 01:57:07 +0000 (18:57 -0700)
If you make case type "Example 1" with an activity list, and if you then make
another case type "Example 2", the activity list form "Example 1" gets applied
to "Example 2" -- because the shared template was inappropriately modified
by "Example 1".

js/angular-crmCaseType.js

index 6a1bc9a50f9d28f3cde17bfb696001d7c50a839b..1c47d9bf0992340d78ebc3f0d35d36ac6fb30672 100644 (file)
@@ -6,6 +6,7 @@
 
   var crmCaseType = angular.module('crmCaseType', ['ngRoute', 'ui.utils', 'crmUi', 'unsavedChanges']);
 
+  // Note: This template will be passed to cloneDeep(), so don't put any funny stuff in here!
   var newCaseTypeDefinitionTemplate = {
     activityTypes: [
       {name: 'Open Case', max_instances: 1 }
@@ -46,7 +47,7 @@
             }
             else {
               return { title: "", name: "", is_active: "1", weight: "1",
-                definition: _.extend({}, newCaseTypeDefinitionTemplate) };
+                definition: _.cloneDeep(newCaseTypeDefinitionTemplate) };
             }
           }
         }