diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index f5d02e53a..87d0903c6 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -2,7 +2,7 @@ "use strict"; -angular.module('OpenSlidesApp.motions', []) +angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users']) .factory('WorkflowState', [ 'DS', diff --git a/openslides/motions/static/js/motions/site.js b/openslides/motions/static/js/motions/site.js index 5c8e85593..6d417d882 100644 --- a/openslides/motions/static/js/motions/site.js +++ b/openslides/motions/static/js/motions/site.js @@ -316,7 +316,6 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) '$scope', '$state', 'gettext', - 'operator', 'Motion', 'MotionFormFieldFactory', 'Category', @@ -325,7 +324,7 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions']) 'Tag', 'User', 'Workflow', - function($scope, $state, gettext, operator, Motion, MotionFormFieldFactory, Category, Config, Mediafile, Tag, User, Workflow) { + function($scope, $state, gettext, Motion, MotionFormFieldFactory, Category, Config, Mediafile, Tag, User, Workflow) { Category.bindAll({}, $scope, 'categories'); Mediafile.bindAll({}, $scope, 'mediafiles'); Tag.bindAll({}, $scope, 'tags'); diff --git a/openslides/users/static/js/users/base.js b/openslides/users/static/js/users/base.js index 7f39fbb9e..6f782e1fc 100644 --- a/openslides/users/static/js/users/base.js +++ b/openslides/users/static/js/users/base.js @@ -4,6 +4,55 @@ angular.module('OpenSlidesApp.users', []) +.factory('operator', [ + 'User', + 'Group', + 'loadGlobalData', + function(User, Group, loadGlobalData) { + var operatorChangeCallbacks = []; + var operator = { + user: null, + perms: [], + isAuthenticated: function () { + return !!this.user; + }, + onOperatorChange: function (func) { + operatorChangeCallbacks.push(func); + }, + setUser: function(user_id) { + if (user_id) { + User.find(user_id).then(function(user) { + operator.user = user; + // TODO: load only the needed groups + Group.findAll().then(function() { + operator.perms = user.getPerms(); + _.forEach(operatorChangeCallbacks, function (callback) { + callback(); + }); + }); + }); + } else { + operator.user = null; + Group.find(1).then(function(group) { + operator.perms = group.permissions; + _.forEach(operatorChangeCallbacks, function (callback) { + callback(); + }); + }); + } + }, + // Returns true if the operator has at least one perm of the perms-list. + hasPerms: function(perms) { + if (typeof perms == 'string') { + perms = perms.split(' '); + } + return _.intersection(perms, operator.perms).length > 0; + }, + }; + return operator; + } +]) + .factory('User', ['DS', 'Group', 'jsDataModel', function(DS, Group, jsDataModel) { var name = 'users/user'; return DS.defineResource({ diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index ae8c29c09..54feba1c6 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -119,55 +119,6 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) }); }) -.factory('operator', [ - 'User', - 'Group', - 'loadGlobalData', - function(User, Group, loadGlobalData) { - var operatorChangeCallbacks = []; - var operator = { - user: null, - perms: [], - isAuthenticated: function () { - return !!this.user; - }, - onOperatorChange: function (func) { - operatorChangeCallbacks.push(func); - }, - setUser: function(user_id) { - if (user_id) { - User.find(user_id).then(function(user) { - operator.user = user; - // TODO: load only the needed groups - Group.findAll().then(function() { - operator.perms = user.getPerms(); - _.forEach(operatorChangeCallbacks, function (callback) { - callback(); - }); - }); - }); - } else { - operator.user = null; - Group.find(1).then(function(group) { - operator.perms = group.permissions; - _.forEach(operatorChangeCallbacks, function (callback) { - callback(); - }); - }); - } - }, - // Returns true if the operator has at least one perm of the perms-list. - hasPerms: function(perms) { - if (typeof perms == 'string') { - perms = perms.split(' '); - } - return _.intersection(perms, operator.perms).length > 0; - }, - }; - return operator; - } -]) - .run([ 'operator', '$rootScope',