summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-01-31 19:53:24 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-01-31 19:53:24 +0000
commitfe22797d69273cc68b5d070416223e9c5f52f396 (patch)
treeae81cb18985a8693dbee64800756921212b037e2 /app
parentd29ba0b80fac3600b3bde5adc20b4df5c2a9bb37 (diff)
downloadredmine-fe22797d69273cc68b5d070416223e9c5f52f396.tar.gz
redmine-fe22797d69273cc68b5d070416223e9c5f52f396.zip
added the ability to set the sort order for issue statuses
git-svn-id: http://redmine.rubyforge.org/svn/trunk@205 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/issue_statuses_controller.rb20
-rw-r--r--app/controllers/issues_controller.rb4
-rw-r--r--app/controllers/reports_controller.rb2
-rw-r--r--app/controllers/roles_controller.rb2
-rw-r--r--app/models/issue_status.rb1
-rw-r--r--app/models/query.rb2
-rw-r--r--app/views/issue_statuses/list.rhtml7
7 files changed, 32 insertions, 6 deletions
diff --git a/app/controllers/issue_statuses_controller.rb b/app/controllers/issue_statuses_controller.rb
index 5c74fbd02..9180533c3 100644
--- a/app/controllers/issue_statuses_controller.rb
+++ b/app/controllers/issue_statuses_controller.rb
@@ -19,13 +19,16 @@ class IssueStatusesController < ApplicationController
layout 'base'
before_filter :require_admin
+ verify :method => :post, :only => [ :destroy, :create, :update, :move ],
+ :redirect_to => { :action => :list }
+
def index
list
render :action => 'list' unless request.xhr?
end
def list
- @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 10
+ @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
render :action => "list", :layout => false if request.xhr?
end
@@ -55,6 +58,21 @@ class IssueStatusesController < ApplicationController
else
render :action => 'edit'
end
+ end
+
+ def move
+ @issue_status = IssueStatus.find(params[:id])
+ case params[:position]
+ when 'highest'
+ @issue_status.move_to_top
+ when 'higher'
+ @issue_status.move_higher
+ when 'lower'
+ @issue_status.move_lower
+ when 'lowest'
+ @issue_status.move_to_bottom
+ end if params[:position]
+ redirect_to :action => 'list'
end
def destroy
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 6ac8bc79b..491062e24 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -25,7 +25,7 @@ class IssuesController < ApplicationController
include IfpdfHelper
def show
- @status_options = @issue.status.workflows.find(:all, :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
+ @status_options = @issue.status.workflows.find(:all, :order => 'position', :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
@journals_count = @issue.journals.count
@journals = @issue.journals.find(:all, :include => [:user, :details], :limit => 15, :order => "journals.created_on desc")
@@ -83,7 +83,7 @@ class IssuesController < ApplicationController
def change_status
#@history = @issue.histories.build(params[:history])
- @status_options = @issue.status.workflows.find(:all, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
+ @status_options = @issue.status.workflows.find(:all, :order => 'position', :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
@new_status = IssueStatus.find(params[:new_status_id])
if params[:confirm]
begin
diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb
index b27eb19ac..2e2f0fc8e 100644
--- a/app/controllers/reports_controller.rb
+++ b/app/controllers/reports_controller.rb
@@ -20,7 +20,7 @@ class ReportsController < ApplicationController
before_filter :find_project, :authorize
def issue_report
- @statuses = IssueStatus.find :all
+ @statuses = IssueStatus.find(:all, :order => 'position')
case params[:detail]
when "tracker"
diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb
index ed7c6c200..9e26a6996 100644
--- a/app/controllers/roles_controller.rb
+++ b/app/controllers/roles_controller.rb
@@ -79,6 +79,6 @@ class RolesController < ApplicationController
end
@roles = Role.find :all
@trackers = Tracker.find :all
- @statuses = IssueStatus.find(:all, :include => :workflows)
+ @statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position')
end
end
diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb
index aafafec19..1a690b449 100644
--- a/app/models/issue_status.rb
+++ b/app/models/issue_status.rb
@@ -18,6 +18,7 @@
class IssueStatus < ActiveRecord::Base
before_destroy :check_integrity
has_many :workflows, :foreign_key => "old_status_id"
+ acts_as_list
validates_presence_of :name
validates_uniqueness_of :name
diff --git a/app/models/query.rb b/app/models/query.rb
index dbde65a15..5594e5cb6 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -69,7 +69,7 @@ class Query < ActiveRecord::Base
def available_filters
return @available_filters if @available_filters
- @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all).collect{|s| [s.name, s.id.to_s] } },
+ @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
"tracker_id" => { :type => :list, :order => 2, :values => Tracker.find(:all).collect{|s| [s.name, s.id.to_s] } },
"priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect{|s| [s.name, s.id.to_s] } },
"subject" => { :type => :text, :order => 8 },
diff --git a/app/views/issue_statuses/list.rhtml b/app/views/issue_statuses/list.rhtml
index bde9b1e23..01617c329 100644
--- a/app/views/issue_statuses/list.rhtml
+++ b/app/views/issue_statuses/list.rhtml
@@ -9,6 +9,7 @@
<th><%=l(:field_status)%></th>
<th><%=l(:field_is_default)%></th>
<th><%=l(:field_is_closed)%></th>
+ <th><%=l(:button_sort)%></th>
<th></th>
</tr></thead>
<tbody>
@@ -18,6 +19,12 @@
<td align="center"><%= image_tag 'true.png' if status.is_default? %></td>
<td align="center"><%= image_tag 'true.png' if status.is_closed? %></td>
<td align="center">
+ <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => status, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
+ <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => status, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
+ <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => status, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
+ <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => status, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
+ </td>
+ <td align="center">
<%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
</td>
</tr>