[autocomplete] When tag categories are enabled, show foo:bar as a completion result for bar, fixes #630
This commit is contained in:
parent
87368ac56a
commit
668e99b140
2 changed files with 10 additions and 3 deletions
|
@ -50,7 +50,10 @@ class AutoComplete extends Extension
|
|||
$limitSQL = "";
|
||||
$search = str_replace('_', '\_', $search);
|
||||
$search = str_replace('%', '\%', $search);
|
||||
$SQLarr = ["search" => "$search%"]; #, "cat_search"=>"%:$search%"];
|
||||
$SQLarr = [
|
||||
"search" => "$search%",
|
||||
"cat_search" => Extension::is_enabled(TagCategoriesInfo::KEY) ? "%:$search%" : "",
|
||||
];
|
||||
if ($limit !== 0) {
|
||||
$limitSQL = "LIMIT :limit";
|
||||
$SQLarr['limit'] = $limit;
|
||||
|
@ -62,7 +65,7 @@ class AutoComplete extends Extension
|
|||
SELECT tag, count
|
||||
FROM tags
|
||||
WHERE LOWER(tag) LIKE LOWER(:search)
|
||||
-- OR LOWER(tag) LIKE LOWER(:cat_search)
|
||||
OR LOWER(tag) LIKE LOWER(:cat_search)
|
||||
AND count > 0
|
||||
ORDER BY count DESC, tag ASC
|
||||
$limitSQL
|
||||
|
|
|
@ -95,7 +95,11 @@ function renderCompletions(element) {
|
|||
// add children for top completions, with the selected one highlighted
|
||||
let word = getCurrentWord(element);
|
||||
Object.keys(completions).filter(
|
||||
(key) => key.toLowerCase().startsWith(word.toLowerCase())
|
||||
(key) => {
|
||||
let k = key.toLowerCase();
|
||||
let w = word.toLowerCase();
|
||||
return k.split(':').some((k) => k.startsWith(w))
|
||||
}
|
||||
).slice(0, 100).forEach((key, i) => {
|
||||
let value = completions[key];
|
||||
let li = document.createElement('li');
|
||||
|
|
Reference in a new issue