Make items in the autocomplete list clickable

next v0.7.2
neobooru 2021-06-28 17:05:42 +02:00
parent 71f81f1c5e
commit 85d9d875a1
2 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "szuru-chrome",
"version": "0.7.1",
"version": "0.7.2",
"description": "Import media from various sites into szurubooru.",
"author": "neobooru",
"license": "MIT",

View File

@ -61,6 +61,7 @@
<div class="autocomplete-items" v-bind:class="{ show: autocompleteShown }">
<div
v-for="(tag, idx) in autocompleteTags"
@click="onClickAutocompleteTagItem(tag)"
:key="tag.name"
:class="{
active: idx == autocompleteIndex,
@ -324,6 +325,9 @@ export default Vue.extend({
// Only add tag if it doesn't already exist
if (tag.name.length > 0 && this.selectedPost.tags.find((x) => x.name == tag.name) == undefined) {
this.selectedPost.tags.push(tag);
// Add implications for the tag
this.selectedPost.tags.push(...tag.implications);
}
}
},
@ -416,12 +420,14 @@ export default Vue.extend({
const tagToAdd = this.autocompleteTags[this.autocompleteIndex];
this.addTag(tagToAdd);
this.addTagInput = ""; // Reset input
// Add implications for the tag
tagToAdd.implications.forEach(this.addTag);
}
}
},
onClickAutocompleteTagItem(tag: TagViewModel) {
this.addTag(tag);
this.addTagInput = ""; // Reset input
this.autocompleteShown = false; // Hide autocomplete list
},
async autoCompletePopulator(input: string) {
// Based on https://www.w3schools.com/howto/howto_js_autocomplete.asp
// TODO: Put this in a separate component