* fix: multi lines and spaces issues * fix: eslint operator-linebreak issue * fix: eslint quotes issue * fix: remaining quotes issues * fix: eslint object curly newline issue * fix: eslint object curly spacing issue * fix: eslint brace-style issues * fix: react jsx indent and props issues * fix: eslint trailing spaces issues * fix: eslint linbreak style issue * fix: eslint space unary operator issue * fix: eslint line around directives issue * fix: void and typeof space unary ops issue
41 lines
1.8 KiB
JavaScript
41 lines
1.8 KiB
JavaScript
/*
|
|
Code for editing users and assigning roles within a library context.
|
|
*/
|
|
define(['underscore', 'gettext', 'js/views/manage_users_and_roles'],
|
|
function(_, gettext, ManageUsersAndRoles) {
|
|
'use strict';
|
|
|
|
return function(containerName, users, tplUserURL, current_user_id, allow_actions) {
|
|
function updateMessages(messages) {
|
|
var local_messages = _.extend({}, messages);
|
|
local_messages.alreadyMember.title = gettext('Already a library team member');
|
|
local_messages.deleteUser.messageTpl = gettext(
|
|
'Are you sure you want to delete {email} from the library “{container}”?'
|
|
);
|
|
return local_messages;
|
|
}
|
|
// Roles order are important: first role is considered initial role (the role added to user when (s)he's added
|
|
// Last role is considered an admin role (unrestricted access + ability to manage other users' permissions)
|
|
// Changing roles is performed in promote-demote fashion, so moves only to adjacent roles is allowed
|
|
var roles = [
|
|
{key: 'library_user', name: gettext('Library User')},
|
|
{key: 'staff', name: gettext('Staff')},
|
|
{key: 'instructor', name: gettext('Admin')}
|
|
];
|
|
|
|
var options = {
|
|
el: $('#content'),
|
|
containerName: containerName,
|
|
tplUserURL: tplUserURL,
|
|
roles: roles,
|
|
users: users,
|
|
messages_modifier: updateMessages,
|
|
current_user_id: current_user_id,
|
|
allow_actions: allow_actions
|
|
};
|
|
|
|
var view = new ManageUsersAndRoles(options);
|
|
view.render();
|
|
};
|
|
});
|