Commit 58d68327 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1512528: The edit access 'Shared with' users fails to paginate



Normally it should load more options if they exist when one scrolls to
the bottom of the list, but was not working as the 'more' bits of code
were left out.

behatnotneeded: can't test a select2 that loads data via ajax yet

Change-Id: Ica89fa229e1c9c2a1e58aa7e2d73882ffb19b65e
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent f030a7b2
......@@ -47,7 +47,10 @@ while ($more && count($tmpuser) < $usersperpage) {
continue;
}
$tmpuser[] = (object) array('id' => $user['id'],
'text' => display_name($user['id']));
'text' => '<img class="select2-user-icon" src="' . get_config('wwwroot') . 'thumb.php?type=profileicon&maxwidth=40&maxheight=40&id=' . $user['id'] . '" />' .
'<span>' . display_name($user['id']) . '</span>',
'name' => display_name($user['id'])
);
}
$page++;
}
......
......@@ -195,6 +195,9 @@ $form = pieform(array(
'ajaxurl' => get_config('wwwroot') . 'module/multirecipientnotification/sendmessage.json.php',
'initfunction' => 'translate_ids_to_names',
'multiple' => true,
'extraparams' => array('escapeMarkup' => 'function (markup) { return markup; }', // let our custom formatter work
'templateSelection' => 'function (data) { console.log(data); return data.name; }'
),
'ajaxextraparams' => array(),
'rules' => array('required' => true),
),
......
......@@ -75,9 +75,13 @@ Version: 4.0.0 Timestamp: Jul 1 13:43:36 EDT 2015
.select2-results__option {
padding: 6px;
user-select: none;
-webkit-user-select: none; }
.select2-results__option[aria-selected] {
cursor: pointer; }
-webkit-user-select: none;
img {
margin: -4px 3px -4px -4px;
}
}
.select2-results__option[aria-selected] {
cursor: pointer; }
.select2-container--open .select2-dropdown {
left: 0; }
......
......@@ -164,7 +164,7 @@ jQuery(function($) {
else {
markup =
'<img class="select2-user-icon" src="' + config.wwwroot + 'thumb.php?type=profileicon&maxwidth=40&maxheight=40&id=' + data.id + '" />' +
data.firstname + ' ' + data.lastname;
'<span>' + data.name + '</span>';
}
return markup;
}
......@@ -194,7 +194,7 @@ jQuery(function($) {
'query': params.term, // search term
'offset': 0,
'limit': 10,
'page': params.page,
'page': params.page || 0,
'sesskey': config.sesskey
};
},
......@@ -207,7 +207,10 @@ jQuery(function($) {
}
return {
results: (data.message.count > 0) ? data.message.data : []
results: (data.message.count > 0) ? data.message.data : [],
pagination: {
more: data.message.more
}
};
},
cache: true
......
......@@ -20,9 +20,12 @@ require_once('searchlib.php');
$type = param_variable('type');
$query = param_variable('query', '');
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$page = param_integer('page');
$limit = 10;
if ($page < 1) {
$page = 1;
}
$offset = ($page - 1) * $limit;
switch ($type) {
case 'friend':
$data = search_user($query, $limit, $offset, array('exclude' => $USER->get('id'), 'friends' => true));
......@@ -46,7 +49,9 @@ switch ($type) {
$data = search_user($query, $limit, $offset, array('exclude' => $USER->get('id'), 'friends' => true));
break;
}
$more = $data['count'] > $limit * $page;
$data['error'] = false;
$data['message'] = '';
$data['more'] = $more;
json_reply(false, $data);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment