artist commentary form: add partial_commentary checkbox.

Add a checkbox for adding/removing the partial_commentary tag in the
artist commentary form.

ref: https://danbooru.donmai.us/forum_topics/15101.
This commit is contained in:
evazion
2018-04-29 22:05:59 -05:00
parent 21431892e8
commit 7e99a1b38b
3 changed files with 28 additions and 4 deletions

View File

@@ -40,8 +40,8 @@ private
def commentary_params
params.fetch(:artist_commentary, {}).except(:post_id).permit(%i[
original_description original_title translated_description translated_title
remove_commentary_tag remove_commentary_request_tag remove_commentary_check_tag
add_commentary_tag add_commentary_request_tag add_commentary_check_tag
remove_commentary_tag remove_commentary_request_tag remove_commentary_check_tag remove_partial_commentary_tag
add_commentary_tag add_commentary_request_tag add_commentary_check_tag add_partial_commentary_tag
])
end
end

View File

@@ -1,8 +1,8 @@
class ArtistCommentary < ApplicationRecord
class RevertError < Exception ; end
attr_accessor :remove_commentary_tag, :remove_commentary_request_tag, :remove_commentary_check_tag
attr_accessor :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag
attr_accessor :remove_commentary_tag, :remove_commentary_request_tag, :remove_commentary_check_tag, :remove_partial_commentary_tag
attr_accessor :add_commentary_tag, :add_commentary_request_tag, :add_commentary_check_tag, :add_partial_commentary_tag
before_validation :trim_whitespace
validates_uniqueness_of :post_id
belongs_to :post, required: true
@@ -108,6 +108,14 @@ class ArtistCommentary < ApplicationRecord
post.add_tag("check_commentary")
end
if remove_partial_commentary_tag == "1"
post.remove_tag("partial_commentary")
end
if add_partial_commentary_tag == "1"
post.add_tag("partial_commentary")
end
post.save if post.tag_string_changed?
end

View File

@@ -80,4 +80,20 @@
</label>
</div>
<% end %>
<% if post.has_tag?("partial_commentary") %>
<div class="input">
<label>
<%= check_box :artist_commentary, :remove_partial_commentary_tag %>
Remove <em>partial_commentary</em> tag
</label>
</div>
<% else %>
<div class="input">
<label>
<%= check_box :artist_commentary, :add_partial_commentary_tag %>
Add <em>partial_commentary</em> tag
</label>
</div>
<% end %>
<% end %>