Use summary object_roles to lookup admin role id

To find the id of an org's admin role, use the `object_role` names
in the organization's summary_fields instead of filtering on
potentially translated role names.
This commit is contained in:
Jake McDermott 2020-01-10 11:32:01 -05:00
parent 200be3297a
commit cf9f00ab86
No known key found for this signature in database
GPG Key ID: 0E56ED990CDFCB4F

View File

@ -26,11 +26,9 @@ function($scope, $rootScope, ProcessErrors, GetBasePath, generateList,
let notAdminAlreadyParams = {};
if ($scope.addType === 'Administrators') {
Rest.setUrl(GetBasePath('organizations') + `${$state.params.organization_id}/object_roles`);
Rest.setUrl(GetBasePath('organizations') + `${$state.params.organization_id}`);
Rest.get().then(({data}) => {
notAdminAlreadyParams.not__roles = data.results
.filter(({name}) => name === i18n._('Admin'))
.map(({id}) => id)[0];
notAdminAlreadyParams.not__roles = data.summary_fields.object_roles.admin_role.id;
init();
});
} else {