lib/client public_html/js public_html/skins
Aleksander Machniak
machniak at kolabsys.com
Wed Feb 22 14:33:09 CET 2012
lib/client/kolab_client_task_user.php | 22 ++++++++++++++++++----
public_html/js/kolab_admin.js | 22 +++++++++++++---------
public_html/skins/default/ui.js | 7 +++++--
3 files changed, 36 insertions(+), 15 deletions(-)
New commits:
commit d1b65b80e8e70e4797b1fd41bb710f8270f31bbe
Author: Aleksander Machniak <alec at alec.pl>
Date: Wed Feb 22 14:29:57 2012 +0100
Fixed list paging issues
Refresh users list after user add/update
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 1718697..17ba129 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -48,7 +48,7 @@ class kolab_client_task_user extends kolab_client_task
{
$page_size = 20;
$page = (int) self::get_input('page', 'POST');
- if (!$page) {
+ if (!$page || $page < 1) {
$page = 1;
}
@@ -67,15 +67,24 @@ class kolab_client_task_user extends kolab_client_task
$field = self::get_input('field', 'POST');
$method = self::get_input('method', 'POST');
- $post['search'] = array(
+ $search_request = array(
$field => array(
'value' => $search,
'type' => $method,
),
);
+ }
+ else if (!empty($_POST['search_request'])) {
+ $search_request = self::get_input('search_request', 'POST');
+ $search_request = @unserialize(base64_decode($search_request));
+ }
+
+ if (!empty($search_request)) {
+ $post['search'] = $search_request;
$post['search_operator'] = 'OR';
}
+ // get users list
$result = $this->api->post('users.list', null, $post);
$count = $result->get('count');
$result = (array) $result->get('list');
@@ -99,7 +108,7 @@ class kolab_client_task_user extends kolab_client_task
$prev = max(0, $page - 1);
$next = $page < $pages ? $page + 1 : 0;
- $count = kolab_html::span(array(
+ $count_str = kolab_html::span(array(
'content' => $this->translate('user.list.records', $start, $end, $count)), true);
$prev = kolab_html::a(array(
'class' => 'prev' . ($prev ? '' : ' disabled'),
@@ -112,10 +121,11 @@ class kolab_client_task_user extends kolab_client_task
'onclick' => $next ? "kadm.command('user.list', {page: $next})" : "return false",
));
- $foot_body = kolab_html::span(array('content' => $prev . $count . $next));
+ $foot_body = kolab_html::span(array('content' => $prev . $count_str . $next));
}
$foot[0]['cells'][] = array('class' => 'listnav', 'body' => $foot_body);
+ // table body
if (!empty($result)) {
foreach ($result as $idx => $item) {
if (!is_array($item) || empty($item['displayname'])) {
@@ -143,6 +153,10 @@ class kolab_client_task_user extends kolab_client_task
'foot' => $foot,
));
+ $this->output->set_env('search_request', $search_request ? base64_encode(serialize($search_request)) : null);
+ $this->output->set_env('list_page', $page);
+ $this->output->set_env('list_count', $count);
+
$this->watermark('taskcontent');
$this->output->set_object('userlist', $table);
}
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 62272d1..89ee9ec 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -498,11 +498,11 @@ function kolab_admin()
this.user_list = function(props)
{
- if (props) {
- if (props.search) {
- props = $.extend(props, this.serialize_form('#search-form'));
- }
- }
+ if (!props)
+ props = {};
+
+ if (props.search === undefined && this.env.search_request)
+ props.search_request = this.env.search_request;
this.http_post('user.list', props);
};
@@ -518,9 +518,14 @@ function kolab_admin()
if (!this.api_response(response))
return;
+ var page = this.env.list_page;
+
+ // goto previous page if last user on the current page has been deleted
+ if (this.env.list_count)
+ page -= 1;
+
this.display_message('user.delete.success');
- this.set_watermark('taskcontent');
- // @TODO: refresh the list
+ this.command('user.list', {page: page});
};
this.user_save = function()
@@ -546,8 +551,7 @@ function kolab_admin()
return;
this.display_message('user.add.success');
- this.set_watermark('taskcontent');
- // @TODO: refresh the list
+ this.command('user.list', {page: this.env.list_page});
};
};
diff --git a/public_html/skins/default/ui.js b/public_html/skins/default/ui.js
index f2baa38..9a1b433 100644
--- a/public_html/skins/default/ui.js
+++ b/public_html/skins/default/ui.js
@@ -33,7 +33,10 @@ function search_init()
})
.keypress(function(e) {
if (this.value && e.which == 13) { // ENTER key
- kadm.command('user.list', {search: this.value});
+ var props = kadm.serialize_form('#search-form');
+ props.search = this.value;
+
+ kadm.command('user.list', props);
}
})
.focus(function() {
@@ -48,7 +51,7 @@ function search_reset()
input.val(kadm.t('search')).addClass('inactive');
- kadm.command('user.list');
+ kadm.command('user.list', {search: ''});
}
function search_details()
More information about the commits
mailing list