aboutsummaryrefslogtreecommitdiff
path: root/client/js/views/post_upload_view.js
diff options
context:
space:
mode:
authorHunternif2019-04-08 00:10:11 +0700
committerHunternif2019-04-08 01:24:50 +0700
commit035ce19788626c007619c004ef3b702f70ac262e (patch)
tree6810c2161a8efca2ce2b2ca02921ae525ab30d35 /client/js/views/post_upload_view.js
parentc6ab097887e7f727a104941b6041335fae9dcd41 (diff)
Set common tags for all uploads, with auto-completion
Diffstat (limited to 'client/js/views/post_upload_view.js')
-rw-r--r--client/js/views/post_upload_view.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/client/js/views/post_upload_view.js b/client/js/views/post_upload_view.js
index b4d0c40..f55b635 100644
--- a/client/js/views/post_upload_view.js
+++ b/client/js/views/post_upload_view.js
@@ -7,6 +7,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 {
'application/x-shockwave-flash': 'flash',
@@ -171,6 +175,16 @@ class PostUploadView extends events.EventTarget {
'click', e => this._evtCancelButtonClick(e));
this._formNode.addEventListener('submit', e => 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() {
@@ -294,6 +308,12 @@ 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(
@@ -401,6 +421,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;

© 2015 - 2026 Jakob L. Kreuze