client: Use expanders and full tag input control on the upload page
This commit is contained in:
parent
d17d37ceb0
commit
66143dce20
4 changed files with 46 additions and 38 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -16,15 +16,21 @@ $cancel-button-color = tomato
|
||||||
&.inactive .always-upload-similar
|
&.inactive .always-upload-similar
|
||||||
&.inactive .pause-remain-on-error
|
&.inactive .pause-remain-on-error
|
||||||
&.inactive .upload-all-anonymous
|
&.inactive .upload-all-anonymous
|
||||||
|
&.inactive .expander
|
||||||
&.inactive #common-tags,
|
&.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 .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
|
||||||
|
@ -33,42 +39,35 @@ $cancel-button-color = tomato
|
||||||
small
|
small
|
||||||
font-size: 60%
|
font-size: 60%
|
||||||
|
|
||||||
label[for=common-tags]
|
.expander
|
||||||
display: none !important
|
&.collapsed
|
||||||
|
margin-bottom: 0
|
||||||
input[type=submit]
|
.expander-content
|
||||||
margin-top: 1em
|
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
|
|
||||||
|
|
||||||
.upload-all-anonymous
|
|
||||||
margin-left: 1em
|
|
||||||
|
|
||||||
form>.messages
|
form>.messages
|
||||||
margin-top: 1em
|
margin-top: 1em
|
||||||
|
|
||||||
.control-strip
|
.control-strip
|
||||||
display: flex
|
display: flex
|
||||||
flex-direction: column
|
flex-direction: column
|
||||||
gap: 0.5em
|
gap: 1em
|
||||||
|
margin-top: 1em
|
||||||
|
|
||||||
.control-options
|
.control-options
|
||||||
display: flex
|
display: flex
|
||||||
flex-direction: column
|
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
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
<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'>
|
<div class='control-options'>
|
||||||
<span class='skip-duplicates'>
|
<span class='skip-duplicates'>
|
||||||
<%= ctx.makeCheckbox({
|
<%= ctx.makeCheckbox({
|
||||||
|
@ -39,8 +37,11 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= ctx.makeTextInput({placeholder: 'Common tags', id: 'common-tags', name: 'common-tags'}) %>
|
<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>
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ 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 misc = require('../util/misc.js');
|
const TagList = require("../models/tag_list.js");
|
||||||
const TagAutoCompleteControl =
|
|
||||||
require('../controls/tag_auto_complete_control.js');
|
|
||||||
|
|
||||||
function _mimeTypeToPostType(mimeType) {
|
function _mimeTypeToPostType(mimeType) {
|
||||||
return (
|
return (
|
||||||
|
@ -164,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,
|
||||||
|
@ -190,13 +191,20 @@ class PostUploadView extends events.EventTarget {
|
||||||
);
|
);
|
||||||
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) {
|
if (this._commonTagsInputNode) {
|
||||||
this._autoCompleteControl = new TagAutoCompleteControl(
|
this._commonTagsControl = new TagInputControl(
|
||||||
this._commonTagsInputNode,
|
this._commonTagsInputNode,
|
||||||
{
|
this._commonTags
|
||||||
confirm: tag =>
|
);
|
||||||
this._autoCompleteControl.replaceSelectedText(
|
|
||||||
misc.escapeSearchTerm(tag.names[0]), true),
|
this._commonTagsControl.addEventListener("change", (_) => {
|
||||||
|
this._commonTagsExpander.title = `Common Tags (${this._commonTags.length})`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,9 +329,7 @@ class PostUploadView extends events.EventTarget {
|
||||||
|
|
||||||
uploadable.tags = [];
|
uploadable.tags = [];
|
||||||
if (this._commonTagsInputNode) {
|
if (this._commonTagsInputNode) {
|
||||||
var tags = this._commonTagsInputNode.value.split(' ');
|
uploadable.tags = this._commonTags.map((tag) => tag.names[0]);
|
||||||
tags = tags.filter(t => t != "").map(t => t.replace('\\', ''));
|
|
||||||
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()) {
|
||||||
|
@ -460,7 +466,9 @@ class PostUploadView extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
get _uploadAllAnonymous() {
|
get _uploadAllAnonymous() {
|
||||||
return this._hostNode.querySelector("form [name=upload-all-anonymous]");
|
return this._hostNode.querySelector(
|
||||||
|
"form [name=upload-all-anonymous]"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get _submitButtonNode() {
|
get _submitButtonNode() {
|
||||||
|
@ -476,7 +484,7 @@ class PostUploadView extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
get _commonTagsInputNode() {
|
get _commonTagsInputNode() {
|
||||||
return this._formNode.querySelector('form [name=common-tags]');
|
return this._formNode.querySelector(".common-tags input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue