new case type fixes, CRM-14480
authorkurund <kurund@civicrm.org>
Thu, 29 May 2014 19:25:03 +0000 (00:55 +0530)
committerkurund <kurund@civicrm.org>
Thu, 29 May 2014 19:25:03 +0000 (00:55 +0530)
----------------------------------------
* CRM-14480: Implement "Edit Case Type" screen
  https://issues.civicrm.org/jira/browse/CRM-14480

CRM/Case/BAO/CaseType.php
api/v3/CaseType.php
js/angular-crmCaseType.js

index 275a643409ee029e949744e94fa08013bef1297c..b845c9cd20e74b45726131d102af448502e6dc34 100644 (file)
@@ -65,6 +65,12 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType {
   static function add(&$params) {
     $caseTypeDAO = new CRM_Case_DAO_CaseType();
 
+    // form the name only if missing: CRM-627
+    $nameParam = CRM_Utils_Array::value('name', $params, NULL);
+    if (!$nameParam && empty($params['id'])) {
+      $params['name'] = CRM_Utils_String::titleToVar($params['title']);
+    }
+
     // function to format definition column
     self::convertDefinitionToXML($params);
 
index 75f0c626f165b295195dd69a3104662f9e563649..3182a6080010290ee504e0c659f9d8646b281cb3 100644 (file)
@@ -50,7 +50,7 @@
  * @access public
  */
 function civicrm_api3_case_type_create($params) {
-  civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name'));
+  civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__));
 
   if (!array_key_exists('is_active', $params) && empty($params['id'])) {
     $params['is_active'] = TRUE;
index 68e1e95ed02518cc506f390c1e71189000ad0450..e83e488e0729fd7ba4c76a69436aadc40fafa700 100644 (file)
@@ -45,7 +45,7 @@
               return crmApi('CaseType', 'getsingle', {id: $route.current.params.id});
             }
             else {
-              return { title: "New case type", name: "New case type", is_active: "1",
+              return { title: "New case type", name: "New case type", is_active: "1", weight: "1",
                 definition: _.extend({}, newCaseTypeDefinitionTemplate) };
             }
           }
     };
 
     $scope.save = function() {
-      crmApi('CaseType', 'create', $scope.caseType, true);
+      var result = crmApi('CaseType', 'create', $scope.caseType, true);
+      result.success(function(data) {
+        if (data.is_error == 0) {
+          $scope.caseType.id = data.id;
+        }
+      });
     };
 
     $scope.$watchCollection('caseType.definition.activitySets', function() {