This commit is contained in:
Neo 2024-11-22 05:22:17 +00:00 committed by GitHub
commit a78a0e6ec5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 108 additions and 44 deletions

View file

@ -19,7 +19,7 @@
font-size: 1em font-size: 1em
color: $inactive-link-color color: $inactive-link-color
float: right float: right
line-height: 2em line-height: 2rem
.expander-content .expander-content
padding: 0.5em 0.5em 2em 0.5em padding: 0.5em 0.5em 2em 0.5em

View file

@ -15,13 +15,22 @@ $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 .upload-all-anonymous
&.inactive .expander
&.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
&.uploading .pause-remain-on-error &.uploading .pause-remain-on-error
&.uploading .upload-all-anonymous
&.uploading .expander
&:not(.uploading) .cancel &:not(.uploading) .cancel
display: none display: none
&.inactive .control-strip
&.uploading .control-strip
gap: 0
.dropper-container .dropper-container
margin: 0 auto margin: 0 auto
.file-dropper .file-dropper
@ -30,28 +39,36 @@ $cancel-button-color = tomato
small small
font-size: 60% font-size: 60%
input[type=submit] .expander
margin-top: 1em &.collapsed
margin-bottom: 0
.expander-content
padding: 0.5em
.cancel .cancel
margin-top: 1em
background: $cancel-button-color background: $cancel-button-color
border-color: $cancel-button-color border-color: $cancel-button-color
&:focus &:focus
border: 2px solid $text-color border: 2px solid $text-color
.skip-duplicates
margin-left: 1em
.always-upload-similar
margin-left: 1em
.pause-remain-on-error
margin-left: 1em
form>.messages form>.messages
margin-top: 1em margin-top: 1em
.control-strip
display: flex
flex-direction: column
gap: 1em
margin-top: 1em
.control-options
display: flex
flex-wrap: wrap
gap: 0 1em
span
flex: 1 1 30%
white-space: nowrap
.uploadables-container .uploadables-container
list-style-type: none list-style-type: none
margin: 0 margin: 0

View file

@ -3,8 +3,7 @@
<div class='dropper-container'></div> <div class='dropper-container'></div>
<div class='control-strip'> <div class='control-strip'>
<input type='submit' value='Upload all' class='submit'/> <div class='control-options'>
<span class='skip-duplicates'> <span class='skip-duplicates'>
<%= ctx.makeCheckbox({ <%= ctx.makeCheckbox({
text: 'Skip duplicate', text: 'Skip duplicate',
@ -29,6 +28,20 @@
}) %> }) %>
</span> </span>
<span class='upload-all-anonymous'>
<%= ctx.makeCheckbox({
text: 'Upload anonymously',
name: 'upload-all-anonymous',
checked: false,
}) %>
</span>
</div>
<section class='common-tags'>
<%= ctx.makeTextInput({name: 'common-tags'}) %>
</section>
<input type='submit' value='Upload all' class='submit'/>
<input type='button' value='Cancel' class='cancel'/> <input type='button' value='Cancel' class='cancel'/>
</div> </div>

View file

@ -81,7 +81,7 @@ function makeCheckbox(options) {
name: options.name, name: options.name,
value: options.value, value: options.value,
type: "checkbox", type: "checkbox",
checked: options.checked !== undefined ? options.checked : false, checked: options.checked !== undefined && options.checked !== null ? options.checked : false,
disabled: options.readonly, disabled: options.readonly,
required: options.required, required: options.required,
}), }),

View file

@ -4,10 +4,14 @@ const events = require("../events.js");
const api = require("../api.js"); const api = require("../api.js");
const views = require("../util/views.js"); const views = require("../util/views.js");
const FileDropperControl = require("../controls/file_dropper_control.js"); const FileDropperControl = require("../controls/file_dropper_control.js");
const ExpanderControl = require("../controls/expander_control.js");
const TagInputControl = require("../controls/tag_input_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 TagList = require("../models/tag_list.js");
function _mimeTypeToPostType(mimeType) { function _mimeTypeToPostType(mimeType) {
return ( return (
{ {
@ -160,6 +164,7 @@ class PostUploadView extends events.EventTarget {
this._uploadables.find = (u) => { this._uploadables.find = (u) => {
return this._uploadables.findIndex((u2) => u.key === u2.key); return this._uploadables.findIndex((u2) => u.key === u2.key);
}; };
this._commonTags = new TagList();
this._contentFileDropper = new FileDropperControl( this._contentFileDropper = new FileDropperControl(
this._contentInputNode, this._contentInputNode,
@ -185,6 +190,23 @@ class PostUploadView extends events.EventTarget {
this._evtFormSubmit(e) this._evtFormSubmit(e)
); );
this._formNode.classList.add("inactive"); this._formNode.classList.add("inactive");
this._commonTagsExpander = new ExpanderControl(
"common-tags",
"Common Tags (0)",
this._hostNode.querySelectorAll(".common-tags")
);
if (this._commonTagsInputNode) {
this._commonTagsControl = new TagInputControl(
this._commonTagsInputNode,
this._commonTags
);
this._commonTagsControl.addEventListener("change", (_) => {
this._commonTagsExpander.title = `Common Tags (${this._commonTags.length})`;
});
}
} }
enableForm() { enableForm() {
@ -299,14 +321,16 @@ class PostUploadView extends events.EventTarget {
uploadable.safety = safetyNode.value; uploadable.safety = safetyNode.value;
} }
const anonymousNode = rowNode.querySelector( let anonymous = this._uploadAllAnonymous.checked;
".anonymous input:checked" if (!anonymous && rowNode.querySelector(".anonymous input:checked")) {
); anonymous = true;
if (anonymousNode) {
uploadable.anonymous = true;
} }
uploadable.anonymous = anonymous;
uploadable.tags = []; uploadable.tags = [];
if (this._commonTagsInputNode) {
uploadable.tags = this._commonTags.map((tag) => tag.names[0]);
}
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(
@ -441,6 +465,12 @@ class PostUploadView extends events.EventTarget {
); );
} }
get _uploadAllAnonymous() {
return this._hostNode.querySelector(
"form [name=upload-all-anonymous]"
);
}
get _submitButtonNode() { get _submitButtonNode() {
return this._hostNode.querySelector("form [type=submit]"); return this._hostNode.querySelector("form [type=submit]");
} }
@ -452,6 +482,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(".common-tags input");
}
} }
module.exports = PostUploadView; module.exports = PostUploadView;