*/
$(function() {
- role = function(name,description,assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers){
+ Role = function(name,description,assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers){
this.name = ko.observable(name);
this.description = ko.observable(description);
this.assignable = ko.observable(assignable);
this.parentsRolesUsers = ko.observableArray(parentsRolesUsers);//read only
this.permissions = ko.observableArray(permissions);//read only
// when editing a role other users not assign to this role are populated
- this.otherUsers = ko.observableArray(otherUsers);
- this.removedUsers=ko.observableArray([]);
+ this.otherUsers = ko.observableArray(otherUsers?otherUsers:new Array());
+ this.removedUsers= ko.observableArray(new Array());
this.updateDescription=function(){
var url = "restServices/redbackServices/roleManagementService/updateRoleDescription?";
}
);
}
+ var self=this;
this.updateUsers=function(){
var url = "restServices/redbackServices/roleManagementService/updateRoleUsers";
$.ajax(url,
type: "POST",
dataType: 'json',
contentType: 'application/json',
- data: "{\"role\": " + ko.toJSON(this)+"}",
+ data: "{\"role\": " + ko.toJSON(self)+"}",
success: function(data) {
displaySuccessMessage($.i18n.prop("role.users.updated",this.name));
},
);
}
- this.updateMode=function(){
- $("#main-content #role-list-users").hide();
- $("#main-content #role-edit-users").show();
- }
- this.viewMode=function(){
- $("#main-content #role-edit-users").hide();
- $("#main-content #role-list-users").show();
- }
}
/**
}
RoleViewModel=function(role){
- selectedOtherUsers=new ko.observableArray();
- selectedUsers=new ko.observableArray();
+ selectedOtherUsers= ko.observableArray();
+ selectedUsers= ko.observableArray();
currentRole=role;
var self=this;
addUser=function(){
+ $.log("addUser");
var removed = currentRole.otherUsers.removeAll(selectedOtherUsers());
for (var i = 0; i < removed.length; i++) {
+ $.log("add user:"+removed[i].username());
currentRole.users.push(removed[i]);
}
selectedOtherUsers([]);
saveUsers=function(){
currentRole.updateUsers();
}
+
+ updateMode=function(){
+ $("#main-content #role-list-users").hide();
+ $("#main-content #role-edit-users").show();
+ }
+ viewMode=function(){
+ $("#main-content #role-edit-users").hide();
+ $("#main-content #role-list-users").show();
+ }
}
/**
return mapUser(item);
}):new Array(mapUser(data.otherUsers)):null;
- return new role(data.name, data.description?data.description:"",data.assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers);
+ return new Role(data.name, data.description?data.description:"",data.assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers);
}
activateRolesGridTab=function(){
${$.i18n.prop('role.edit.no.user.defined')}
{{/if}}
- <button class="btn" data-bind="click:updateMode">${$.i18n.prop('role.update.mode')}</button>
+ <input class="btn" type="button" id="role-list-users-update-mode" data-bind="click: updateMode" value="${$.i18n.prop('role.update.mode')}"/>
</div>
</div>
<div class="ar-multiselect-column ar-multiselect-center">
<ul style="list-style: none">
- <li><button class="btn" data-bind="click: addUser">></button></li>
- <li><button class="btn" data-bind="click: removeUser"><</button></li>
+ <li><input class="btn" id="role-edit-users-add-user" type="button" data-bind="click: addUser" value=">"/></li>
+ <li><input class="btn" id="role-edit-users-remove-user" type="button" data-bind="click: removeUser" value="<"/></li>
</ul>
</div>
<div class="ar-multiselect-column ar-multiselect-right">
<select data-bind="options: users ,optionsText: 'username',selectedOptions:selectedUsers" multiple="true" id="role-edit-affected-users"></select>
</div>
- <button class="btn" data-bind="click: saveUsers">${$.i18n.prop('save')}</button>
+ <button class="btn" id="role-edit-users-save" data-bind="click: saveUsers">${$.i18n.prop('save')}</button>
<br/>
- <button class="btn" data-bind="click:viewMode">${$.i18n.prop('role.view.mode')}</button>
+ <input class="btn" id="role-edit-users-view-mode" type="button" data-bind="click: viewMode" value="${$.i18n.prop('role.view.mode')}"/>
</div>
</script>
+
+
<script id='ko_rolesGrid' type='text/x-jquery-tmpl'>
<thead>
<tr>