[MRM-1734] add some filtering for searching in users table

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1427725 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-01-02 10:51:04 +00:00
parent 4d615d7fd9
commit 07aafa69cf
2 changed files with 78 additions and 8 deletions

View File

@ -51,10 +51,51 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
}); });
clearFilters=function(){ clearFilters=function(){
self.users(self.originalUsers()); self.users(self.originalUsers());
applyAutocompleteOnHeader("username",self); applyAutocompleteOnHeaders(self);
applyAutocompleteOnHeader("fullName",self);
applyAutocompleteOnHeader("email",self);
}; };
filterLocked=function(){
var founds=[];
$(self.originalUsers()).each(function(idx,user){
if(user.locked()){
founds.push(user);
}
});
self.users(founds);
applyAutocompleteOnHeaders(self);
}
filterNonLocked=function(){
var founds=[];
$(self.originalUsers()).each(function(idx,user){
if(user.locked()==false){
founds.push(user);
}
});
self.users(founds);
applyAutocompleteOnHeaders(self);
}
filterPasswordChangeRequired=function(){
var founds=[];
$(self.originalUsers()).each(function(idx,user){
if(user.passwordChangeRequired()){
founds.push(user);
}
});
self.users(founds);
applyAutocompleteOnHeaders(self);
}
filterPasswordChangeNotRequired=function(){
var founds=[];
$(self.originalUsers()).each(function(idx,user){
if(user.passwordChangeRequired()==false){
founds.push(user);
}
});
self.users(founds);
applyAutocompleteOnHeaders(self);
}
this.addUser=function() { this.addUser=function() {
clearUserMessages(); clearUserMessages();
var mainContent = $("#main-content"); var mainContent = $("#main-content");
@ -298,15 +339,20 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid) {
}) })
mainContent.find("#users-view-tabs-content #users-view").addClass("active"); mainContent.find("#users-view-tabs-content #users-view").addClass("active");
applyAutocompleteOnHeader("username",usersViewModel); applyAutocompleteOnHeaders(usersViewModel);
applyAutocompleteOnHeader("fullName",usersViewModel); mainContent.find("#usersTable").find('.dropdown-toggle').dropdown();
applyAutocompleteOnHeader("email",usersViewModel);
} }
} }
); );
} }
applyAutocompleteOnHeaders=function(usersViewModel){
applyAutocompleteOnHeader("username",usersViewModel);
applyAutocompleteOnHeader("fullName",usersViewModel);
applyAutocompleteOnHeader("email",usersViewModel);
}
activateUsersGridTab=function(){ activateUsersGridTab=function(){
var mainContent = $("#main-content"); var mainContent = $("#main-content");
mainContent.find("#users-view-tabs li").removeClass("active"); mainContent.find("#users-view-tabs li").removeClass("active");

View File

@ -200,8 +200,32 @@
{{/each}} {{/each}}
<th></th> <th></th>
<th></th> <th></th>
<th>locked ?</th> <th>
<th>chg pwd</th> <div class="btn-group" style="vertical-align: top; padding-bottom: 9px;">
<a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
Filter
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#" class="cursor-hand" data-bind="click: clearFilters">${$.i18n.prop('users.grid.filter.all')}</a></li>
<li><a href="#" class="cursor-hand" data-bind="click: filterLocked">${$.i18n.prop('users.grid.filter.locked')}</a></li>
<li><a href="#" class="cursor-hand" data-bind="click: filterNonLocked">${$.i18n.prop('users.grid.filter.not.locked')}</a></li>
</ul>
</div>
</th>
<th>
<div class="btn-group" style="vertical-align: top; padding-bottom: 9px;">
<a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#">
Filter
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#" class="cursor-hand" data-bind="click: clearFilters">${$.i18n.prop('users.grid.filter.all')}</a></li>
<li><a href="#" class="cursor-hand" data-bind="click: filterPasswordChangeRequired">${$.i18n.prop('users.grid.filter.pwd.change.required')}</a></li>
<li><a href="#" class="cursor-hand" data-bind="click: filterPasswordChangeNotRequired">${$.i18n.prop('users.grid.filter.pwd.change.not.required')}</a></li>
</ul>
</div>
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>