add chronological and random sorting

This commit is contained in:
Andrew Brown 2020-10-01 17:18:04 -07:00
parent d4fe136498
commit 35c248a419
2 changed files with 12 additions and 2 deletions

View File

@ -173,6 +173,8 @@ class PageCollectionsController < ApplicationController
@pages = @pages.reorder('cached_content_name ASC')
when 'chronological'
@pages = @pages.reorder('accepted_at ASC')
when 'shuffle'
@pages = @pages.shuffle
when 'recent'
@pages = @pages.reorder('accepted_at DESC')
when nil

View File

@ -5,12 +5,20 @@
Trending
<% end %>
-->
<%= link_to params.permit(:sort).merge({sort: 'alphabetical'}), class: 'btn btn-flat' do %>
<%= link_to params.permit(:sort).merge({sort: 'alphabetical'}), class: 'btn btn-flat tooltipped', data: { tooltip: "Show pages in this collection alphabetically, by name" } do %>
<i class="material-icons left">sort</i>
Alphabetical
<% end %>
<%= link_to params.permit(:sort).merge({sort: 'recent'}), class: 'btn btn-flat' do %>
<%= link_to params.permit(:sort).merge({sort: 'chronological'}), class: 'btn btn-flat tooltipped', data: { tooltip: "Show pages in this collection in the order they were added" } do %>
<i class="material-icons left">sort</i>
Chronological
<% end %>
<%= link_to params.permit(:sort).merge({sort: 'recent'}), class: 'btn btn-flat tooltipped', data: { tooltip: "Sort pages in this collection most-recently-added-first" } do %>
<i class="material-icons left">sort</i>
Recently added
<% end %>
<%= link_to params.permit(:sort).merge({sort: 'shuffle'}), class: 'btn btn-flat tooltipped', data: { tooltip: "Show pages in this collection in a random order" } do %>
<i class="material-icons left">sort</i>
Shuffle
<% end %>
</div>