Added Reply Reversal And Toggle

This commit is contained in:
MrYummy
2017-05-28 17:42:39 -04:00
parent 2c02a797b8
commit db3aea185b
2 changed files with 15 additions and 5 deletions

View File

@@ -7,7 +7,11 @@ class ForumthreadsController < ApplicationController
end
def show
@replies = @thread.replies.page(params[:page])
if params[:reverse]
@replies = @thread.replies.reverse_order.page(params[:page])
else
@replies = @thread.replies.page(params[:page])
end
end
def edit
@@ -92,4 +96,4 @@ class ForumthreadsController < ApplicationController
a += add
params.require(:forumthread).permit(a)
end
end
end

View File

@@ -1,6 +1,12 @@
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%=truncate(@thread.title, length: 60, omission: " …") %>
<h1><%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %></h1>
<h1>
<%= render partial: "labels/label", locals: {label: @thread.label} %><%= title @thread.title %>
<% if params[:reverse] %>
<%= link_to "Reverse Replies", @thread, class: "btn right blue" %>
<% else %>
<%= link_to "Reverse Replies", forumthread_path(@thread, reverse: true), class: "btn right blue" %>
<% end %>
</h1>
<div class="item-group thread with-avatar" id="thread-<%= @thread.id %>">
<div class="header">
<%= link_to(@thread.author.avatar(64), @thread.author, title: @thread.author.ign) %>
@@ -44,4 +50,4 @@
<% else %>
<p>Please <%= link_to "Log in", login_path(return_path: request.env['PATH_INFO']), action: "new" %> to post a reply.</p>
<% end %>
</div>
</div>