Commit 28ef3edd authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review
Browse files

Merge changes I7e74bdfb,Ic5ebcd43

* changes:
  Bug 1771473: tags search - filter and sort selectors update each other
  Bug 1771473: Confusion of sorting
parents be7f9f14 65696c0f
......@@ -23,7 +23,7 @@ if ($tag = param_variable('tag', null)) {
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$sort = param_alpha('sort', 'name');
$type = param_alpha('type', null);
$type = param_alpha('type', 'all');
$owner = (object) array('type' => 'user', 'id' => $USER->get('id'));
$data = get_portfolio_items_by_tag($tag, $owner, $limit, $offset, $sort, $type);
......
......@@ -4547,6 +4547,13 @@ function build_portfolio_search_html(&$data) {
$data->basejsonurl = 'json/tagsearch.php';
}
if (isset($data->sort) && $data->sort != 'name') {
$data->baseurl .= (strpos($data->baseurl, '?') ? '&' : '?') . 'sort=' . $data->sort;
}
if (isset($data->filter) && $data->filter != 'all') {
$data->baseurl .= (strpos($data->baseurl, '?') ? '&' : '?') . 'type=' . $data->filter;
}
$data->sortcols = array('name', 'date');
$data->filtercols = array(
'all' => get_string('tagfilter_all'),
......@@ -4568,7 +4575,7 @@ function build_portfolio_search_html(&$data) {
$pagination = build_pagination(array(
'id' => 'results_pagination',
'class' => 'center',
'url' => $data->baseurl . ($data->sort == 'name' ? '' : '&sort=' . $data->sort) . ($data->filter == 'all' ? '' : '&type=' . $data->filter),
'url' => $data->baseurl,
'jsonscript' => $data->basejsonurl,
'datatable' => 'results',
'count' => $data->count,
......
......@@ -159,6 +159,7 @@ jQuery(function($) {
$(this).addClass('selected');
}
});
$('#results_filter a').each(function () {rewriteTagLink(this, ['tag', 'sort'], ['type'])});
params.sort = data.data.sort;
}
......@@ -174,6 +175,7 @@ jQuery(function($) {
$('#results_filter').parent().removeClass('open');
}
});
$('#results_sort a').each(function () {rewriteTagLink(this, ['tag', 'type'], [ 'sort'])});
params.type = data.data.type;
}
......
......@@ -26,7 +26,7 @@
<div id="results_sort" class="pull-right">
<strong>{str tag=sortresultsby}</strong>
{foreach from=$results->sortcols item=sortfield name=sortcols}
<a href="{$results->baseurl}{$results->queryprefix}type={$results->filter}&sort={$sortfield}"{if $results->sort == $sortfield} class="selected"{/if}>{str tag=$sortfield}</a>{if !$.foreach.sortcols.last} <span class="sep">|</span>{/if}
<a href="{$results->baseurl}{$results->queryprefix}sort={$sortfield}"{if $results->sort == $sortfield} class="selected"{/if}>{str tag=$sortfield}</a>{if !$.foreach.sortcols.last} <span class="sep">|</span>{/if}
{/foreach}
</div>
<div class="btn-group">
......@@ -41,7 +41,7 @@
<ul class="dropdown-menu" id="results_filter">
{foreach from=$results->filtercols key=filtername item=filterdisplay name=filtercols}
<li>
<a href="{$results->baseurl}{$results->queryprefix}sort={$results->sort}&type={$filtername}"{if $results->filter == $filtername} class="selected"{/if}>{$filterdisplay}</a>
<a href="{$results->baseurl}{$results->queryprefix}type={$filtername}"{if $results->filter == $filtername} class="selected"{/if}>{$filterdisplay}</a>
</li>
{/foreach}
</ul>
......
Supports Markdown
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