BigW Consortium Gitlab

Improve sorting for public projects page

parent 6a0c0f3f
...@@ -8,7 +8,8 @@ class Public::ProjectsController < ApplicationController ...@@ -8,7 +8,8 @@ class Public::ProjectsController < ApplicationController
def index def index
@projects = Project.public_or_internal_only(current_user) @projects = Project.public_or_internal_only(current_user)
@projects = @projects.search(params[:search]) if params[:search].present? @projects = @projects.search(params[:search]) if params[:search].present?
@projects = case params[:sort] @sort = params[:sort]
@projects = case @sort
when 'newest' then @projects.order('created_at DESC') when 'newest' then @projects.order('created_at DESC')
when 'oldest' then @projects.order('created_at ASC') when 'oldest' then @projects.order('created_at ASC')
when 'recently_updated' then @projects.order('updated_at DESC') when 'recently_updated' then @projects.order('updated_at DESC')
......
...@@ -15,12 +15,14 @@ ...@@ -15,12 +15,14 @@
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%span.light sort: %span.light sort:
- if @sort.present? - if @sort.present?
= @sort = @sort.humanize
- else - else
Newest Name
%b.caret %b.caret
%ul.dropdown-menu %ul.dropdown-menu
%li %li
= link_to public_projects_path(sort: nil) do
Name
= link_to public_projects_path(sort: 'newest') do = link_to public_projects_path(sort: 'newest') do
Newest Newest
= link_to public_projects_path(sort: 'oldest') do = link_to public_projects_path(sort: 'oldest') do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment