##// END OF EJS Templates
added the ability to set the sort order for roles...
Jean-Philippe Lang -
r205:671a0fa10161
parent child
Show More
@@ -0,0 +1,10
1 class AddRolePosition < ActiveRecord::Migration
2 def self.up
3 add_column :roles, :position, :integer, :default => 1, :null => false
4 Role.find(:all).each_with_index {|role, i| role.update_attribute(:position, i+1)}
5 end
6
7 def self.down
8 remove_column :roles, :position
9 end
10 end
@@ -91,7 +91,7 class ProjectsController < ApplicationController
91 @custom_fields = IssueCustomField.find(:all)
91 @custom_fields = IssueCustomField.find(:all)
92 @issue_category ||= IssueCategory.new
92 @issue_category ||= IssueCategory.new
93 @member ||= @project.members.new
93 @member ||= @project.members.new
94 @roles = Role.find(:all)
94 @roles = Role.find(:all, :order => 'position')
95 @users = User.find_active(:all) - @project.users
95 @users = User.find_active(:all) - @project.users
96 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
96 @custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
97 end
97 end
@@ -19,13 +19,16 class RolesController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :require_admin
20 before_filter :require_admin
21
21
22 verify :method => :post, :only => [ :destroy, :move ],
23 :redirect_to => { :action => :list }
24
22 def index
25 def index
23 list
26 list
24 render :action => 'list' unless request.xhr?
27 render :action => 'list' unless request.xhr?
25 end
28 end
26
29
27 def list
30 def list
28 @role_pages, @roles = paginate :roles, :per_page => 10
31 @role_pages, @roles = paginate :roles, :per_page => 10, :order => "position"
29 render :action => "list", :layout => false if request.xhr?
32 render :action => "list", :layout => false if request.xhr?
30 end
33 end
31
34
@@ -62,6 +65,21 class RolesController < ApplicationController
62 redirect_to :action => 'list'
65 redirect_to :action => 'list'
63 end
66 end
64
67
68 def move
69 @role = Role.find(params[:id])
70 case params[:position]
71 when 'highest'
72 @role.move_to_top
73 when 'higher'
74 @role.move_higher
75 when 'lower'
76 @role.move_lower
77 when 'lowest'
78 @role.move_to_bottom
79 end if params[:position]
80 redirect_to :action => 'list'
81 end
82
65 def workflow
83 def workflow
66 @role = Role.find_by_id(params[:role_id])
84 @role = Role.find_by_id(params[:role_id])
67 @tracker = Tracker.find_by_id(params[:tracker_id])
85 @tracker = Tracker.find_by_id(params[:tracker_id])
@@ -77,7 +95,7 class RolesController < ApplicationController
77 flash[:notice] = l(:notice_successful_update)
95 flash[:notice] = l(:notice_successful_update)
78 end
96 end
79 end
97 end
80 @roles = Role.find :all
98 @roles = Role.find(:all, :order => 'position')
81 @trackers = Tracker.find :all
99 @trackers = Tracker.find :all
82 @statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position')
100 @statuses = IssueStatus.find(:all, :include => :workflows, :order => 'position')
83 end
101 end
@@ -80,7 +80,7 class UsersController < ApplicationController
80 end
80 end
81 end
81 end
82 @auth_sources = AuthSource.find(:all)
82 @auth_sources = AuthSource.find(:all)
83 @roles = Role.find :all
83 @roles = Role.find(:all, :order => 'position')
84 @projects = Project.find(:all) - @user.projects
84 @projects = Project.find(:all) - @user.projects
85 @membership ||= Member.new
85 @membership ||= Member.new
86 end
86 end
@@ -20,6 +20,7 class Role < ActiveRecord::Base
20 has_and_belongs_to_many :permissions
20 has_and_belongs_to_many :permissions
21 has_many :workflows, :dependent => :delete_all
21 has_many :workflows, :dependent => :delete_all
22 has_many :members
22 has_many :members
23 acts_as_list
23
24
24 validates_presence_of :name
25 validates_presence_of :name
25 validates_uniqueness_of :name
26 validates_uniqueness_of :name
@@ -1,10 +1,10
1 <h2><%=l(:label_member_plural)%></h2>
1 <h2><%=l(:label_member_plural)%></h2>
2
2
3 <% members = @members.group_by {|m| m.role } %>
3 <% members = @members.group_by {|m| m.role } %>
4 <% members.each do |role, member| %>
4 <% members.keys.sort{|x,y| x.position <=> y.position}.each do |role| %>
5 <h3><%= role.name %></h3>
5 <h3><%= role.name %></h3>
6 <ul>
6 <ul>
7 <% member.each do |m| %>
7 <% members[role].each do |m| %>
8 <li><%= link_to m.user.display_name, :controller => 'account', :action => 'show', :id => m.user %> (<%= format_date m.created_on %>)</li>
8 <li><%= link_to m.user.display_name, :controller => 'account', :action => 'show', :id => m.user %> (<%= format_date m.created_on %>)</li>
9 <% end %>
9 <% end %>
10 </ul>
10 </ul>
@@ -23,7 +23,7
23 <table class="list">
23 <table class="list">
24 <thead><th><%= l(:label_user) %></th><th><%= l(:label_role) %></th><th></th></thead>
24 <thead><th><%= l(:label_user) %></th><th><%= l(:label_role) %></th><th></th></thead>
25 <tbody>
25 <tbody>
26 <% for member in @project.members.find(:all, :include => :user) %>
26 <% @project.members.find(:all, :include => [:role, :user]).sort{|x,y| x.role.position <=> y.role.position}.each do |member| %>
27 <% unless member.new_record? %>
27 <% unless member.new_record? %>
28 <tr class="<%= cycle 'odd', 'even' %>">
28 <tr class="<%= cycle 'odd', 'even' %>">
29 <td><%= member.user.display_name %></td>
29 <td><%= member.user.display_name %></td>
@@ -7,6 +7,7
7 <table class="list">
7 <table class="list">
8 <thead><tr>
8 <thead><tr>
9 <th><%=l(:label_role)%></th>
9 <th><%=l(:label_role)%></th>
10 <th><%=l(:button_sort)%></th>
10 <th></th>
11 <th></th>
11 </tr></thead>
12 </tr></thead>
12 <tbody>
13 <tbody>
@@ -14,6 +15,12
14 <tr class="<%= cycle("odd", "even") %>">
15 <tr class="<%= cycle("odd", "even") %>">
15 <td><%= link_to role.name, :action => 'edit', :id => role %></td>
16 <td><%= link_to role.name, :action => 'edit', :id => role %></td>
16 <td align="center">
17 <td align="center">
18 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => role, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
19 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => role, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
20 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => role, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
21 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => role, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
22 </td>
23 <td align="center">
17 <%= button_to l(:button_delete), { :action => 'destroy', :id => role }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
24 <%= button_to l(:button_delete), { :action => 'destroy', :id => role }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
18 </tr>
25 </tr>
19 <% end %>
26 <% end %>
@@ -11,7 +11,7 http://redmine.rubyforge.org/
11 * settings are now stored in the database and editable through the application in: Admin -> Settings (config_custom.rb is no longer used)
11 * settings are now stored in the database and editable through the application in: Admin -> Settings (config_custom.rb is no longer used)
12 * mail notifications added when a document, a file or an attachment is added
12 * mail notifications added when a document, a file or an attachment is added
13 * tooltips added on Gantt chart and calender to view the details of the issues
13 * tooltips added on Gantt chart and calender to view the details of the issues
14 * ability to set the sort order for issue statuses
14 * ability to set the sort order for roles, issue statuses
15 * added missing fields to csv export: priority, start date, due date, done ratio
15 * added missing fields to csv export: priority, start date, due date, done ratio
16 * 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-)
16 * 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-)
17 * added back "fixed version" field on issue screen and in filters
17 * added back "fixed version" field on issue screen and in filters
General Comments 0
You need to be logged in to leave comments. Login now