Skip to content

Commit

Permalink
feat(search): made the tag selection aside sitcky, so it is always vi…
Browse files Browse the repository at this point in the history
…sible when user scrolls down the list of annotations. gh-74
  • Loading branch information
geoffroy-noel-ddh committed Oct 1, 2024
1 parent 74b8c9e commit 20046f6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
19 changes: 19 additions & 0 deletions app/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,25 @@ div[data-tei-subtype='section'] .textpart-number:before {
.annotation-preview .tags span {
margin-left: 0.1em;
}

.selection .tags-selector img {
margin-left: 0.5em;
}
.selection .tags-selector {
max-height: 39%;
overflow: auto;
}
.selection .tags-selector label {
display: block;
}
.selection .tags-selector label:hover {
background-color: var(--hover-color);
}
.selection {
position: sticky;
display: inline-block;
top: 0;
bottom: 0;
overflow-y: auto;
max-height: 90vh;
}
23 changes: 23 additions & 0 deletions app/assets/search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ createApp({
total: 0
}
},
tagSelection() {
let ret = ''
let stats = [0, 0]

for (let state of Object.values(this.definitions.tags)) {
if (state === false) stats[1]++;
if (state === true) stats[0]++;
}

if (stats[0]) {
ret += `+${stats[0]}`
}
if (stats[1]) {
if (ret) ret += ', ';
ret += `-${stats[1]}`
}

if (ret) {
ret = `(${ret})`
}

return ret
},
lastMessage() {
let ret = {
content: '',
Expand Down
22 changes: 10 additions & 12 deletions app/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,22 @@ <h2 class="title is-3">Annotations ({{ pagination.total }})</h2>
<h2 class="title is-3">Bulk edit ({{ selection.items.size }})
<button @click.prevent.stop="saveChangeQueue()" class="button is-primary" :disabled="!canEdit || !isUnsaved">Save</button>
</h2>
<h3 class="title is-4">Tags:</h3>
<h3 class="title is-4">Tags {{ tagSelection }}:</h3>
<ul class="tags-selector">
<li v-for="state, tag in definitions.tags">
<label @click.stop.prevent="onClickTag(tag)" :class="`state-${state}`"><input type="checkbox" :checked="state === true" :disabled="state === null"> {{ tag }}</label>
<img :src="getThumbUrlFromTag(tag, 40)" alt="annotation thumbnail" class="graph-thumb" v-if="getThumbUrlFromTag(tag, 40)">
</li>
<li>
<div class="field has-addons">
<div class="control">
<input :class="{input: 1, 'is-danger': tagFormatError}" type="text" v-model="selection.newTagName" @keyup.enter="onAddTag()">
</div>
<div class="control">
<button class="button" @click="onAddTag()" :disabled="!canEdit || Boolean(tagFormatError) || !(selection.newTagName || '').trim()">Add</button>
</div>
</div>
<div class="tag-error" v-if="tagFormatError">{{tagFormatError}}</div>
</li>
</ul>
<div class="field has-addons">
<div class="control">
<input :class="{input: 1, 'is-danger': tagFormatError}" type="text" v-model="selection.newTagName" @keyup.enter="onAddTag()">
</div>
<div class="control">
<button class="button" @click="onAddTag()" :disabled="!canEdit || Boolean(tagFormatError) || !(selection.newTagName || '').trim()">Add</button>
</div>
</div>
<div class="tag-error" v-if="tagFormatError">{{tagFormatError}}</div>
<p>
<br>
<a href="https://github.com/kingsdigitallab/crossreads/blob/main/annotations/change-queue.json" target="_blank">{{ changeQueue?.changes?.length || 'no' }} change(s)</a> pending.
Expand Down

0 comments on commit 20046f6

Please sign in to comment.