Fix 'operator' error in projector view.
Move operator factory from users/site.js to users/base.js. The Motion factory uses 'operator' in motions/base.js which is also loaded on projector. So operator is required in users/base.js.
This commit is contained in:
parent
f26188e0ff
commit
9af302ce36
@ -2,7 +2,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
angular.module('OpenSlidesApp.motions', [])
|
||||
angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users'])
|
||||
|
||||
.factory('WorkflowState', [
|
||||
'DS',
|
||||
|
@ -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');
|
||||
|
@ -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({
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user