Skip to content

Commit

Permalink
OS2DISP-155: Squashed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tuj committed Aug 22, 2018
1 parent 317661f commit cefde00
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 1.1.1

* Merged https://github.com/os2display/admin-bundle/pull/6: Only display the add role modal if the user has admin privileges.

## 1.1.0

* Made media upload buttons sticky.
Expand Down
2 changes: 1 addition & 1 deletion Resources/public/apps/adminApp/user/admin-user.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</article>
<article class="grid--item">
<box heading="{{ 'role.heading' | translate }}">
<div class="button-icon-link has-spacing-after" ng-click="showAddRoleModal()" ng-if="baseCanUpdate(user)">
<div class="button-icon-link has-spacing-after" ng-click="showAddRoleModal()" ng-if="baseCanUpdateRoles(baseCurrentUser)">
<i class="icon-rounded material-icons">security</i>
<span class="button-text has-spacing-before">{{ 'common.action.add_role' | translate }}</span>
</div>
Expand Down
13 changes: 10 additions & 3 deletions Resources/public/apps/adminApp/user/adminUserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,25 @@ angular.module('adminApp').controller('AdminUserController', [
var addRoleToDisplayList = function addRoleToDisplayList(key, role) {
var actions = [];

if ($scope.baseCanUpdate($scope.user)) {
// Determine actions the user is allowed to perform.
if ($scope.baseCanUpdateRoles($scope.baseCurrentUser)) {
actions.push({
title: $translate('user.action.remove_role'),
click: $scope.removeRoleFromUser,
entity: key
});
}

var newRole = {
id: key,
title: role,
actions: actions
title: role
};

// We only add the actions if they are actually there.
if (actions.length > 0) {
newRole.actions = actions;
}

$scope.userRoles.push(newRole);
};

Expand Down
10 changes: 10 additions & 0 deletions Resources/public/apps/mainModule/controller/baseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ angular.module('mainModule').controller('BaseController', ['$scope', 'userServic
return hasPermission(entity, 'can_update');
};

/**
* Can the entity update roles?
*
* @param entity
* @return {*}
*/
$scope.baseCanUpdateRoles = function baseCanUpdateRoles(entity) {
return hasPermission(entity, 'can_update_roles');
};

/**
* Can the entity be deleted?
*
Expand Down
24 changes: 23 additions & 1 deletion Resources/public/assets/build/os2displayadmin.min.js

Large diffs are not rendered by default.

0 comments on commit cefde00

Please sign in to comment.