Fixed tag autocompletion
It yielded too many results in some cases.
This commit is contained in:
parent
e346a8e57c
commit
24f5024db3
2 changed files with 7 additions and 6 deletions
|
@ -158,6 +158,7 @@ $(function()
|
||||||
source: function(request, response)
|
source: function(request, response)
|
||||||
{
|
{
|
||||||
var term = extractLast(request.term);
|
var term = extractLast(request.term);
|
||||||
|
if (term != '')
|
||||||
$.get(searchInput.attr('data-autocomplete-url') + '?json', {filter: term}, function(data)
|
$.get(searchInput.attr('data-autocomplete-url') + '?json', {filter: term}, function(data)
|
||||||
{
|
{
|
||||||
response($.map(data.tags, function(tag) { return { label: tag, value: tag }; }));
|
response($.map(data.tags, function(tag) { return { label: tag, value: tag }; }));
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TagController
|
||||||
$dbQuery->from('tag');
|
$dbQuery->from('tag');
|
||||||
$dbQuery->innerJoin('post_tag');
|
$dbQuery->innerJoin('post_tag');
|
||||||
$dbQuery->on('tag.id = post_tag.tag_id');
|
$dbQuery->on('tag.id = post_tag.tag_id');
|
||||||
if ($suppliedFilter)
|
if ($suppliedFilter !== null)
|
||||||
{
|
{
|
||||||
if (strlen($suppliedFilter) >= 3)
|
if (strlen($suppliedFilter) >= 3)
|
||||||
$suppliedFilter = '%' . $suppliedFilter;
|
$suppliedFilter = '%' . $suppliedFilter;
|
||||||
|
@ -26,7 +26,7 @@ class TagController
|
||||||
}
|
}
|
||||||
$dbQuery->groupBy('tag.id');
|
$dbQuery->groupBy('tag.id');
|
||||||
$dbQuery->orderBy('LOWER(tag.name)')->asc();
|
$dbQuery->orderBy('LOWER(tag.name)')->asc();
|
||||||
if ($suppliedFilter)
|
if ($suppliedFilter !== null)
|
||||||
$dbQuery->limit(15);
|
$dbQuery->limit(15);
|
||||||
$rows = $dbQuery->get();
|
$rows = $dbQuery->get();
|
||||||
$tags = R::convertToBeans('tag', $rows);
|
$tags = R::convertToBeans('tag', $rows);
|
||||||
|
|
Loading…
Reference in a new issue