##// END OF EJS Templates
Reorder links refactoring (follows r2526)....
Jean-Philippe Lang -
r2478:47f5713b1e1c
parent child
Show More
@@ -1,87 +1,81
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class BoardsController < ApplicationController
19 19 before_filter :find_project, :authorize
20 20
21 21 helper :messages
22 22 include MessagesHelper
23 23 helper :sort
24 24 include SortHelper
25 25 helper :watchers
26 26 include WatchersHelper
27 27
28 28 def index
29 29 @boards = @project.boards
30 30 # show the board if there is only one
31 31 if @boards.size == 1
32 32 @board = @boards.first
33 33 show
34 34 end
35 35 end
36 36
37 37 def show
38 38 sort_init 'updated_on', 'desc'
39 39 sort_update 'created_on' => "#{Message.table_name}.created_on",
40 40 'replies' => "#{Message.table_name}.replies_count",
41 41 'updated_on' => "#{Message.table_name}.updated_on"
42 42
43 43 @topic_count = @board.topics.count
44 44 @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
45 45 @topics = @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
46 46 :include => [:author, {:last_reply => :author}],
47 47 :limit => @topic_pages.items_per_page,
48 48 :offset => @topic_pages.current.offset
49 49 render :action => 'show', :layout => !request.xhr?
50 50 end
51 51
52 52 verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
53 53
54 54 def new
55 55 @board = Board.new(params[:board])
56 56 @board.project = @project
57 57 if request.post? && @board.save
58 58 flash[:notice] = l(:notice_successful_create)
59 59 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
60 60 end
61 61 end
62 62
63 63 def edit
64 64 if request.post? && @board.update_attributes(params[:board])
65 case params[:position]
66 when 'highest'; @board.move_to_top
67 when 'higher'; @board.move_higher
68 when 'lower'; @board.move_lower
69 when 'lowest'; @board.move_to_bottom
70 end if params[:position]
71 65 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
72 66 end
73 67 end
74 68
75 69 def destroy
76 70 @board.destroy
77 71 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
78 72 end
79 73
80 74 private
81 75 def find_project
82 76 @project = Project.find(params[:project_id])
83 77 @board = @project.boards.find(params[:id]) if params[:id]
84 78 rescue ActiveRecord::RecordNotFound
85 79 render_404
86 80 end
87 81 end
@@ -1,73 +1,58
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2009 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class CustomFieldsController < ApplicationController
19 19 before_filter :require_admin
20 20
21 21 def index
22 22 @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
23 23 @tab = params[:tab] || 'IssueCustomField'
24 24 end
25 25
26 26 def new
27 27 @custom_field = begin
28 28 if params[:type].to_s.match(/.+CustomField$/)
29 29 params[:type].to_s.constantize.new(params[:custom_field])
30 30 end
31 31 rescue
32 32 end
33 33 redirect_to(:action => 'index') and return unless @custom_field.is_a?(CustomField)
34 34
35 35 if request.post? and @custom_field.save
36 36 flash[:notice] = l(:notice_successful_create)
37 37 redirect_to :action => 'index', :tab => @custom_field.class.name
38 38 end
39 39 @trackers = Tracker.find(:all, :order => 'position')
40 40 end
41 41
42 42 def edit
43 43 @custom_field = CustomField.find(params[:id])
44 44 if request.post? and @custom_field.update_attributes(params[:custom_field])
45 45 flash[:notice] = l(:notice_successful_update)
46 46 redirect_to :action => 'index', :tab => @custom_field.class.name
47 47 end
48 48 @trackers = Tracker.find(:all, :order => 'position')
49 49 end
50
51 def move
52 @custom_field = CustomField.find(params[:id])
53 case params[:position]
54 when 'highest'
55 @custom_field.move_to_top
56 when 'higher'
57 @custom_field.move_higher
58 when 'lower'
59 @custom_field.move_lower
60 when 'lowest'
61 @custom_field.move_to_bottom
62 end if params[:position]
63 redirect_to :action => 'index', :tab => @custom_field.class.name
64 end
65 50
66 51 def destroy
67 52 @custom_field = CustomField.find(params[:id]).destroy
68 53 redirect_to :action => 'index', :tab => @custom_field.class.name
69 54 rescue
70 55 flash[:error] = "Unable to delete custom field"
71 56 redirect_to :action => 'index'
72 57 end
73 58 end
@@ -1,93 +1,78
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class EnumerationsController < ApplicationController
19 19 before_filter :require_admin
20 20
21 21 def index
22 22 list
23 23 render :action => 'list'
24 24 end
25 25
26 26 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
27 27 verify :method => :post, :only => [ :destroy, :create, :update ],
28 28 :redirect_to => { :action => :list }
29 29
30 30 def list
31 31 end
32 32
33 33 def new
34 34 @enumeration = Enumeration.new(:opt => params[:opt])
35 35 end
36 36
37 37 def create
38 38 @enumeration = Enumeration.new(params[:enumeration])
39 39 if @enumeration.save
40 40 flash[:notice] = l(:notice_successful_create)
41 41 redirect_to :action => 'list', :opt => @enumeration.opt
42 42 else
43 43 render :action => 'new'
44 44 end
45 45 end
46 46
47 47 def edit
48 48 @enumeration = Enumeration.find(params[:id])
49 49 end
50 50
51 51 def update
52 52 @enumeration = Enumeration.find(params[:id])
53 53 if @enumeration.update_attributes(params[:enumeration])
54 54 flash[:notice] = l(:notice_successful_update)
55 55 redirect_to :action => 'list', :opt => @enumeration.opt
56 56 else
57 57 render :action => 'edit'
58 58 end
59 59 end
60
61 def move
62 @enumeration = Enumeration.find(params[:id])
63 case params[:position]
64 when 'highest'
65 @enumeration.move_to_top
66 when 'higher'
67 @enumeration.move_higher
68 when 'lower'
69 @enumeration.move_lower
70 when 'lowest'
71 @enumeration.move_to_bottom
72 end if params[:position]
73 redirect_to :action => 'index'
74 end
75 60
76 61 def destroy
77 62 @enumeration = Enumeration.find(params[:id])
78 63 if !@enumeration.in_use?
79 64 # No associated objects
80 65 @enumeration.destroy
81 66 redirect_to :action => 'index'
82 67 elsif params[:reassign_to_id]
83 68 if reassign_to = Enumeration.find_by_opt_and_id(@enumeration.opt, params[:reassign_to_id])
84 69 @enumeration.destroy(reassign_to)
85 70 redirect_to :action => 'index'
86 71 end
87 72 end
88 73 @enumerations = Enumeration.values(@enumeration.opt) - [@enumeration]
89 74 #rescue
90 75 # flash[:error] = 'Unable to delete enumeration'
91 76 # redirect_to :action => 'index'
92 77 end
93 78 end
@@ -1,84 +1,69
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class IssueStatusesController < ApplicationController
19 19 before_filter :require_admin
20 20
21 21 verify :method => :post, :only => [ :destroy, :create, :update, :move ],
22 22 :redirect_to => { :action => :list }
23 23
24 24 def index
25 25 list
26 26 render :action => 'list' unless request.xhr?
27 27 end
28 28
29 29 def list
30 30 @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
31 31 render :action => "list", :layout => false if request.xhr?
32 32 end
33 33
34 34 def new
35 35 @issue_status = IssueStatus.new
36 36 end
37 37
38 38 def create
39 39 @issue_status = IssueStatus.new(params[:issue_status])
40 40 if @issue_status.save
41 41 flash[:notice] = l(:notice_successful_create)
42 42 redirect_to :action => 'list'
43 43 else
44 44 render :action => 'new'
45 45 end
46 46 end
47 47
48 48 def edit
49 49 @issue_status = IssueStatus.find(params[:id])
50 50 end
51 51
52 52 def update
53 53 @issue_status = IssueStatus.find(params[:id])
54 54 if @issue_status.update_attributes(params[:issue_status])
55 55 flash[:notice] = l(:notice_successful_update)
56 56 redirect_to :action => 'list'
57 57 else
58 58 render :action => 'edit'
59 59 end
60 60 end
61
62 def move
63 @issue_status = IssueStatus.find(params[:id])
64 case params[:position]
65 when 'highest'
66 @issue_status.move_to_top
67 when 'higher'
68 @issue_status.move_higher
69 when 'lower'
70 @issue_status.move_lower
71 when 'lowest'
72 @issue_status.move_to_bottom
73 end if params[:position]
74 redirect_to :action => 'list'
75 end
76 61
77 62 def destroy
78 63 IssueStatus.find(params[:id]).destroy
79 64 redirect_to :action => 'list'
80 65 rescue
81 66 flash[:error] = "Unable to delete issue status"
82 67 redirect_to :action => 'list'
83 68 end
84 69 end
@@ -1,94 +1,79
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class RolesController < ApplicationController
19 19 before_filter :require_admin
20 20
21 21 verify :method => :post, :only => [ :destroy, :move ],
22 22 :redirect_to => { :action => :list }
23 23
24 24 def index
25 25 list
26 26 render :action => 'list' unless request.xhr?
27 27 end
28 28
29 29 def list
30 30 @role_pages, @roles = paginate :roles, :per_page => 25, :order => 'builtin, position'
31 31 render :action => "list", :layout => false if request.xhr?
32 32 end
33 33
34 34 def new
35 35 # Prefills the form with 'Non member' role permissions
36 36 @role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
37 37 if request.post? && @role.save
38 38 # workflow copy
39 39 if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
40 40 @role.workflows.copy(copy_from)
41 41 end
42 42 flash[:notice] = l(:notice_successful_create)
43 43 redirect_to :action => 'list'
44 44 end
45 45 @permissions = @role.setable_permissions
46 46 @roles = Role.find :all, :order => 'builtin, position'
47 47 end
48 48
49 49 def edit
50 50 @role = Role.find(params[:id])
51 51 if request.post? and @role.update_attributes(params[:role])
52 52 flash[:notice] = l(:notice_successful_update)
53 53 redirect_to :action => 'list'
54 54 end
55 55 @permissions = @role.setable_permissions
56 56 end
57 57
58 58 def destroy
59 59 @role = Role.find(params[:id])
60 60 @role.destroy
61 61 redirect_to :action => 'list'
62 62 rescue
63 63 flash[:error] = 'This role is in use and can not be deleted.'
64 64 redirect_to :action => 'index'
65 65 end
66 66
67 def move
68 @role = Role.find(params[:id])
69 case params[:position]
70 when 'highest'
71 @role.move_to_top
72 when 'higher'
73 @role.move_higher
74 when 'lower'
75 @role.move_lower
76 when 'lowest'
77 @role.move_to_bottom
78 end if params[:position]
79 redirect_to :action => 'list'
80 end
81
82 67 def report
83 68 @roles = Role.find(:all, :order => 'builtin, position')
84 69 @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
85 70 if request.post?
86 71 @roles.each do |role|
87 72 role.permissions = params[:permissions][role.id.to_s]
88 73 role.save
89 74 end
90 75 flash[:notice] = l(:notice_successful_update)
91 76 redirect_to :action => 'list'
92 77 end
93 78 end
94 79 end
@@ -1,58 +1,53
1 1 <h2><%=l(:label_custom_field_plural)%></h2>
2 2
3 3 <% selected_tab = params[:tab] ? params[:tab].to_s : custom_fields_tabs.first[:name] %>
4 4
5 5 <div class="tabs">
6 6 <ul>
7 7 <% custom_fields_tabs.each do |tab| -%>
8 8 <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
9 9 :id => "tab-#{tab[:name]}",
10 10 :class => (tab[:name] != selected_tab ? nil : 'selected'),
11 11 :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
12 12 <% end -%>
13 13 </ul>
14 14 </div>
15 15
16 16 <% custom_fields_tabs.each do |tab| %>
17 17 <div id="tab-content-<%= tab[:name] %>" class="tab-content" style="<%= tab[:name] != selected_tab ? 'display:none' : nil %>">
18 18 <table class="list">
19 19 <thead><tr>
20 20 <th width="30%"><%=l(:field_name)%></th>
21 21 <th><%=l(:field_field_format)%></th>
22 22 <th><%=l(:field_is_required)%></th>
23 23 <% if tab[:name] == 'IssueCustomField' %>
24 24 <th><%=l(:field_is_for_all)%></th>
25 25 <th><%=l(:label_used_by)%></th>
26 26 <% end %>
27 27 <th><%=l(:button_sort)%></th>
28 28 <th width="10%"></th>
29 29 </tr></thead>
30 30 <tbody>
31 31 <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
32 32 <tr class="<%= cycle("odd", "even") %>">
33 33 <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
34 34 <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td>
35 35 <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
36 36 <% if tab[:name] == 'IssueCustomField' %>
37 37 <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
38 38 <td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
39 39 <% end %>
40 <td align="center" style="width:15%;">
41 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => custom_field, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
42 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => custom_field, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
43 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => custom_field, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
44 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => custom_field, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
45 </td>
40 <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
46 41 <td align="center">
47 42 <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
48 43 </td>
49 44 </tr>
50 45 <% end; reset_cycle %>
51 46 </tbody>
52 47 </table>
53 48
54 49 <p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
55 50 </div>
56 51 <% end %>
57 52
58 53 <% html_title(l(:label_custom_field_plural)) -%>
@@ -1,31 +1,26
1 1 <h2><%=l(:label_enumerations)%></h2>
2 2
3 3 <% Enumeration::OPTIONS.each do |option, params| %>
4 4 <h3><%= l(params[:label]) %></h3>
5 5
6 6 <% enumerations = Enumeration.values(option) %>
7 7 <% if enumerations.any? %>
8 8 <table class="list">
9 9 <% enumerations.each do |enumeration| %>
10 10 <tr class="<%= cycle('odd', 'even') %>">
11 11 <td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td>
12 12 <td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
13 <td style="width:15%;">
14 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => enumeration, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
15 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => enumeration, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
16 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => enumeration, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
17 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => enumeration, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
18 </td>
13 <td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}) %></td>
19 14 <td align="center" style="width:10%;">
20 15 <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, :method => :post, :confirm => l(:text_are_you_sure), :class => "icon icon-del" %>
21 16 </td>
22 17 </tr>
23 18 <% end %>
24 19 </table>
25 20 <% reset_cycle %>
26 21 <% end %>
27 22
28 23 <p><%= link_to l(:label_enumeration_new), { :action => 'new', :opt => option } %></p>
29 24 <% end %>
30 25
31 26 <% html_title(l(:label_enumerations)) -%>
@@ -1,37 +1,32
1 1 <div class="contextual">
2 2 <%= link_to l(:label_issue_status_new), {:action => 'new'}, :class => 'icon icon-add' %>
3 3 </div>
4 4
5 5 <h2><%=l(:label_issue_status_plural)%></h2>
6 6
7 7 <table class="list">
8 8 <thead><tr>
9 9 <th><%=l(:field_status)%></th>
10 10 <th><%=l(:field_is_default)%></th>
11 11 <th><%=l(:field_is_closed)%></th>
12 12 <th><%=l(:button_sort)%></th>
13 13 <th></th>
14 14 </tr></thead>
15 15 <tbody>
16 16 <% for status in @issue_statuses %>
17 17 <tr class="<%= cycle("odd", "even") %>">
18 18 <td><%= link_to status.name, :action => 'edit', :id => status %></td>
19 19 <td align="center"><%= image_tag 'true.png' if status.is_default? %></td>
20 20 <td align="center"><%= image_tag 'true.png' if status.is_closed? %></td>
21 <td align="center" style="width:15%;">
22 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => status, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
23 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => status, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
24 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => status, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
25 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => status, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
26 </td>
21 <td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}) %></td>
27 22 <td align="center" style="width:10%;">
28 23 <%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
29 24 </td>
30 25 </tr>
31 26 <% end %>
32 27 </tbody>
33 28 </table>
34 29
35 30 <p class="pagination"><%= pagination_links_full @issue_status_pages %></p>
36 31
37 32 <% html_title(l(:label_issue_status_plural)) -%>
@@ -1,28 +1,25
1 1 <% if @project.boards.any? %>
2 2 <table class="list">
3 3 <thead><th><%= l(:label_board) %></th><th><%= l(:field_description) %></th><th style="width:15%"></th><th style="width:15%"></th><th style="width:15%"></th></thead>
4 4 <tbody>
5 5 <% @project.boards.each do |board|
6 6 next if board.new_record? %>
7 7 <tr class="<%= cycle 'odd', 'even' %>">
8 8 <td><%=h board.name %></td>
9 9 <td><%=h board.description %></td>
10 10 <td align="center">
11 11 <% if authorize_for("boards", "edit") %>
12 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
13 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
14 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
15 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
12 <%= reorder_links('board', {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}) %>
16 13 <% end %>
17 14 </td>
18 15 <td align="center"><%= link_to_if_authorized l(:button_edit), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}, :class => 'icon icon-edit' %></td>
19 16 <td align="center"><%= link_to_if_authorized l(:button_delete), {:controller => 'boards', :action => 'destroy', :project_id => @project, :id => board}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></td>
20 17 </tr>
21 18 <% end %>
22 19 </tbody>
23 20 </table>
24 21 <% else %>
25 22 <p class="nodata"><%= l(:label_no_data) %></p>
26 23 <% end %>
27 24
28 25 <p><%= link_to_if_authorized l(:label_board_new), {:controller => 'boards', :action => 'new', :project_id => @project} %></p>
@@ -1,37 +1,34
1 1 <div class="contextual">
2 2 <%= link_to l(:label_role_new), {:action => 'new'}, :class => 'icon icon-add' %>
3 3 </div>
4 4
5 5 <h2><%=l(:label_role_plural)%></h2>
6 6
7 7 <table class="list">
8 8 <thead><tr>
9 9 <th><%=l(:label_role)%></th>
10 10 <th><%=l(:button_sort)%></th>
11 11 <th></th>
12 12 </tr></thead>
13 13 <tbody>
14 14 <% for role in @roles %>
15 15 <tr class="<%= cycle("odd", "even") %>">
16 16 <td><%= content_tag(role.builtin? ? 'em' : 'span', link_to(role.name, :action => 'edit', :id => role)) %></td>
17 17 <td align="center" style="width:15%;">
18 18 <% unless role.builtin? %>
19 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => role, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
20 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => role, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
21 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => role, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
22 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => role, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
19 <%= reorder_links('role', {:action => 'edit', :id => role}) %>
23 20 <% end %>
24 21 </td>
25 22 <td align="center" style="width:10%;">
26 23 <%= button_to(l(:button_delete), { :action => 'destroy', :id => role }, :confirm => l(:text_are_you_sure), :class => "button-small", :disabled => role.builtin? ) %>
27 24 </td>
28 25 </tr>
29 26 <% end %>
30 27 </tbody>
31 28 </table>
32 29
33 30 <p class="pagination"><%= pagination_links_full @role_pages %></p>
34 31
35 32 <p><%= link_to l(:label_permissions_report), :action => 'report' %></p>
36 33
37 34 <% html_title(l(:label_role_plural)) -%>
@@ -1,180 +1,180
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.dirname(__FILE__) + '/../test_helper'
19 19 require 'roles_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class RolesController; def rescue_action(e) raise e end; end
23 23
24 24 class RolesControllerTest < Test::Unit::TestCase
25 25 fixtures :roles, :users, :members, :workflows
26 26
27 27 def setup
28 28 @controller = RolesController.new
29 29 @request = ActionController::TestRequest.new
30 30 @response = ActionController::TestResponse.new
31 31 User.current = nil
32 32 @request.session[:user_id] = 1 # admin
33 33 end
34 34
35 35 def test_get_index
36 36 get :index
37 37 assert_response :success
38 38 assert_template 'list'
39 39
40 40 assert_not_nil assigns(:roles)
41 41 assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles)
42 42
43 43 assert_tag :tag => 'a', :attributes => { :href => '/roles/edit/1' },
44 44 :content => 'Manager'
45 45 end
46 46
47 47 def test_get_new
48 48 get :new
49 49 assert_response :success
50 50 assert_template 'new'
51 51 end
52 52
53 53 def test_post_new_with_validaton_failure
54 54 post :new, :role => {:name => '',
55 55 :permissions => ['add_issues', 'edit_issues', 'log_time', ''],
56 56 :assignable => '0'}
57 57
58 58 assert_response :success
59 59 assert_template 'new'
60 60 assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' }
61 61 end
62 62
63 63 def test_post_new_without_workflow_copy
64 64 post :new, :role => {:name => 'RoleWithoutWorkflowCopy',
65 65 :permissions => ['add_issues', 'edit_issues', 'log_time', ''],
66 66 :assignable => '0'}
67 67
68 68 assert_redirected_to 'roles/list'
69 69 role = Role.find_by_name('RoleWithoutWorkflowCopy')
70 70 assert_not_nil role
71 71 assert_equal [:add_issues, :edit_issues, :log_time], role.permissions
72 72 assert !role.assignable?
73 73 end
74 74
75 75 def test_post_new_with_workflow_copy
76 76 post :new, :role => {:name => 'RoleWithWorkflowCopy',
77 77 :permissions => ['add_issues', 'edit_issues', 'log_time', ''],
78 78 :assignable => '0'},
79 79 :copy_workflow_from => '1'
80 80
81 81 assert_redirected_to 'roles/list'
82 82 role = Role.find_by_name('RoleWithWorkflowCopy')
83 83 assert_not_nil role
84 84 assert_equal Role.find(1).workflows.size, role.workflows.size
85 85 end
86 86
87 87 def test_get_edit
88 88 get :edit, :id => 1
89 89 assert_response :success
90 90 assert_template 'edit'
91 91 assert_equal Role.find(1), assigns(:role)
92 92 end
93 93
94 94 def test_post_edit
95 95 post :edit, :id => 1,
96 96 :role => {:name => 'Manager',
97 97 :permissions => ['edit_project', ''],
98 98 :assignable => '0'}
99 99
100 100 assert_redirected_to 'roles/list'
101 101 role = Role.find(1)
102 102 assert_equal [:edit_project], role.permissions
103 103 end
104 104
105 105 def test_destroy
106 106 r = Role.new(:name => 'ToBeDestroyed', :permissions => [:view_wiki_pages])
107 107 assert r.save
108 108
109 109 post :destroy, :id => r
110 110 assert_redirected_to 'roles/list'
111 111 assert_nil Role.find_by_id(r.id)
112 112 end
113 113
114 114 def test_destroy_role_in_use
115 115 post :destroy, :id => 1
116 116 assert_redirected_to 'roles'
117 117 assert flash[:error] == 'This role is in use and can not be deleted.'
118 118 assert_not_nil Role.find_by_id(1)
119 119 end
120 120
121 121 def test_get_report
122 122 get :report
123 123 assert_response :success
124 124 assert_template 'report'
125 125
126 126 assert_not_nil assigns(:roles)
127 127 assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles)
128 128
129 129 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
130 130 :name => 'permissions[3][]',
131 131 :value => 'add_issues',
132 132 :checked => 'checked' }
133 133
134 134 assert_tag :tag => 'input', :attributes => { :type => 'checkbox',
135 135 :name => 'permissions[3][]',
136 136 :value => 'delete_issues',
137 137 :checked => nil }
138 138 end
139 139
140 140 def test_post_report
141 141 post :report, :permissions => { '0' => '', '1' => ['edit_issues'], '3' => ['add_issues', 'delete_issues']}
142 142 assert_redirected_to 'roles/list'
143 143
144 144 assert_equal [:edit_issues], Role.find(1).permissions
145 145 assert_equal [:add_issues, :delete_issues], Role.find(3).permissions
146 146 assert Role.find(2).permissions.empty?
147 147 end
148 148
149 149 def test_clear_all_permissions
150 150 post :report, :permissions => { '0' => '' }
151 151 assert_redirected_to 'roles/list'
152 152 assert Role.find(1).permissions.empty?
153 153 end
154 154
155 155 def test_move_highest
156 post :move, :id => 3, :position => 'highest'
156 post :edit, :id => 3, :role => {:move_to => 'highest'}
157 157 assert_redirected_to 'roles/list'
158 158 assert_equal 1, Role.find(3).position
159 159 end
160 160
161 161 def test_move_higher
162 162 position = Role.find(3).position
163 post :move, :id => 3, :position => 'higher'
163 post :edit, :id => 3, :role => {:move_to => 'higher'}
164 164 assert_redirected_to 'roles/list'
165 165 assert_equal position - 1, Role.find(3).position
166 166 end
167 167
168 168 def test_move_lower
169 169 position = Role.find(2).position
170 post :move, :id => 2, :position => 'lower'
170 post :edit, :id => 2, :role => {:move_to => 'lower'}
171 171 assert_redirected_to 'roles/list'
172 172 assert_equal position + 1, Role.find(2).position
173 173 end
174 174
175 175 def test_move_lowest
176 post :move, :id => 2, :position => 'lowest'
176 post :edit, :id => 2, :role => {:move_to => 'lowest'}
177 177 assert_redirected_to 'roles/list'
178 178 assert_equal Role.count, Role.find(2).position
179 179 end
180 180 end
General Comments 0
You need to be logged in to leave comments. Login now