From c4df893eab1614f5f0219bb1ce8ffe79642e1200 Mon Sep 17 00:00:00 2001 From: huangjingquan Date: Mon, 2 Sep 2013 12:49:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86tabs=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 4 + app/controllers/projects_controller.rb | 8 ++ app/helpers/bids_helper.rb | 14 ++ app/helpers/projects_helper.rb | 22 +++ app/views/bids/index.html.erb | 8 +- app/views/projects/index.html.erb | 13 +- public/stylesheets/application.css | 134 ++++++++++++++---- .../stylesheets/application.css | 5 + 8 files changed, 172 insertions(+), 36 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index e5af4ac85..b245e9037 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -34,6 +34,7 @@ class BidsController < ApplicationController limit = @bid_count % @limit @bids = @bids.offset(@offset).limit(limit).all.reverse end + @s_state = 0 when '1' unless @offset == 0 @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse @@ -41,6 +42,7 @@ class BidsController < ApplicationController limit = @bid_count % @limit @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse end + @s_state = 1 when '2' unless @offset == 0 @bids = @bids.offset(@offset).limit(@limit).all.reverse @@ -48,6 +50,7 @@ class BidsController < ApplicationController limit = @bid_count % @limit @bids = @bids.offset(@offset).limit(@limit).all.reverse end + @s_state = 0 end else unless @offset == 0 @@ -56,6 +59,7 @@ class BidsController < ApplicationController limit = @bid_count % @limit @bids = @bids.offset(@offset).limit(limit).all.reverse end + @s_state = 0 end #end # @limit = api_offset_and_limit({:limit => 5}) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f8b4f926b..d9ead306d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -19,6 +19,9 @@ class ProjectsController < ApplicationController menu_item :overview menu_item :roadmap, :only => :roadmap menu_item :settings, :only => :settings + menu_item l(:label_sort_by_time), :only => :index + menu_item l(:label_sort_by_active), :only => :index + menu_item l(:label_sort_by_influence), :only => :index before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ] before_filter :authorize, :except => [:watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback, :project_respond] @@ -104,6 +107,7 @@ class ProjectsController < ApplicationController @project_pages = Paginator.new @project_count, @limit, params['page'] @offset ||= @project_pages.reverse_offset + #@projects = @projects.offset(@offset).limit(@limit).order('created_on DESC').all if params[:project_sort_type].present? case params[:project_sort_type] @@ -118,6 +122,7 @@ class ProjectsController < ApplicationController end @projects = @projects.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' @@ -131,6 +136,7 @@ class ProjectsController < ApplicationController end @projects = @projects.includes(:project_status).reorder('project_statuses.changesets_count').offset(@offset).limit(limit).all.reverse end + @s_type = 1 #@projects = @projects[@offset, @limit] when '2' @@ -144,6 +150,7 @@ class ProjectsController < ApplicationController end @projects = @projects.includes(:project_status).reorder('project_statuses.watchers_count').offset(@offset).limit(limit).all.reverse end + @s_type = 2 end else @offset ||= @project_pages.reverse_offset @@ -156,6 +163,7 @@ class ProjectsController < ApplicationController end @projects = @projects.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] diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index 784a11379..5c1407293 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -37,4 +37,18 @@ module BidsHelper Bid.tagged_with(tag_name).order('updated_on desc') end + def sort_bid(state) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1'))) + when 1 + content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:bid_sort_type => '0'))) + content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:bid_sort_type => '1'), :class=>"selected"), :class=>"selected") + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + end \ No newline at end of file diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 6e87b6a7d..db5ac93ac 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -36,6 +36,28 @@ module ProjectsHelper ] tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} end + + def sort_project(state) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2'))) + when 1 + content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0'))) + content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2'))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0'))) + content << content_tag('li', link_to(l(:label_sort_by_active), projects_path(:project_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2'), :class=>"selected"), :class=>"selected") + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + + def parent_project_select_tag(project) selected = project.parent diff --git a/app/views/bids/index.html.erb b/app/views/bids/index.html.erb index 091ef31c2..f5234a840 100644 --- a/app/views/bids/index.html.erb +++ b/app/views/bids/index.html.erb @@ -28,8 +28,8 @@ <% end %> - - +
<%= render :partial => 'bid_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %> diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 98ca363ad..1c611a0f1 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -19,19 +19,20 @@
<%end%> -