Extract mapping converter function, kinda brutally
[civicrm-core.git] / ang / crmCaseType.js
index 899ad35abf7eff9f00ebf2902ae9a911b626821d..a1ff51ae5749074c93fd2d019b1e93a5950f9815 100644 (file)
             });
           }
         }
+        // TODO The ids below really should use names not labels see
+        //  https://lab.civicrm.org/dev/core/issues/774
         else {
           result.push({
             text: relType.label_b_a,
-            id: relType.name_a_b
+            id: relType.label_a_b
           });
 
           if (!isBidirectionalRelationship) {
             result.push({
               text: relType.label_a_b,
-              id: relType.name_b_a
+              id: relType.label_b_a
             });
           }
         }
       activity.default_assignee_contact = null;
     };
 
+    // TODO roleName passed to addRole is a misnomer, its passed as the
+    // label HOWEVER it should be saved to xml as the name see
+    // https://lab.civicrm.org/dev/core/issues/774
+
     /// Add a new role
     $scope.addRole = function(roles, roleName) {
       var names = _.pluck($scope.caseType.definition.caseRoles, 'name');
            CRM.loadForm(CRM.url('civicrm/admin/reltype', {action: 'add', reset: 1, label_a_b: roleName}))
             .on('crmFormSuccess', function(e, data) {
               var newType = _.values(data.relationshipType)[0];
-              roles.push({name: newType.label_a_b, displaylabel: newType.label_b_a});
+              roles.push({name: newType.label_b_a, displaylabel: newType.label_a_b});
               // Assume that the case role should be A-B but add both directions as options.
               $scope.relationshipTypeOptions.push({id: newType.label_a_b, text: newType.label_a_b});
               if (newType.label_a_b != newType.label_b_a) {