You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2014/05/06 08:59:18 UTC

[1/2] git commit: [MRM-1812] Users - Manage section needs Sort by User Name, Sort by Full Name, and Sort by Email buttons

Repository: archiva
Updated Branches:
  refs/heads/master 8e8148886 -> 08ae7d269


[MRM-1812] Users - Manage section needs Sort by User Name, Sort by Full Name, and Sort by Email buttons


Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/7d3cdeb1
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/7d3cdeb1
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/7d3cdeb1

Branch: refs/heads/master
Commit: 7d3cdeb181c70f6ba94065d45b2e48b728c34fa8
Parents: 8e81488
Author: Olivier Lamy <ol...@apache.org>
Authored: Tue May 6 16:57:38 2014 +1000
Committer: Olivier Lamy <ol...@apache.org>
Committed: Tue May 6 16:57:38 2014 +1000

----------------------------------------------------------------------
 .../org/apache/archiva/i18n/default.properties  |  1 +
 .../src/main/webapp/js/redback/users.js         | 84 ++++++++++++--------
 .../webapp/js/templates/redback/user-edit.html  |  9 ++-
 3 files changed, 59 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva/blob/7d3cdeb1/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
----------------------------------------------------------------------
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 684f6b3..14a8c09 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

http://git-wip-us.apache.org/repos/asf/archiva/blob/7d3cdeb1/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js
----------------------------------------------------------------------
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 827a206..79a9d16 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");

http://git-wip-us.apache.org/repos/asf/archiva/blob/7d3cdeb1/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/redback/user-edit.html
----------------------------------------------------------------------
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 3baec2b..f129ad3 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 @@
   <thead>
     <tr>
       {{each(i, columnDefinition) columns}}
-      <th>${ columnDefinition.headerText }</th>
+      <th>${columnDefinition.headerText}
+        <button id="users-header-${columnDefinition.rowText}" class="btn">
+          ${$.i18n.prop('users.sort.generic')}
+        </button>
+      </th>
       {{/each}}
       <th>${$.i18n.prop('edit')}</th>
       <th>${$.i18n.prop('delete')}</th>
@@ -306,9 +310,6 @@
   </ul>
   <div id="users-view-tabs-content" class="tab-content">
     <div id="users-view" class="tab-pane">
-      <button data-bind='click: sortByName' class="btn">
-        ${$.i18n.prop('users.sort.byname')}
-      </button>
       <a href="#" class="btn btn-warning" data-bind="click: clearFilters" id="remove-filter-id">${$.i18n.prop('users.grid.filter')}</a>
       <table class="table table-striped table-bordered" id="usersTable"
              data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko_usersGrid_grid',pageLinksId:'usersPagination'">


[2/2] git commit: cleanup

Posted by ol...@apache.org.
cleanup


Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/08ae7d26
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/08ae7d26
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/08ae7d26

Branch: refs/heads/master
Commit: 08ae7d269f1af40d7cebfb6127398588c6a2afca
Parents: 7d3cdeb
Author: Olivier Lamy <ol...@apache.org>
Authored: Tue May 6 16:58:48 2014 +1000
Committer: Olivier Lamy <ol...@apache.org>
Committed: Tue May 6 16:58:48 2014 +1000

----------------------------------------------------------------------
 .../src/main/webapp/js/redback/users.js          | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva/blob/08ae7d26/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/redback/users.js
----------------------------------------------------------------------
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 79a9d16..d9cc59d 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
@@ -66,7 +66,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) {
         }
       });
       self.users(founds);
-    }
+    };
     filterNonLocked=function(){
       var founds=[];
       $(self.originalUsers()).each(function(idx,user){
@@ -75,7 +75,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) {
         }
       });
       self.users(founds);
-    }
+    };
 
     filterPasswordChangeRequired=function(){
       var founds=[];
@@ -85,7 +85,8 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) {
         }
       });
       self.users(founds);
-    }
+    };
+
     filterPasswordChangeNotRequired=function(){
       var founds=[];
       $(self.originalUsers()).each(function(idx,user){
@@ -94,7 +95,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) {
         }
       });
       self.users(founds);
-    }
+    };
 
 
     this.addUser=function() {
@@ -144,16 +145,6 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,typeahead) {
       user.changePasswordChangeRequired(forceChangedPassword);
     };
 
-    this.sortByName = function() {
-      this.users.sort(function(a, b) {
-        return a.username().localeCompare(b.username());
-      });
-    };
-
-    sortByProperty = function( property ) {
-      $.log("sortByProperty:" + property.headerText);
-    }
-
     deleteUser=function(user){
       clearUserMessages();