Commit be8d1398 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow user to set the number of results per page in admin search



Change-Id: Ibb88b2a68dad2816d7e9e4459b5ff54280d8f73a
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent c20c4cc3
......@@ -30,6 +30,7 @@ function UserSearch() {
self.rewriteQueryButton();
self.rewritePaging();
self.rewriteSorting();
self.rewriteSetLimit();
self.params = {};
}
......@@ -142,10 +143,27 @@ function UserSearch() {
if ($('searchresults')) {
self.rewritePaging();
self.rewriteSorting();
self.rewriteSetLimit();
}
});
}
this.rewriteSetLimit = function() {
if ($('setlimit')) {
forEach(getElementsByTagAndClassName('a', null, 'setlimit'), function(i) {
connect(i, 'onclick', function(e) {
e.stop();
if (!self.params.offset) {
self.params.offset = 0;
}
self.params.limit = scrapeText(i);
self.params.offset = Math.floor(self.params.offset / self.params.limit) * self.params.limit;
self.doSearch();
});
});
}
}
addLoadEvent(self.init);
}
......
......@@ -123,6 +123,7 @@ $string['tagupdatedsuccessfully'] = 'Tag updated successfully';
$string['tagdeletedsuccessfully'] = 'Tag deleted successfully';
$string['selfsearch'] = 'Search My Portfolio';
$string['resultsperpage'] = 'Results per page';
// Quota strings
$string['quota'] = 'Quota';
......
......@@ -314,6 +314,7 @@ function build_admin_user_search_results($search, $offset, $limit, $sortby, $sor
$smarty->assign('sortby', $sortby);
$smarty->assign('sortdir', $sortdir);
$smarty->assign('pagebaseurl', $searchurl . '&sortby=' . $sortby . '&sortdir=' . $sortdir);
$smarty->assign('limitoptions', array(10, 50, 100, 200, 500));
$smarty->assign('cols', $cols);
$smarty->assign('ncols', count($cols));
return $smarty->fetch('searchresulttable.tpl');
......
......@@ -1404,7 +1404,7 @@ a.tag {
padding: 0 5px;
vertical-align: middle;
}
.tag-results .selected, .mytags .selected {
.tag-results .selected, .mytags .selected, .setlimit a.selected {
font-weight: bold;
text-decoration: none;
}
......
{if $results.data}
<div id="setlimit" class="setlimit fr">
{str tag=resultsperpage}:
{foreach from=$limitoptions item=l}
<a href="?limit={$l}"{if $l == $results.limit} class="selected"{/if}>{$l}</a>
{/foreach}
</div>
<h2>{str tag="Results"}</h2>
<table id="searchresults" class="tablerenderer fullwidth listing">
<thead>
......
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