gridUpdateCallBack: function(){
$.log("gridUpdateCallBack users result");
applyAutocompleteOnUsersHeaders(self);
+ applySortOnHeadersButtons(self);
}
});
clearFilters=function(){
});
};
+ sortByProperty = function( property ) {
+ $.log("sortByProperty:" + property.headerText);
+ }
+
deleteUser=function(user){
clearUserMessages();
}
- }
+ };
+
+ 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);
}
- 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
*/
}
- applyAutocompleteOnUsersHeaders=function(usersViewModel){
- applyAutocompleteOnHeaderUsers("username",usersViewModel);
- applyAutocompleteOnHeaderUsers("fullName",usersViewModel);
- applyAutocompleteOnHeaderUsers("email",usersViewModel);
- }
+
activateUsersGridTab=function(){
var mainContent = $("#main-content");
<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>
</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'">