Skip to content

Commit

Permalink
pull out function for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
demeritcowboy committed Oct 3, 2019
1 parent f76980b commit ccc6bd7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions ang/crmCaseType.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,20 +474,22 @@
roles.push({name: roleName, displaylabel: matchingRole.text});
} else {
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_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) {
$scope.relationshipTypeOptions.push({id: newType.label_b_a, text: newType.label_b_a});
}
$scope.$digest();
});
.on('crmFormSuccess', $scope.addRoleOnTheFly);
}
}
};

$scope.addRoleOnTheFly = function(e, data) {
var newType = _.values(data.relationshipType)[0];
$scope.caseType.definition.caseRoles.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) {
$scope.relationshipTypeOptions.push({id: newType.label_b_a, text: newType.label_b_a});
}
$scope.$digest();
};

$scope.onManagerChange = function(managerRole) {
angular.forEach($scope.caseType.definition.caseRoles, function(caseRole) {
if (caseRole != managerRole) {
Expand Down

0 comments on commit ccc6bd7

Please sign in to comment.