diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-01-31 20:57:01 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-01-31 20:57:01 +0000 |
commit | 671a0fa10161ead2ec0fef888710cf7d872b2f61 (patch) | |
tree | f7b9068afbc1d1e360106b9584cd88aa89f10ab1 | |
parent | 99f006f2c959ce9d1e5136e950ca448cc92ec7c9 (diff) | |
download | redmine-671a0fa10161ead2ec0fef888710cf7d872b2f61.tar.gz redmine-671a0fa10161ead2ec0fef888710cf7d872b2f61.zip |
added the ability to set the sort order for roles
git-svn-id: http://redmine.rubyforge.org/svn/trunk@208 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/projects_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/roles_controller.rb | 22 | ||||
-rw-r--r-- | app/controllers/users_controller.rb | 2 | ||||
-rw-r--r-- | app/models/role.rb | 1 | ||||
-rw-r--r-- | app/views/projects/list_members.rhtml | 4 | ||||
-rw-r--r-- | app/views/projects/settings.rhtml | 2 | ||||
-rw-r--r-- | app/views/roles/list.rhtml | 7 | ||||
-rw-r--r-- | db/migrate/020_add_role_position.rb | 10 | ||||
-rw-r--r-- | doc/CHANGELOG | 2 |
9 files changed, 44 insertions, 8 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e7db204ed..815edb87d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -91,7 +91,7 @@ class ProjectsController < ApplicationController @custom_fields = IssueCustomField.find(:all)
@issue_category ||= IssueCategory.new
@member ||= @project.members.new
- @roles = Role.find(:all)
+ @roles = Role.find(:all, :order => 'position')
@users = User.find_active(:all) - @project.users
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
end
diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 9e26a6996..6ac08a767 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -18,6 +18,9 @@ class RolesController < ApplicationController
layout 'base'
before_filter :require_admin
+
+ verify :method => :post, :only => [ :destroy, :move ],
+ :redirect_to => { :action => :list }
def index list @@ -25,7 +28,7 @@ class RolesController < ApplicationController end def list - @role_pages, @roles = paginate :roles, :per_page => 10
+ @role_pages, @roles = paginate :roles, :per_page => 10, :order => "position"
render :action => "list", :layout => false if request.xhr? end @@ -62,6 +65,21 @@ class RolesController < ApplicationController redirect_to :action => 'list' end
+ def move
+ @role = Role.find(params[:id])
+ case params[:position]
+ when 'highest'
+ @role.move_to_top
+ when 'higher'
+ @role.move_higher
+ when 'lower'
+ @role.move_lower
+ when 'lowest'
+ @role.move_to_bottom
+ end if params[:position]
+ redirect_to :action => 'list'
+ end
+
def workflow
@role = Role.find_by_id(params[:role_id])
@tracker = Tracker.find_by_id(params[:tracker_id])
@@ -77,7 +95,7 @@ class RolesController < ApplicationController flash[:notice] = l(:notice_successful_update)
end
end
- @roles = Role.find :all
+ @roles = Role.find(:all, :order => 'position')
@trackers = Tracker.find :all
@statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position')
end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 14f8ecff3..4ddbe0548 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -80,7 +80,7 @@ class UsersController < ApplicationController end
end @auth_sources = AuthSource.find(:all)
- @roles = Role.find :all
+ @roles = Role.find(:all, :order => 'position')
@projects = Project.find(:all) - @user.projects
@membership ||= Member.new
end
diff --git a/app/models/role.rb b/app/models/role.rb index aea402f46..d00a2b218 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -20,6 +20,7 @@ class Role < ActiveRecord::Base has_and_belongs_to_many :permissions
has_many :workflows, :dependent => :delete_all
has_many :members
+ acts_as_list
validates_presence_of :name
validates_uniqueness_of :name
diff --git a/app/views/projects/list_members.rhtml b/app/views/projects/list_members.rhtml index 655abb280..d7b6c5bcb 100644 --- a/app/views/projects/list_members.rhtml +++ b/app/views/projects/list_members.rhtml @@ -1,10 +1,10 @@ <h2><%=l(:label_member_plural)%></h2>
<% members = @members.group_by {|m| m.role } %>
-<% members.each do |role, member| %>
+<% members.keys.sort{|x,y| x.position <=> y.position}.each do |role| %>
<h3><%= role.name %></h3>
<ul>
-<% member.each do |m| %>
+<% members[role].each do |m| %>
<li><%= link_to m.user.display_name, :controller => 'account', :action => 'show', :id => m.user %> (<%= format_date m.created_on %>)</li>
<% end %>
</ul>
diff --git a/app/views/projects/settings.rhtml b/app/views/projects/settings.rhtml index 9299ce49c..8a891c010 100644 --- a/app/views/projects/settings.rhtml +++ b/app/views/projects/settings.rhtml @@ -23,7 +23,7 @@ <table class="list">
<thead><th><%= l(:label_user) %></th><th><%= l(:label_role) %></th><th></th></thead> <tbody> - <% for member in @project.members.find(:all, :include => :user) %>
+ <% @project.members.find(:all, :include => [:role, :user]).sort{|x,y| x.role.position <=> y.role.position}.each do |member| %>
<% unless member.new_record? %>
<tr class="<%= cycle 'odd', 'even' %>">
<td><%= member.user.display_name %></td>
diff --git a/app/views/roles/list.rhtml b/app/views/roles/list.rhtml index 141d75873..c6c4492b3 100644 --- a/app/views/roles/list.rhtml +++ b/app/views/roles/list.rhtml @@ -7,6 +7,7 @@ <table class="list"> <thead><tr> <th><%=l(:label_role)%></th> + <th><%=l(:button_sort)%></th> <th></th> </tr></thead> <tbody> @@ -14,6 +15,12 @@ <tr class="<%= cycle("odd", "even") %>"> <td><%= link_to role.name, :action => 'edit', :id => role %></td> <td align="center"> + <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => role, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %> + <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => role, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> - + <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => role, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %> + <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => role, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %> + </td> + <td align="center"> <%= button_to l(:button_delete), { :action => 'destroy', :id => role }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
</tr> <% end %> diff --git a/db/migrate/020_add_role_position.rb b/db/migrate/020_add_role_position.rb new file mode 100644 index 000000000..3afa88193 --- /dev/null +++ b/db/migrate/020_add_role_position.rb @@ -0,0 +1,10 @@ +class AddRolePosition < ActiveRecord::Migration + def self.up + add_column :roles, :position, :integer, :default => 1, :null => false + Role.find(:all).each_with_index {|role, i| role.update_attribute(:position, i+1)} + end + + def self.down + remove_column :roles, :position + end +end diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 34381a04a..66d513e65 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -11,7 +11,7 @@ http://redmine.rubyforge.org/ * settings are now stored in the database and editable through the application in: Admin -> Settings (config_custom.rb is no longer used)
* mail notifications added when a document, a file or an attachment is added
* tooltips added on Gantt chart and calender to view the details of the issues
-* ability to set the sort order for issue statuses
+* ability to set the sort order for roles, issue statuses
* added missing fields to csv export: priority, start date, due date, done ratio
* all icons replaced (new icons are based on GPL icon set: "KDE Crystal Diamond 2.5" -by paolino- and "kNeu! Alpha v0.1" -by Pablo Fabregat-)
* added back "fixed version" field on issue screen and in filters
|