CRM-14483 - crmCaseType - Support for adding relationship-types
authorTim Otten <totten@civicrm.org>
Mon, 26 May 2014 21:05:25 +0000 (14:05 -0700)
committerTim Otten <totten@civicrm.org>
Mon, 26 May 2014 21:14:38 +0000 (14:14 -0700)
CRM/Case/Info.php
js/angular-crmCaseType.js
partials/crmCaseType/rolesTable.html

index 7067b2b7cb32820fbdcee96b266a0fcdcef1073f..8bd728d2c78e7d474f6ebab5cf59e45c29db4334 100644 (file)
@@ -68,11 +68,15 @@ class CRM_Case_Info extends CRM_Core_Component_Info {
     // Need full OptionValue records
     $actStatuses = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'activity_status'));
     $actTypes = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'activity_type'));
+    $relTypes = civicrm_api3('RelationshipType', 'get', array());
+
     CRM_Core_Resources::singleton()->addSetting(array(
       'crmCaseType' => array(
         'actStatuses' => array_values($actStatuses['values']),
         'actTypes' => array_values($actTypes['values']),
+        'relTypes' => array_values($relTypes['values']),
         //CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'),
+
       ),
     ));
     return $result;
index 35037757b3ca8b6066a4741ab227c405979c8560..7f2fe2dc1b67233ef1f3928e67ce23dcb4841c09 100644 (file)
@@ -61,6 +61,7 @@
     $scope.activityStatuses = CRM.crmCaseType.actStatuses;
     $scope.activityTypes = CRM.crmCaseType.actTypes;
     $scope.activityTypeNames = _.pluck(CRM.crmCaseType.actTypes, 'name');
+    $scope.relationshipTypeNames = _.pluck(CRM.crmCaseType.relTypes, 'label_b_a'); // label_b_a is CRM_Case_XMLProcessor::REL_TYPE_CNAME
 
     $scope.workflows = {
       'timeline': 'Timeline',
       }
     };
 
+    /// Add a new role
+    $scope.addRole = function(roles, roleName) {
+      roles.push({
+        name: roleName
+      });
+    };
+
     $scope.onManagerChange = function(managerRole) {
       angular.forEach($scope.caseType.definition.caseRoles, function(caseRole) {
         if (caseRole != managerRole) {
index 52e63e178e3fd5905ce322c184e2062788b92438..614c788075eb85a5a6d368c79d13e2f8e88dc8d6 100644 (file)
@@ -23,4 +23,16 @@ Required vars: caseType
     </td>
   </tr>
   </tbody>
+
+  <tfoot>
+  <tr class="addRow">
+    <td colspan="4">
+      <div crm-add-name
+           crm-options="relationshipTypeNames"
+           crm-var="newRole"
+           crm-on-add="addRole(caseType.definition.caseRoles, newRole)"
+              />
+    </td>
+  </tr>
+  </tfoot>
 </table>