Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only show History tab if user has relevant permission #756

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions dist/udb3-angular.js

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions dist/udb3-angular.min.js

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions src/event-detail/ui/event-detail.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,23 @@ function EventDetail(
return permission === RolePermission.FILMS_AANMAKEN;
});

var canSeeHistory = !!_.find($scope.userPermissions, function(permission) {
return permission === RolePermission.AANBOD_HISTORIEK;
});

var canEditMovies = hasEditMoviesPermission && hasMovieLabel;

if ($scope.isGodUser) {
$scope.permissions = {editing: true, editingMovies: canEditMovies, duplication: true};
$scope.permissions = {editing: true, editingMovies: canEditMovies, duplication: true, history: true};
} else if (hasPermission) {
$scope.permissions = {editing: !event.isExpired(), editingMovies: canEditMovies, duplication: true};
$scope.permissions = {
editing: !event.isExpired(),
editingMovies: canEditMovies,
duplication: true,
history: canSeeHistory
};
} else {
$scope.permissions = {editing: false, duplication: false};
$scope.permissions = {editing: false, duplication: false, history: canSeeHistory};
}

setTabs();
Expand Down Expand Up @@ -112,7 +121,7 @@ function EventDetail(
$scope.calendarSummary = undefined;

function setTabs() {
if ($scope.isGodUser) {
if ($scope.permissions.history) {
$scope.tabs = [
{
id: 'data'
Expand Down
12 changes: 8 additions & 4 deletions src/event-detail/ui/event-detail.controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ describe('Controller: Event Detail', function() {
var expectedPermissions = {
editing: true,
editingMovies: false,
duplication: true
duplication: true,
history: false
};

$scope.$digest();
Expand All @@ -422,7 +423,8 @@ describe('Controller: Event Detail', function() {
var expectedPermissions = {
editing: false,
editingMovies: false,
duplication: true
duplication: true,
history: false
};

$scope.$digest();
Expand All @@ -442,7 +444,8 @@ describe('Controller: Event Detail', function() {

var expectedPermissions = {
editing: false,
duplication: false
duplication: false,
history: false
};

$scope.$digest();
Expand All @@ -463,7 +466,8 @@ describe('Controller: Event Detail', function() {
var expectedPermissions = {
editing: true,
editingMovies: false,
duplication: true
duplication: true,
history: true
};

$scope.$digest();
Expand Down
1 change: 1 addition & 0 deletions src/management/roles/permission.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ angular
'AANBOD_BEWERKEN': 'AANBOD_BEWERKEN',
'AANBOD_MODEREREN': 'AANBOD_MODEREREN',
'AANBOD_VERWIJDEREN': 'AANBOD_VERWIJDEREN',
'AANBOD_HISTORIEK': 'AANBOD_HISTORIEK',
'ORGANISATIES_BEWERKEN': 'ORGANISATIES_BEWERKEN',
'ORGANISATIES_BEHEREN': 'ORGANISATIES_BEHEREN',
'GEBRUIKERS_BEHEREN': 'GEBRUIKERS_BEHEREN',
Expand Down
1 change: 1 addition & 0 deletions src/management/roles/role-form.controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('Controller: Roles Form', function() {
{ key: 'AANBOD_BEWERKEN', name: 'AANBOD_BEWERKEN' },
{ key: 'AANBOD_MODEREREN', name: 'AANBOD_MODEREREN' },
{ key: 'AANBOD_VERWIJDEREN', name: 'AANBOD_VERWIJDEREN' },
{ key: 'AANBOD_HISTORIEK', name: 'AANBOD_HISTORIEK' },
{ key: 'ORGANISATIES_BEWERKEN', name: 'ORGANISATIES_BEWERKEN' },
{ key: 'ORGANISATIES_BEHEREN', name: 'ORGANISATIES_BEHEREN' },
{ key: 'GEBRUIKERS_BEHEREN', name: 'GEBRUIKERS_BEHEREN' },
Expand Down
Loading