Default upload tags

This commit is contained in:
Fabricio Winter 2022-12-30 13:07:34 -03:00 committed by neobooru
parent f90c190baf
commit 881cfe026c
3 changed files with 29 additions and 0 deletions

View file

@ -15,6 +15,7 @@ $cancel-button-color = tomato
&.inactive .skip-duplicates &.inactive .skip-duplicates
&.inactive .always-upload-similar &.inactive .always-upload-similar
&.inactive .pause-remain-on-error &.inactive .pause-remain-on-error
&.inactive #common-tags,
&.uploading input[type=submit], &.uploading input[type=submit],
&.uploading .skip-duplicates, &.uploading .skip-duplicates,
&.uploading .always-upload-similar &.uploading .always-upload-similar
@ -30,6 +31,9 @@ $cancel-button-color = tomato
small small
font-size: 60% font-size: 60%
label[for=common-tags]
display: none !important
input[type=submit] input[type=submit]
margin-top: 1em margin-top: 1em

View file

@ -29,6 +29,8 @@
}) %> }) %>
</span> </span>
<%= ctx.makeTextInput({placeholder: 'Common tags', id: 'common-tags', name: 'common-tags', style: 'margin-top:1em;'}) %>
<input type='button' value='Cancel' class='cancel'/> <input type='button' value='Cancel' class='cancel'/>
</div> </div>

View file

@ -8,6 +8,10 @@ const FileDropperControl = require("../controls/file_dropper_control.js");
const template = views.getTemplate("post-upload"); const template = views.getTemplate("post-upload");
const rowTemplate = views.getTemplate("post-upload-row"); 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) { function _mimeTypeToPostType(mimeType) {
return ( return (
{ {
@ -185,6 +189,16 @@ class PostUploadView extends events.EventTarget {
this._evtFormSubmit(e) this._evtFormSubmit(e)
); );
this._formNode.classList.add("inactive"); 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() { enableForm() {
@ -307,6 +321,11 @@ class PostUploadView extends events.EventTarget {
} }
uploadable.tags = []; uploadable.tags = [];
if (this._commonTagsInputNode) {
var tags = this._commonTagsInputNode.value.split(' ');
tags = tags.filter(t => t != "");
uploadable.tags = uploadable.tags.concat(tags);
}
uploadable.relations = []; uploadable.relations = [];
for (let [i, lookalike] of uploadable.lookalikes.entries()) { for (let [i, lookalike] of uploadable.lookalikes.entries()) {
let lookalikeNode = rowNode.querySelector( let lookalikeNode = rowNode.querySelector(
@ -452,6 +471,10 @@ class PostUploadView extends events.EventTarget {
get _contentInputNode() { get _contentInputNode() {
return this._formNode.querySelector(".dropper-container"); return this._formNode.querySelector(".dropper-container");
} }
get _commonTagsInputNode() {
return this._formNode.querySelector('form [name=common-tags');
}
} }
module.exports = PostUploadView; module.exports = PostUploadView;