From fa688d48e673abfa8711beb69995aaf3d41069d1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 31 Jan 2007 21:18:43 +0000 Subject: added the ability to set the sort order for trackers git-svn-id: http://redmine.rubyforge.org/svn/trunk@209 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/custom_fields_controller.rb | 4 ++-- app/controllers/projects_controller.rb | 6 +++--- app/controllers/reports_controller.rb | 4 ++-- app/controllers/roles_controller.rb | 2 +- app/controllers/trackers_controller.rb | 19 +++++++++++++++++-- 5 files changed, 25 insertions(+), 10 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb index 29314f4b1..7d8829641 100644 --- a/app/controllers/custom_fields_controller.rb +++ b/app/controllers/custom_fields_controller.rb @@ -47,7 +47,7 @@ class CustomFieldsController < ApplicationController flash[:notice] = l(:notice_successful_create) redirect_to :action => 'list', :tab => @custom_field.type end - @trackers = Tracker.find(:all) + @trackers = Tracker.find(:all, :order => 'position') end def edit @@ -59,7 +59,7 @@ class CustomFieldsController < ApplicationController flash[:notice] = l(:notice_successful_update) redirect_to :action => 'list', :tab => @custom_field.type end - @trackers = Tracker.find(:all) + @trackers = Tracker.find(:all, :order => 'position') end def destroy diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 815edb87d..5d42221c3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -81,7 +81,7 @@ class ProjectsController < ApplicationController @members = @project.members.find(:all, :include => [:user, :role]) @subprojects = @project.children if @project.children.size > 0 @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "news.created_on DESC") - @trackers = Tracker.find(:all) + @trackers = Tracker.find(:all, :order => 'position') @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN issue_statuses ON issue_statuses.id = issues.status_id", :conditions => ["project_id=? and issue_statuses.is_closed=?", @project.id, false]) @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) end @@ -245,7 +245,7 @@ class ProjectsController < ApplicationController :limit => @issue_pages.items_per_page, :offset => @issue_pages.current.offset end - @trackers = Tracker.find :all + @trackers = Tracker.find :all, :order => 'position' render :layout => false if request.xhr? end @@ -404,7 +404,7 @@ class ProjectsController < ApplicationController # Show changelog for @project def changelog - @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true]) + @trackers = Tracker.find(:all, :conditions => ["is_in_chlog=?", true], :order => 'position') if request.get? @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } else diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 2e2f0fc8e..aa26e24b9 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -25,7 +25,7 @@ class ReportsController < ApplicationController case params[:detail] when "tracker" @field = "tracker_id" - @rows = Tracker.find :all + @rows = Tracker.find :all, :order => 'position' @data = issues_by_tracker @report_title = l(:field_tracker) render :template => "reports/issue_report_details" @@ -49,7 +49,7 @@ class ReportsController < ApplicationController render :template => "reports/issue_report_details" else @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)] - @trackers = Tracker.find(:all) + @trackers = Tracker.find(:all, :order => 'position') @priorities = Enumeration::get_values('IPRI') @categories = @project.issue_categories @authors = @project.members.collect { |m| m.user } diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 6ac08a767..b26cf730b 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -96,7 +96,7 @@ class RolesController < ApplicationController end end @roles = Role.find(:all, :order => 'position') - @trackers = Tracker.find :all + @trackers = Tracker.find(:all, :order => 'position') @statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position') end end diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index 186f8b7ae..173f63c48 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -28,7 +28,7 @@ class TrackersController < ApplicationController verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :list } def list - @tracker_pages, @trackers = paginate :trackers, :per_page => 10 + @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' render :action => "list", :layout => false if request.xhr? end @@ -47,7 +47,22 @@ class TrackersController < ApplicationController redirect_to :action => 'list' end end - + + def move + @tracker = Tracker.find(params[:id]) + case params[:position] + when 'highest' + @tracker.move_to_top + when 'higher' + @tracker.move_higher + when 'lower' + @tracker.move_lower + when 'lowest' + @tracker.move_to_bottom + end if params[:position] + redirect_to :action => 'list' + end + def destroy @tracker = Tracker.find(params[:id]) unless @tracker.issues.empty? -- cgit v1.2.3