@custom_fields = IssueCustomField.find(:all)\r
@issue_category ||= IssueCategory.new\r
@member ||= @project.members.new\r
- @roles = Role.find(:all)\r
+ @roles = Role.find(:all, :order => 'position')\r
@users = User.find_active(:all) - @project.users\r
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }\r
end\r
class RolesController < ApplicationController\r
layout 'base' \r
before_filter :require_admin\r
+\r
+ verify :method => :post, :only => [ :destroy, :move ],\r
+ :redirect_to => { :action => :list }\r
def index
list
end
def list
- @role_pages, @roles = paginate :roles, :per_page => 10\r
+ @role_pages, @roles = paginate :roles, :per_page => 10, :order => "position"\r
render :action => "list", :layout => false if request.xhr?
end
redirect_to :action => 'list'
end\r
\r
+ def move\r
+ @role = Role.find(params[:id])\r
+ case params[:position]\r
+ when 'highest'\r
+ @role.move_to_top\r
+ when 'higher'\r
+ @role.move_higher\r
+ when 'lower'\r
+ @role.move_lower\r
+ when 'lowest'\r
+ @role.move_to_bottom\r
+ end if params[:position]\r
+ redirect_to :action => 'list'\r
+ end\r
+ \r
def workflow \r
@role = Role.find_by_id(params[:role_id])\r
@tracker = Tracker.find_by_id(params[:tracker_id]) \r
flash[:notice] = l(:notice_successful_update)\r
end\r
end\r
- @roles = Role.find :all\r
+ @roles = Role.find(:all, :order => 'position')\r
@trackers = Tracker.find :all\r
@statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position')\r
end
end\r
end
@auth_sources = AuthSource.find(:all)\r
- @roles = Role.find :all\r
+ @roles = Role.find(:all, :order => 'position')\r
@projects = Project.find(:all) - @user.projects\r
@membership ||= Member.new\r
end\r
has_and_belongs_to_many :permissions\r
has_many :workflows, :dependent => :delete_all\r
has_many :members\r
+ acts_as_list\r
\r
validates_presence_of :name\r
validates_uniqueness_of :name\r
<h2><%=l(:label_member_plural)%></h2>\r
\r
<% members = @members.group_by {|m| m.role } %>\r
-<% members.each do |role, member| %>\r
+<% members.keys.sort{|x,y| x.position <=> y.position}.each do |role| %>\r
<h3><%= role.name %></h3>\r
<ul>\r
-<% member.each do |m| %>\r
+<% members[role].each do |m| %>\r
<li><%= link_to m.user.display_name, :controller => 'account', :action => 'show', :id => m.user %> (<%= format_date m.created_on %>)</li>\r
<% end %>\r
</ul>\r
<table class="list">\r
<thead><th><%= l(:label_user) %></th><th><%= l(:label_role) %></th><th></th></thead>
<tbody>
- <% for member in @project.members.find(:all, :include => :user) %>\r
+ <% @project.members.find(:all, :include => [:role, :user]).sort{|x,y| x.role.position <=> y.role.position}.each do |member| %>\r
<% unless member.new_record? %>\r
<tr class="<%= cycle 'odd', 'even' %>">\r
<td><%= member.user.display_name %></td>\r
<table class="list">
<thead><tr>
<th><%=l(:label_role)%></th>
+ <th><%=l(:button_sort)%></th>
<th></th>
</tr></thead>
<tbody>
<% for role in @roles %>
<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" %>\r
</tr>
--- /dev/null
+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
* settings are now stored in the database and editable through the application in: Admin -> Settings (config_custom.rb is no longer used)\r
* mail notifications added when a document, a file or an attachment is added\r
* tooltips added on Gantt chart and calender to view the details of the issues\r
-* ability to set the sort order for issue statuses\r
+* ability to set the sort order for roles, issue statuses\r
* added missing fields to csv export: priority, start date, due date, done ratio\r
* 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-)\r
* added back "fixed version" field on issue screen and in filters\r