Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default upload tags and anonymous uploads #534

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Default upload tags
  • Loading branch information
Fabricio20 committed Dec 30, 2022
commit 9f569f76b1b264296d4b96f0df1198ec4d03b037
4 changes: 4 additions & 0 deletions client/css/post-upload.styl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions client/html/post_upload.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
}) %>
</span>

<%= ctx.makeTextInput({placeholder: 'Common tags', id: 'common-tags', name: 'common-tags', style: 'margin-top:1em;'}) %>

<input type='button' value='Cancel' class='cancel'/>
</div>

Expand Down
23 changes: 23 additions & 0 deletions client/js/views/post_upload_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
{
Expand Down Expand Up @@ -183,6 +187,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() {
Expand Down Expand Up @@ -305,6 +319,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(
Expand Down Expand Up @@ -450,6 +469,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;