diff --git a/ang/crmCaseType.js b/ang/crmCaseType.js index 64f2d5cbcdd..daee538ae4c 100644 --- a/ang/crmCaseType.js +++ b/ang/crmCaseType.js @@ -477,18 +477,23 @@ 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(); + $scope.$apply(function() { + $scope.addRoleOnTheFly(roles, newType); + }); }); } } }; + $scope.addRoleOnTheFly = function(roles, newType) { + 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.onManagerChange = function(managerRole) { angular.forEach($scope.caseType.definition.caseRoles, function(caseRole) { if (caseRole != managerRole) {