posts: rework post deletion to use dialog box.
Rework post deletion from using a separate page to using a dialog box, like flagging. * Add `DELETE /posts/:id` endpoint. * Remove `POST /moderator/post/posts/:id/delete` endpoint.
This commit is contained in:
5
app/views/posts/destroy.js.erb
Normal file
5
app/views/posts/destroy.js.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<% if params[:commit] == "Delete" %>
|
||||
location.reload();
|
||||
<% else %>
|
||||
Danbooru.Utility.dialog("Delete Post", "<%= j render "posts/partials/show/delete_dialog", post: @post %>");
|
||||
<% end %>
|
||||
9
app/views/posts/partials/show/_delete_dialog.html.erb
Normal file
9
app/views/posts/partials/show/_delete_dialog.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<div class="delete-post-dialog-body">
|
||||
<%= edit_form_for(post, method: :delete, remote: true) do |f| %>
|
||||
<input type="hidden" name="commit" value="Delete">
|
||||
<%= f.input :reason, as: :dtext, inline: true, input_html: { value: "" } %>
|
||||
<% if post.parent_id.present? %>
|
||||
<%= f.input :move_favorites, label: "Move favorites to parent", as: :boolean, input_html: { checked: false } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -64,7 +64,7 @@
|
||||
<li id="post-option-move-favorites"><%= link_to "Move favorites", confirm_move_favorites_moderator_post_post_path(post_id: post.id) %></li>
|
||||
<% end %>
|
||||
<% elsif policy(post).delete? %>
|
||||
<li id="post-option-delete"><%= link_to "Delete", confirm_delete_moderator_post_post_path(post_id: post.id) %></li>
|
||||
<li id="post-option-delete"><%= link_to "Delete", post, method: :delete, remote: true %></li>
|
||||
<% end %>
|
||||
|
||||
<% if post.is_approvable? && !post.is_deleted? %>
|
||||
|
||||
Reference in New Issue
Block a user