diff --git a/client/css/post-upload.styl b/client/css/post-upload.styl index cb6b0067..9d15e218 100644 --- a/client/css/post-upload.styl +++ b/client/css/post-upload.styl @@ -15,6 +15,7 @@ $cancel-button-color = tomato &.inactive .skip-duplicates &.inactive .always-upload-similar &.inactive .pause-remain-on-error + &.inactive #common-tags, &.uploading input[type=submit], &.uploading .skip-duplicates, &.uploading .always-upload-similar @@ -30,6 +31,9 @@ $cancel-button-color = tomato small font-size: 60% + label[for=common-tags] + display: none !important + input[type=submit] margin-top: 1em diff --git a/client/html/post_upload.tpl b/client/html/post_upload.tpl index 3c1b2388..54a9871d 100644 --- a/client/html/post_upload.tpl +++ b/client/html/post_upload.tpl @@ -29,6 +29,8 @@ }) %> + <%= ctx.makeTextInput({placeholder: 'Common tags', id: 'common-tags', name: 'common-tags', style: 'margin-top:1em;'}) %> + diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js index 4ef4c1ad..ccabacf6 100644 --- a/client/js/views/post_upload_view.js +++ b/client/js/views/post_upload_view.js @@ -8,6 +8,10 @@ const FileDropperControl = require("../controls/file_dropper_control.js"); const template = views.getTemplate("post-upload"); const rowTemplate = views.getTemplate("post-upload-row"); +const misc = require('../util/misc.js'); +const TagAutoCompleteControl = + require('../controls/tag_auto_complete_control.js'); + function _mimeTypeToPostType(mimeType) { return ( { @@ -185,6 +189,16 @@ class PostUploadView extends events.EventTarget { this._evtFormSubmit(e) ); this._formNode.classList.add("inactive"); + + if (this._commonTagsInputNode) { + this._autoCompleteControl = new TagAutoCompleteControl( + this._commonTagsInputNode, + { + confirm: tag => + this._autoCompleteControl.replaceSelectedText( + misc.escapeSearchTerm(tag.names[0]), true), + }); + } } enableForm() { @@ -307,6 +321,11 @@ class PostUploadView extends events.EventTarget { } uploadable.tags = []; + if (this._commonTagsInputNode) { + var tags = this._commonTagsInputNode.value.split(' '); + tags = tags.filter(t => t != ""); + uploadable.tags = uploadable.tags.concat(tags); + } uploadable.relations = []; for (let [i, lookalike] of uploadable.lookalikes.entries()) { let lookalikeNode = rowNode.querySelector( @@ -452,6 +471,10 @@ class PostUploadView extends events.EventTarget { get _contentInputNode() { return this._formNode.querySelector(".dropper-container"); } + + get _commonTagsInputNode() { + return this._formNode.querySelector('form [name=common-tags'); + } } module.exports = PostUploadView;