Add tags to the web UI

This commit is contained in:
Alex Ling
2020-12-30 05:35:28 +00:00
parent a6862e86d4
commit 40a24f4247
3 changed files with 47 additions and 0 deletions

View File

@@ -252,3 +252,33 @@ const bulkProgress = (action, el) => {
deselectAll();
});
};
const tagsComponent = () => {
return {
tags: tags,
newTag: '',
inputShown: false,
add() {
this.tags.push(this.newTag);
this.newTag = '';
},
keydown(event) {
if (event.key === 'Enter')
this.add()
},
rm(event) {
const tag = event.currentTarget.id.split('-')[0];
const idx = this.tags.indexOf(tag);
if (idx < 0) return;
this.tags.splice(idx, 1);
},
toggleInput(nextTick) {
this.inputShown = !this.inputShown;
if (this.inputShown) {
nextTick(() => {
$('#tag-input').get(0).focus();
});
}
}
};
};