Merge pull request #4259 from BrokenEagle/upload-commentary-enhancements
Add upload commentary enhancements
This commit is contained in:
@@ -63,7 +63,8 @@ class UploadsController < ApplicationController
|
||||
permitted_params = %i[
|
||||
file source tag_string rating status parent_id artist_commentary_title
|
||||
artist_commentary_desc include_artist_commentary referer_url
|
||||
md5_confirmation as_pending
|
||||
md5_confirmation as_pending translated_commentary_title
|
||||
translated_commentary_desc
|
||||
]
|
||||
|
||||
params.require(:upload).permit(permitted_params)
|
||||
|
||||
@@ -37,6 +37,11 @@ Upload.initialize_all = function() {
|
||||
Upload.toggle_commentary();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$("#toggle-commentary-translation").on("click.danbooru", function(e) {
|
||||
Upload.toggle_translation();
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
if ($("#c-uploads #a-new").length) {
|
||||
@@ -136,6 +141,17 @@ Upload.toggle_commentary = function() {
|
||||
}
|
||||
|
||||
$(".artist-commentary").slideToggle();
|
||||
$(".upload_commentary_translation_container").slideToggle();
|
||||
};
|
||||
|
||||
Upload.toggle_translation = function() {
|
||||
if ($(".commentary-translation").is(":visible")) {
|
||||
$("#toggle-commentary-translation").text("show »");
|
||||
} else {
|
||||
$("#toggle-commentary-translation").text("« hide");
|
||||
}
|
||||
|
||||
$(".commentary-translation").slideToggle();
|
||||
};
|
||||
|
||||
Upload.initialize_dropzone = function() {
|
||||
|
||||
@@ -4,6 +4,10 @@ div#c-uploads {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.commentary-translation {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
div#upload-guide-notice {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
@@ -65,10 +65,6 @@ class UploadService
|
||||
return @post.warnings.full_messages
|
||||
end
|
||||
|
||||
def include_artist_commentary?
|
||||
params[:include_artist_commentary].to_s.truthy?
|
||||
end
|
||||
|
||||
def create_post_from_upload(upload)
|
||||
@post = convert_to_post(upload)
|
||||
@post.save!
|
||||
@@ -81,10 +77,12 @@ class UploadService
|
||||
)
|
||||
end
|
||||
|
||||
if include_artist_commentary?
|
||||
if upload.include_artist_commentary
|
||||
@post.create_artist_commentary(
|
||||
:original_title => params[:artist_commentary_title],
|
||||
:original_description => params[:artist_commentary_desc]
|
||||
:original_title => upload.artist_commentary_title,
|
||||
:original_description => upload.artist_commentary_desc,
|
||||
:translated_title => upload.translated_commentary_title,
|
||||
:translated_description => upload.translated_commentary_desc
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -46,12 +46,22 @@
|
||||
<a href="#" id="toggle-artist-commentary">show »</a>
|
||||
|
||||
<div class="artist-commentary" style="display: none;">
|
||||
<%= f.input :artist_commentary_title, as: :string, label: "Title", input_html: { size: 60, value: params[:artist_commentary_title] } %>
|
||||
<%= f.input :artist_commentary_desc, as: :text, label: "Description", input_html: { size: "60x5", value: params[:artist_commentary_desc] } %>
|
||||
<%= f.input :artist_commentary_title, as: :string, label: "Original Title", input_html: { size: 60, value: params[:artist_commentary_title] } %>
|
||||
<%= f.input :artist_commentary_desc, as: :text, label: "Original Description", input_html: { size: "60x5", value: params[:artist_commentary_desc] } %>
|
||||
<%= f.input :include_artist_commentary, as: :boolean, label: "Include Commentary", input_html: { checked: params[:include_artist_commentary].present? } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input upload_commentary_translation_container" style="display: none;">
|
||||
<strong>Translation</strong>
|
||||
<a href="#" id="toggle-commentary-translation">show »</a>
|
||||
|
||||
<div class="commentary-translation" style="display: none;">
|
||||
<%= f.input :translated_commentary_title, as: :string, label: "Translated Title", input_html: { size: 60, value: params[:translated_commentary_title] } %>
|
||||
<%= f.input :translated_commentary_desc, as: :text, label: "Translated Description", input_html: { size: "60x5", value: params[:translated_commentary_desc] } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input fixed-width-container" id="tags-container">
|
||||
<div class="header">
|
||||
<%= f.label :tag_string, "Tags" %>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddMoreCommentaryToUploads < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :uploads, :translated_commentary_title, :text, null: false, default: ""
|
||||
add_column :uploads, :translated_commentary_desc, :text, null: false, default: ""
|
||||
end
|
||||
end
|
||||
@@ -3021,7 +3021,9 @@ CREATE TABLE public.uploads (
|
||||
artist_commentary_title text,
|
||||
include_artist_commentary boolean,
|
||||
context text,
|
||||
referer_url text
|
||||
referer_url text,
|
||||
translated_commentary_title text DEFAULT ''::text NOT NULL,
|
||||
translated_commentary_desc text DEFAULT ''::text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -7397,6 +7399,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20191117081229'),
|
||||
('20191117200404'),
|
||||
('20191119061018'),
|
||||
('20191223032633');
|
||||
('20191223032633'),
|
||||
('20200114204550');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user