diff --git a/CHANGELOG b/CHANGELOG
index bee113dba..2b71f0a29 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -40,6 +40,7 @@ Core:
- New csv import layout.
- Replaced angular-csv-import through Papa Parse for csv parsing.
- Added smooth projector scroll.
+- Added watching permissions in client and change the view immediately on changes.
Motions:
- Added adjustable line numbering mode (outside, inside, none) for each
diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js
index 1985f3b0d..e95f2373b 100644
--- a/openslides/agenda/static/js/agenda/site.js
+++ b/openslides/agenda/static/js/agenda/site.js
@@ -34,6 +34,7 @@ angular.module('OpenSlidesApp.agenda.site', [
template: "",
data: {
title: gettext('Agenda'),
+ basePerm: 'agenda.can_see',
},
})
.state('agenda.item', {
diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js
index e8e005fc5..68aa632dd 100644
--- a/openslides/assignments/static/js/assignments/site.js
+++ b/openslides/assignments/static/js/assignments/site.js
@@ -34,6 +34,7 @@ angular.module('OpenSlidesApp.assignments.site', [
template: "",
data: {
title: gettext('Elections'),
+ basePerm: 'assignments.can_see',
},
})
.state('assignments.assignment', {
diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js
index b83f5ec29..da5f50d4e 100644
--- a/openslides/core/static/js/core/base.js
+++ b/openslides/core/static/js/core/base.js
@@ -123,10 +123,8 @@ angular.module('OpenSlidesApp.core', [
setUser: function(user_id, user_data) {
if (user_id && user_data) {
operator.user = User.inject(user_data);
- operator.perms = operator.user.getPerms();
} else {
operator.user = null;
- operator.perms = Group.get(1).permissions;
}
},
// Returns true if the operator has at least one perm of the perms-list.
@@ -136,6 +134,14 @@ angular.module('OpenSlidesApp.core', [
}
return _.intersection(perms, operator.perms).length > 0;
},
+ reloadPerms: function () {
+ if (operator.user) {
+ operator.perms = operator.user.getPerms();
+ } else {
+ var defaultGroup = Group.get(1);
+ operator.perms = defaultGroup ? defaultGroup.permissions : [];
+ }
+ },
// Returns true if the operator is a member of group.
isInGroup: function(group) {
return _.indexOf(operator.user.groups_id, group.id) > -1;
diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js
index 154d4f1e4..b6bb74d3a 100644
--- a/openslides/core/static/js/core/site.js
+++ b/openslides/core/static/js/core/site.js
@@ -115,10 +115,18 @@ angular.module('OpenSlidesApp.core.site', [
.run([
'$rootScope',
'gettextCatalog',
- function ($rootScope, gettextCatalog) {
+ 'operator',
+ function ($rootScope, gettextCatalog, operator) {
$rootScope.activeAppTitle = '';
- $rootScope.$on('$stateChangeSuccess', function(evt, toState) {
- $rootScope.activeAppTitle = toState.data ? toState.data.title : '';
+ $rootScope.$on('$stateChangeSuccess', function(event, toState) {
+ if (toState.data) {
+ $rootScope.activeAppTitle = toState.data.title || '';
+ $rootScope.baseViewPermissionsGranted = toState.data.basePerm ?
+ operator.hasPerms(toState.data.basePerm) : true;
+ } else {
+ $rootScope.activeAppTitle = '';
+ $rootScope.baseViewPermissionsGranted = true;
+ }
});
}
])
@@ -263,6 +271,7 @@ angular.module('OpenSlidesApp.core.site', [
templateUrl: 'static/templates/home.html',
data: {
title: gettext('Home'),
+ basePerm: 'core.can_see_frontpage',
},
})
.state('projector', {
@@ -287,6 +296,7 @@ angular.module('OpenSlidesApp.core.site', [
controller: 'ManageProjectorsCtrl',
data: {
title: gettext('Manage projectors'),
+ basePerm: 'core.can_manage_projector',
},
})
.state('core', {
@@ -315,6 +325,7 @@ angular.module('OpenSlidesApp.core.site', [
},
data: {
title: gettext('Settings'),
+ basePerm: 'core.can_manage_config',
},
})
@@ -335,6 +346,7 @@ angular.module('OpenSlidesApp.core.site', [
template: "",
data: {
title: gettext('Tags'),
+ basePerm: 'core.can_manage_tags',
},
})
.state('core.tag.list', {})
diff --git a/openslides/core/static/js/core/start.js b/openslides/core/static/js/core/start.js
index f92842fc2..77e8a542e 100644
--- a/openslides/core/static/js/core/start.js
+++ b/openslides/core/static/js/core/start.js
@@ -30,6 +30,39 @@ angular.module('OpenSlidesApp.core.start', [])
}
});
}
+])
+
+.run([
+ '$rootScope',
+ '$state',
+ 'operator',
+ 'User',
+ 'Group',
+ 'mainMenu',
+ function ($rootScope, $state, operator, User, Group, mainMenu) {
+ var permissionChangeCallback = function () {
+ operator.reloadPerms();
+ mainMenu.updateMainMenu();
+ var stateData = $state.current.data;
+ var basePerm = stateData ? stateData.basePerm : '';
+ $rootScope.baseViewPermissionsGranted = basePerm ?
+ operator.hasPerms(basePerm) : true;
+ };
+
+ $rootScope.$watch(function () {
+ return Group.lastModified();
+ }, function () {
+ if (Group.getAll().length) {
+ permissionChangeCallback();
+ }
+ });
+
+ $rootScope.$watch(function () {
+ return operator.user ? User.lastModified(operator.user.id) : true;
+ }, function () {
+ permissionChangeCallback();
+ });
+ }
]);
}());
diff --git a/openslides/core/static/templates/core/manage-projectors.html b/openslides/core/static/templates/core/manage-projectors.html
index b4c40441c..f9792ef09 100644
--- a/openslides/core/static/templates/core/manage-projectors.html
+++ b/openslides/core/static/templates/core/manage-projectors.html
@@ -36,8 +36,8 @@
-
-
+
+
diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html
index c0042ad4a..1c41fdac8 100644
--- a/openslides/core/static/templates/index.html
+++ b/openslides/core/static/templates/index.html
@@ -174,9 +174,9 @@