diff --git a/public/js/title.js b/public/js/title.js index d46c173..6f53265 100644 --- a/public/js/title.js +++ b/public/js/title.js @@ -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(); + }); + } + } + }; +}; diff --git a/src/views/components/tags.html.ecr b/src/views/components/tags.html.ecr new file mode 100644 index 0000000..a443393 --- /dev/null +++ b/src/views/components/tags.html.ecr @@ -0,0 +1,15 @@ + +