From: kurund Date: Thu, 29 May 2014 19:25:03 +0000 (+0530) Subject: new case type fixes, CRM-14480 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c7bccb5f247bf2443e8234a85d6c5ff4ca67d149;p=civicrm-core.git new case type fixes, CRM-14480 ---------------------------------------- * CRM-14480: Implement "Edit Case Type" screen https://issues.civicrm.org/jira/browse/CRM-14480 --- diff --git a/CRM/Case/BAO/CaseType.php b/CRM/Case/BAO/CaseType.php index 275a643409..b845c9cd20 100644 --- a/CRM/Case/BAO/CaseType.php +++ b/CRM/Case/BAO/CaseType.php @@ -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); diff --git a/api/v3/CaseType.php b/api/v3/CaseType.php index 75f0c626f1..3182a60800 100644 --- a/api/v3/CaseType.php +++ b/api/v3/CaseType.php @@ -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; diff --git a/js/angular-crmCaseType.js b/js/angular-crmCaseType.js index 68e1e95ed0..e83e488e07 100644 --- a/js/angular-crmCaseType.js +++ b/js/angular-crmCaseType.js @@ -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) }; } } @@ -184,7 +184,12 @@ }; $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() {