From 77a47797d22be545d66def0d6dfc62b7c3e058be Mon Sep 17 00:00:00 2001 From: huangjingquan Date: Mon, 2 Sep 2013 15:01:20 +0800 Subject: [PATCH] =?UTF-8?q?user=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 4 ++++ app/helpers/users_helper.rb | 21 +++++++++++++++++++++ app/views/layouts/base_projects.html.erb | 8 ++++---- app/views/users/index.html.erb | 6 +++--- config/locales/en.yml | 2 +- public/stylesheets/application.css | 2 +- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 04e0b5f2b..a216033a9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -179,6 +179,7 @@ class UsersController < ApplicationController end @users = scope.offset(@offset).limit(limit).all.reverse end + @s_type = 0 # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } # @projects = @projects[@offset, @limit] when '1' @@ -192,6 +193,7 @@ class UsersController < ApplicationController end @users = scope.includes(:user_status).reorder('user_statuses.changesets_count').offset(@offset).limit(limit).all.reverse end + @s_type = 1 #sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count} #@users = @users[@offset, @limit] when '2' @@ -207,6 +209,7 @@ class UsersController < ApplicationController end #@users = @users[@offset, @limit] end + @s_type = 2 else @offset ||= @user_pages.reverse_offset unless @offset == 0 @@ -218,6 +221,7 @@ class UsersController < ApplicationController end @users = scope.offset(@offset).limit(limit).all.reverse end + @s_type = 0 # @projects = @projects.sort {|x,y| y.created_on <=> x.created_on } # @projects = @projects[@offset, @limit] end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index a9abfbc2f..d41fcb713 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -91,4 +91,25 @@ module UsersHelper content_tag('div', content, :class => "pagination") end +# added by huang +def sort_user(state) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2'))) + when 1 + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0'))) + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2'))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0'))) + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2'), :class=>"selected"), :class=>"selected") + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end +#end end diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 95744e44d..db80b0071 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -61,10 +61,10 @@ <%=link_to files_count, project_files_path(@project) %> - <%= l(:label_member) %> - <%= l(:label_user_watcher) %> - <%= l(:label_project_issues) %> - <%= l(:label_attachment) %> + <%= l(:label_member) %> + <%= l(:label_user_watcher) %> + <%= l(:label_project_issues) %> + <%= l(:label_attachment) %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index b13639877..82288143d 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -84,9 +84,9 @@ <% end %> -  +<%= sort_user(@s_type)%> -