Unverified Commit 7458437e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Improve sorting for public projects page


Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent aba544a77f01
......@@ -8,7 +8,8 @@ class Public::ProjectsController < ApplicationController
def index
@projects = Project.public_or_internal_only(current_user)
@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 'oldest' then @projects.order('created_at ASC')
when 'recently_updated' then @projects.order('updated_at DESC')
......
......@@ -15,12 +15,14 @@
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%span.light sort:
- if @sort.present?
= @sort
= @sort.humanize
- else
Newest
Name
%b.caret
%ul.dropdown-menu
%li
= link_to public_projects_path(sort: nil) do
Name
= link_to public_projects_path(sort: 'newest') do
Newest
= link_to public_projects_path(sort: 'oldest') do
......
Supports Markdown
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