2014-04-02 23:48:35 +04:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2014, Arthur Schiwon <blizzz@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-04-16 21:41:09 +04:00
|
|
|
* @brief this object takes care of the filter functionality on the user
|
2014-04-03 00:00:25 +04:00
|
|
|
* management page
|
2015-08-05 18:29:20 +03:00
|
|
|
* @param {UserList} userList the UserList object
|
|
|
|
* @param {GroupList} groupList the GroupList object
|
2014-04-02 23:48:35 +04:00
|
|
|
*/
|
2015-08-05 18:29:20 +03:00
|
|
|
function UserManagementFilter (userList, groupList) {
|
2014-04-02 23:48:35 +04:00
|
|
|
this.userList = userList;
|
2014-04-15 02:13:23 +04:00
|
|
|
this.groupList = groupList;
|
2015-08-05 18:29:20 +03:00
|
|
|
this.oldFilter = '';
|
2014-04-02 23:48:35 +04:00
|
|
|
|
|
|
|
this.init();
|
|
|
|
}
|
|
|
|
|
2014-04-03 00:00:25 +04:00
|
|
|
/**
|
|
|
|
* @brief sets up when the filter action shall be triggered
|
|
|
|
*/
|
2015-08-05 18:29:20 +03:00
|
|
|
UserManagementFilter.prototype.init = function () {
|
|
|
|
OC.Plugins.register('OCA.Search', this);
|
2014-04-16 21:41:09 +04:00
|
|
|
};
|
2014-04-02 23:48:35 +04:00
|
|
|
|
2014-04-03 00:00:25 +04:00
|
|
|
/**
|
|
|
|
* @brief the filter action needs to be done, here the accurate steps are being
|
|
|
|
* taken care of
|
|
|
|
*/
|
2015-08-05 18:29:20 +03:00
|
|
|
UserManagementFilter.prototype.run = _.debounce(function (filter) {
|
|
|
|
if (filter === this.oldFilter) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.oldFilter = filter;
|
|
|
|
this.userList.filter = filter;
|
2014-05-13 17:59:04 +04:00
|
|
|
this.userList.empty();
|
|
|
|
this.userList.update(GroupList.getCurrentGID());
|
2015-08-05 18:29:20 +03:00
|
|
|
if (this.groupList.filterGroups) {
|
2014-07-09 14:19:50 +04:00
|
|
|
// user counts are being updated nevertheless
|
|
|
|
this.groupList.empty();
|
|
|
|
}
|
2014-05-13 17:59:04 +04:00
|
|
|
this.groupList.update();
|
|
|
|
},
|
|
|
|
300
|
|
|
|
);
|
2014-04-02 23:48:35 +04:00
|
|
|
|
2014-04-03 00:00:25 +04:00
|
|
|
/**
|
|
|
|
* @brief returns the filter String
|
|
|
|
* @returns string
|
|
|
|
*/
|
2015-08-05 18:29:20 +03:00
|
|
|
UserManagementFilter.prototype.getPattern = function () {
|
2014-12-05 14:16:22 +03:00
|
|
|
var input = this.filterInput.val(),
|
|
|
|
html = $('html'),
|
|
|
|
isIE8or9 = html.hasClass('lte9');
|
|
|
|
// FIXME - TODO - once support for IE8 and IE9 is dropped
|
2015-08-05 18:29:20 +03:00
|
|
|
if (isIE8or9 && input == this.filterInput.attr('placeholder')) {
|
2014-12-05 14:16:22 +03:00
|
|
|
input = '';
|
|
|
|
}
|
|
|
|
return input;
|
2014-04-16 21:41:09 +04:00
|
|
|
};
|
2014-04-18 00:14:04 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief adds reset functionality to an HTML element
|
|
|
|
* @param jQuery the jQuery representation of that element
|
|
|
|
*/
|
2015-08-05 18:29:20 +03:00
|
|
|
UserManagementFilter.prototype.addResetButton = function (button) {
|
2014-04-18 00:14:04 +04:00
|
|
|
var umf = this;
|
2015-08-05 18:29:20 +03:00
|
|
|
button.click(function () {
|
2014-04-18 00:14:04 +04:00
|
|
|
umf.filterInput.val('');
|
|
|
|
umf.run();
|
|
|
|
});
|
2014-05-13 17:59:04 +04:00
|
|
|
};
|
2015-08-05 18:29:20 +03:00
|
|
|
|
|
|
|
UserManagementFilter.prototype.attach = function (search) {
|
|
|
|
search.setFilter('settings', this.run.bind(this));
|
|
|
|
};
|