Skip to content

Commit

Permalink
WIP: gh-33, better object autocomplete box.
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffroy-noel-ddh committed Sep 1, 2023
1 parent f6ba989 commit 6d249b9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/annotator.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@
<div class="field-body">
<div class="field">
<p class="control has-icons-left">
<input class="input" type="text" placeholder="Search" v-model="searchPhrase" list="available-objects" @keyup.delete.stop>
<input class="input" type="text"
placeholder="Search" v-model="searchPhrase"
list="available-objects"
@keyup.delete.stop
@keyup.escape.stop="onEscapeObjectSearch()"
@blur="onBlurObjectSearch()"
>
<span class="icon is-left">
<i class="fas fa-search" aria-hidden="true"></i>
</span>
Expand Down
14 changes: 13 additions & 1 deletion app/assets/annotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ createApp({
}
let filteredImages = this.filteredImages
let img = this.image
console.log(img)
if (!img) {
img = filteredImages ? filteredImages[0] : null
}
Expand Down Expand Up @@ -1412,6 +1411,19 @@ createApp({
if (!this.description.tags) return;
this.description.tags = this.description.tags.filter(t => t != tag)
this.updateSelectedAnnotationFromDescription()
},
onBlurObjectSearch() {
this.resetSearchPhrase()
},
onEscapeObjectSearch() {
if (this.searchPhrase == '') {
this.resetSearchPhrase()
} else {
this.searchPhrase = ''
}
},
resetSearchPhrase() {
this.searchPhrase = this?.object?.title || ''
}
},
}).mount('#annotator');
6 changes: 6 additions & 0 deletions app/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,9 @@ br[data-tei-n="1"] {
.image-loaded-1 {
display: none;
}

#available-objects {
option {
color: red;
}
}

0 comments on commit 6d249b9

Please sign in to comment.