posts: rework post events page.

* Add a global /post_events page that shows the history of all approvals,
  disapprovals, flags, appeals, and replacements on a single page.

* Redesign the /posts/:id/events page to show all approval, disapproval,
  flag, appeal, and replacement events for a single post (before it only
  showed approvals, flags, and appeals).

* Remove the replacement history link from the post show page. Replacements
  are now included in the post events page (closes #4948: Highlighed replacements).

* Add /post_approvals/:id and /post_replacements/:id routes (these are
  used by the "Details" link on the post events page).
This commit is contained in:
evazion
2022-09-24 17:41:23 -05:00
parent fc122cbc5a
commit 361af6a4cb
26 changed files with 455 additions and 201 deletions

View File

@@ -15,4 +15,12 @@ class PostApprovalsController < ApplicationController
respond_with(@post_approvals)
end
def show
@approval = authorize PostApproval.find(params[:id])
respond_with(@approval) do |format|
format.html { redirect_to post_approvals_path(search: { id: @approval.id }) }
end
end
end

View File

@@ -4,7 +4,13 @@ class PostEventsController < ApplicationController
respond_to :html, :xml, :json
def index
@events = PostEvent.find_for_post(params[:post_id])
respond_with(@events)
if post_id = params[:post_id] || params.dig(:search, :post_id)
@post = Post.find(post_id)
end
@post_events = authorize PostEvent.paginated_search(params, defaults: { post_id: @post&.id }, count_pages: @post.present?)
@post_events = @post_events.includes(:creator, :post, model: [:post]) if request.format.html?
respond_with(@post_events)
end
end

View File

@@ -35,4 +35,12 @@ class PostReplacementsController < ApplicationController
respond_with(@post_replacements)
end
def show
@post_replacement = authorize PostReplacement.find(params[:id])
respond_with(@post_replacement) do |format|
format.html { redirect_to post_replacements_path(search: { id: @post_replacement.id }) }
end
end
end