diff --git a/app/controllers/policies_controller.rb b/app/controllers/policies_controller.rb index d3dcac551..d69f497a9 100644 --- a/app/controllers/policies_controller.rb +++ b/app/controllers/policies_controller.rb @@ -10,6 +10,8 @@ def index case @sort when "name" @policies = @policies.order(:name) + when "date" + @policies = @policies.order("updated_at DESC") else @policies = @policies.left_joins(:watches).group(:id).order("COUNT(watches.id) DESC") @sort = nil diff --git a/app/views/policies/_policies_chooser.html.haml b/app/views/policies/_policies_chooser.html.haml index d402ec9e1..a672c174a 100644 --- a/app/views/policies/_policies_chooser.html.haml +++ b/app/views/policies/_policies_chooser.html.haml @@ -3,6 +3,8 @@ %button.btn.btn-sm.btn-default.dropdown-toggle{type: "button", id: "dropdownMenu1", data: {toggle: "dropdown"}} - if @sort == "name" Sorted by Name + - elsif @sort == "date" + Sorted by Date Edited - elsif @sort.nil? Sorted by Subscribers %span.caret @@ -12,3 +14,5 @@ = link_to "Name", {sort: "name"}, title: "Sort by name", role: "menuitem", tabindex: "-1" %li{role: "presentation", class: "#{'disabled' if @sort.nil?}"} = link_to "Subscribers", {sort: nil}, title: "Sort by subscribers", role: "menuitem", tabindex: "-1" + %li{role: "presentation", class: "#{'disabled' if @sort == 'date'}"} + = link_to "Date Edited", {sort: "date"}, title: "Sort by date edited", role: "menuitem", tabindex: "-1" \ No newline at end of file diff --git a/spec/fixtures/static_pages/policies.html b/spec/fixtures/static_pages/policies.html index f7ba8e7b7..49ef74705 100644 --- a/spec/fixtures/static_pages/policies.html +++ b/spec/fixtures/static_pages/policies.html @@ -82,6 +82,9 @@