BigW Consortium Gitlab

Add sorting to public projects page

parent 8310b458
...@@ -21,6 +21,10 @@ form { ...@@ -21,6 +21,10 @@ form {
text-align: left; text-align: left;
} }
} }
&.form-tiny {
margin: 0;
}
} }
input.input-xpadding, input.input-xpadding,
......
...@@ -29,7 +29,7 @@ module Issues ...@@ -29,7 +29,7 @@ module Issues
if params[:milestone_id].present? if params[:milestone_id].present?
@issues = @issues.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) @issues = @issues.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id]))
end end
# Sort by :sort param # Sort by :sort param
@issues = sort(@issues, params[:sort]) @issues = sort(@issues, params[:sort])
...@@ -49,6 +49,5 @@ module Issues ...@@ -49,6 +49,5 @@ module Issues
else issues else issues
end end
end end
end end
end end
...@@ -8,6 +8,13 @@ class Public::ProjectsController < ApplicationController ...@@ -8,6 +8,13 @@ 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 = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) @projects = case params[: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')
when 'last_updated' then @projects.order('updated_at ASC')
else @projects.order("namespaces.path, projects.name ASC")
end
@projects = @projects.includes(:namespace).page(params[:page]).per(20)
end end
end end
.row %h3.page-title
.span6 Projects (#{@projects.total_count})
%h3.page-title .light
Projects (#{@projects.total_count}) You can browse public projects in read-only mode until signed in.
.light %hr
You can browse public projects in read-only mode until signed in. .clearfix
.pull-left
= form_tag public_projects_path, method: :get, class: 'form-inline form-tiny' do |f|
.search-holder
= search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span4 search-text-input", id: "projects_search"
= submit_tag 'Search', class: "btn btn-primary wide"
.pull-right
.dropdown.inline
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%span.light sort:
- if @sort.present?
= @sort
- else
Newest
%b.caret
%ul.dropdown-menu
%li
= link_to public_projects_path(sort: 'newest') do
Newest
= link_to public_projects_path(sort: 'oldest') do
Oldest
= link_to public_projects_path(sort: 'recently_updated') do
Recently updated
= link_to public_projects_path(sort: 'last_updated') do
Last updated
.span6
.pull-right
= form_tag public_projects_path, method: :get, class: 'form-inline' do |f|
.search-holder
= search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span3 search-text-input", id: "projects_search"
= submit_tag 'Search', class: "btn btn-primary wide"
%hr %hr
.public-projects .public-projects
%ul.bordered-list.top-list %ul.bordered-list.top-list
......
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