Link tags after adding them through autosuggest.

This commit is contained in:
Aaron van Geffen 2019-03-09 13:22:32 +01:00
parent 20db3561cf
commit 05c48be785
3 changed files with 11 additions and 5 deletions

View File

@ -41,8 +41,9 @@ class ProvideAutoSuggest extends JSONController
$results = Tag::matchPeople($data);
foreach ($results as $id_tag => $tag)
$this->payload['items'][] = [
'label' => $tag,
'label' => $tag['tag'],
'id_tag' => $id_tag,
'url' => BASEURL . '/' . $tag['slug'] . '/',
];
}
}

View File

@ -335,8 +335,8 @@ class Tag
if (!is_array($tokens))
$tokens = explode(' ', $tokens);
return Registry::get('db')->queryPair('
SELECT id_tag, tag
return Registry::get('db')->queryPairs('
SELECT id_tag, tag, slug
FROM tags
WHERE LOWER(tag) LIKE {string:tokens} AND
kind = {string:person}

View File

@ -175,9 +175,14 @@ class PhotoPage extends SubTemplate
appendCallback: function(item) {
var request = new HttpRequest("post", "', $this->photo->getPageUrl(), '",
"id_tag=" + item.id_tag, function(response) {
var newNode = document.createElement("li");
var newLink = document.createElement("a");
newLink.href = item.url;
var newLabel = document.createTextNode(item.label);
newNode.appendChild(newLabel);
newLink.appendChild(newLabel);
var newNode = document.createElement("li");
newNode.appendChild(newLink);
var list = document.getElementById("tag_list");
list.appendChild(newNode);