From 7d3cdeb181c70f6ba94065d45b2e48b728c34fa8 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 6 May 2014 16:57:38 +1000 Subject: [PATCH] =?utf8?q?[MRM-1812]=C2=A0Users=20-=20Manage=20section=20n?= =?utf8?q?eeds=20Sort=20by=20User=20Name,=20Sort=20by=20Full=20Name,=20and?= =?utf8?q?=20Sort=20by=20Email=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../apache/archiva/i18n/default.properties | 1 + .../src/main/webapp/js/redback/users.js | 84 ++++++++++++------- .../js/templates/redback/user-edit.html | 9 +- 3 files changed, 59 insertions(+), 35 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 684f6b3c5..14a8c099e 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -241,6 +241,7 @@ user.change.password.required=Change password required users.grid.tab.title=Users users.list=Users List users.sort.byname=Sort by User Name +users.sort.generic=Sort effective.roles.edit=Edit Roles locked=Locked validated=Validated diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js index 827a20653..79a9d1612 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js @@ -52,6 +52,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) { gridUpdateCallBack: function(){ $.log("gridUpdateCallBack users result"); applyAutocompleteOnUsersHeaders(self); + applySortOnHeadersButtons(self); } }); clearFilters=function(){ @@ -149,6 +150,10 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) { }); }; + sortByProperty = function( property ) { + $.log("sortByProperty:" + property.headerText); + } + deleteUser=function(user){ clearUserMessages(); @@ -234,7 +239,53 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) { } - } + }; + + applyAutocompleteOnUsersHeaders=function(usersViewModel){ + applyAutocompleteOnHeaderUsers("username",usersViewModel); + applyAutocompleteOnHeaderUsers("fullName",usersViewModel); + applyAutocompleteOnHeaderUsers("email",usersViewModel); + }; + + applySortOnHeadersButtons=function(usersViewModel){ + applySortOnHeadersButton("username",usersViewModel); + applySortOnHeadersButton("fullName",usersViewModel); + applySortOnHeadersButton("email",usersViewModel); + }; + + applyAutocompleteOnHeaderUsers=function(property,usersViewModel){ + var founds=[]; + $(usersViewModel.originalUsers()).each(function(idx,user){ + if(user[property] && user[property]()){ + founds.push(user[property]()); + } + }); + var cell = $("#main-content").find("#users-grid-filter-auto-"+property ); + cell.typeahead({ + local: founds, + name: 'users-'+property+'-'+$.now() + }); + cell.on('typeahead:selected', function(obj, datum) { + var users=[]; + + $(usersViewModel.originalUsers()).each(function(idx,user){ + if(user[property] && user[property]() && user[property]().indexOf(datum.value)>=0){ + users.push(user); + } + }); + usersViewModel.users(users); + }); + + }; + + applySortOnHeadersButton=function(property,usersViewModel){ + var cell = $("#main-content").find("#users-header-"+property ); + cell.on("click",function(){ + usersViewModel.users.sort(function(a, b) { + return a[property]().localeCompare(b[property]()); + }); + }); + }; editUserRoles=function(user){ var viewModel = new UserViewModel(user); @@ -280,31 +331,6 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) { } - applyAutocompleteOnHeaderUsers=function(property,usersViewModel){ - var founds=[]; - $(usersViewModel.originalUsers()).each(function(idx,user){ - if(user[property] && user[property]()){ - founds.push(user[property]()); - } - }); - //var filteredHeader = ; - $("#main-content").find("#users-grid-filter-auto-"+property ).typeahead({ - local: founds, - name: 'users-'+property+'-'+$.now() - }); - $("#main-content").find("#users-grid-filter-auto-"+property ).on('typeahead:selected', function(obj, datum) { - var users=[]; - - $(usersViewModel.originalUsers()).each(function(idx,user){ - if(user[property] && user[property]() && user[property]().indexOf(datum.value)>=0){ - users.push(user); - } - }); - usersViewModel.users(users); - }); - - } - /** * called from the menu to display tabs with users grid */ @@ -345,11 +371,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) { } - applyAutocompleteOnUsersHeaders=function(usersViewModel){ - applyAutocompleteOnHeaderUsers("username",usersViewModel); - applyAutocompleteOnHeaderUsers("fullName",usersViewModel); - applyAutocompleteOnHeaderUsers("email",usersViewModel); - } + activateUsersGridTab=function(){ var mainContent = $("#main-content"); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html index 3baec2b24..f129ad38a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html @@ -182,7 +182,11 @@ {{each(i, columnDefinition) columns}} - ${ columnDefinition.headerText } + ${columnDefinition.headerText} + + {{/each}} ${$.i18n.prop('edit')} ${$.i18n.prop('delete')} @@ -306,9 +310,6 @@
- ${$.i18n.prop('users.grid.filter')} -- 2.39.5