From bf1b57fdcdb363df22a0e9d44ddaecd6b5370cb2 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 11 Feb 2012 22:17:20 +0000 Subject: [PATCH] ui rewrite add bulk save mode in role edition screen git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1243170 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/redback/roles.js | 55 ++++++++++++++++--- .../js/redback/templates/roles-tmpl.html | 11 ++-- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js index 9877fedad..ebf0390e4 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js @@ -19,6 +19,9 @@ $(function() { Role = function(name,description,assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers){ + + var self=this; + this.name = ko.observable(name); this.name.subscribe(function(newValue){self.modified(true)}); @@ -52,6 +55,8 @@ $(function() { this.modified=ko.observable(false); + this.usersModified=ko.observable(false); + this.updateDescription=function(){ var url = "restServices/redbackServices/roleManagementService/updateRoleDescription?"; var roleName = this.name(); @@ -72,7 +77,7 @@ $(function() { } ); } - var self=this; + this.updateUsers=function(){ var url = "restServices/redbackServices/roleManagementService/updateRoleUsers"; $.ajax(url, @@ -130,20 +135,50 @@ $(function() { dataType: 'json', success: function(data) { var mappedRole = mapRole(data.role); - role.parentRoleNames=mappedRole.parentRoleNames; - role.parentsRolesUsers=mappedRole.parentsRolesUsers; - role.users=mappedRole.users; - role.otherUsers=mappedRole.otherUsers; + role.parentRoleNames(mappedRole.parentRoleNames()); + role.parentsRolesUsers(mappedRole.parentsRolesUsers()); + role.users(mappedRole.users()); + role.otherUsers(mappedRole.otherUsers()); + role.modified(false); var viewModel = new RoleViewModel(role); ko.applyBindings(viewModel,mainContent.find("#roles-view-tabs-content #role-edit").get(0)); activateRoleEditTab(); - mainContent.find("#role-view-users ").tabs("show"); + mainContent.find("#role-view-users").tabs("show"); mainContent.find("#role-edit-users-tabs-content #role-view-users").addClass("active"); } } ); } + this.bulkSave=function(){ + $.log("bulkSave"); + return getModifiedRoles().length>0; + } + + getModifiedRoles=function(){ + var prx = $.grep(self.roles(), + function (role,i) { + return role.modified()||role.usersModified(); + }); + return prx; + } + + updateModifiedRoles=function(){ + var modifiedRoles = getModifiedRoles(); + $.log("modifiedRoles:"+modifiedRoles); + for(i=0;i
+
+ +
@@ -149,10 +152,10 @@

${$.i18n.prop('role.edit.users.defined.in.current.role')}

- {{if $data.users}} + {{if users().length>0}}
    - {{each users}} -
  • ${$value.fullName} - ( ${$value.username} - ${$value.email} )
  • + {{each(j, user) users()}} +
  • ${user.fullName()} - ( ${user.username()} - ${user.email()} )
  • {{/each}}
{{else}} @@ -191,7 +194,7 @@ {{each(i, row) itemsOnCurrentPage()}} - + {{each(j, columnDefinition) columns}} {{var val = (typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText])}} -- 2.39.5