Adds a view for editing all trackers fields.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10283 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
462c986452
commit
3a32edc3bd
|
@ -80,4 +80,22 @@ class TrackersController < ApplicationController
|
||||||
end
|
end
|
||||||
redirect_to :action => 'index'
|
redirect_to :action => 'index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fields
|
||||||
|
if request.post? && params[:trackers]
|
||||||
|
params[:trackers].each do |tracker_id, tracker_params|
|
||||||
|
tracker = Tracker.find_by_id(tracker_id)
|
||||||
|
if tracker
|
||||||
|
tracker.core_fields = tracker_params[:core_fields]
|
||||||
|
tracker.custom_field_ids = tracker_params[:custom_field_ids]
|
||||||
|
tracker.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_to :action => 'fields'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
@trackers = Tracker.sorted.all
|
||||||
|
@custom_fields = IssueCustomField.all.sort
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
<h2><%= link_to l(:label_tracker_plural), trackers_path %> » <%= l(:field_summary) %></h2>
|
||||||
|
|
||||||
|
<% if @trackers.any? %>
|
||||||
|
<%= form_tag({}) do %>
|
||||||
|
<div class="autoscroll">
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<% @trackers.each do |tracker| %>
|
||||||
|
<th>
|
||||||
|
<%= tracker.name %>
|
||||||
|
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('input.tracker-#{tracker.id}')",
|
||||||
|
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
|
||||||
|
</th>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr class="group open">
|
||||||
|
<td colspan="<%= @trackers.size + 1 %>">
|
||||||
|
<span class="expander" onclick="toggleRowGroup(this);"> </span>
|
||||||
|
<%= l(:field_core_fields) %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% Tracker::CORE_FIELDS.each do |field| %>
|
||||||
|
<tr class="<%= cycle("odd", "even") %>">
|
||||||
|
<td>
|
||||||
|
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('input.core-field-#{field}')",
|
||||||
|
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
|
||||||
|
<%= l("field_#{field}".sub(/_id$/, '')) %>
|
||||||
|
</td>
|
||||||
|
<% @trackers.each do |tracker| %>
|
||||||
|
<td align="center">
|
||||||
|
<%= check_box_tag "trackers[#{tracker.id}][core_fields][]", field, tracker.core_fields.include?(field),
|
||||||
|
:class => "tracker-#{tracker.id} core-field-#{field}" %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% if @custom_fields.any? %>
|
||||||
|
<tr class="group open">
|
||||||
|
<td colspan="<%= @trackers.size + 1 %>">
|
||||||
|
<span class="expander" onclick="toggleRowGroup(this);"> </span>
|
||||||
|
<%= l(:label_custom_field_plural) %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% @custom_fields.each do |field| %>
|
||||||
|
<tr class="<%= cycle("odd", "even") %>">
|
||||||
|
<td>
|
||||||
|
<%= link_to_function(image_tag('toggle_check.png'), "toggleCheckboxesBySelector('input.custom-field-#{field.id}')",
|
||||||
|
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}") %>
|
||||||
|
<%= field.name %>
|
||||||
|
</td>
|
||||||
|
<% @trackers.each do |tracker| %>
|
||||||
|
<td align="center">
|
||||||
|
<%= check_box_tag "trackers[#{tracker.id}][custom_field_ids][]", field.id, tracker.custom_fields.include?(field),
|
||||||
|
:class => "tracker-#{tracker.id} custom-field-#{field.id}" %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<p><%= submit_tag l(:button_save) %></p>
|
||||||
|
<% @trackers.each do |tracker| %>
|
||||||
|
<%= hidden_field_tag "trackers[#{tracker.id}][core_fields][]", '' %>
|
||||||
|
<%= hidden_field_tag "trackers[#{tracker.id}][custom_field_ids][]", '' %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title l(:field_summary) %>
|
|
@ -1,5 +1,6 @@
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<%= link_to l(:label_tracker_new), new_tracker_path, :class => 'icon icon-add' %>
|
<%= link_to l(:label_tracker_new), new_tracker_path, :class => 'icon icon-add' %>
|
||||||
|
<%= link_to l(:field_summary), {:action => 'fields'}, :class => 'icon icon-summary' %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2><%=l(:label_tracker_plural)%></h2>
|
<h2><%=l(:label_tracker_plural)%></h2>
|
||||||
|
|
|
@ -278,7 +278,11 @@ RedmineApp::Application.routes.draw do
|
||||||
match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post
|
match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post
|
||||||
match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post
|
match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post
|
||||||
|
|
||||||
resources :trackers, :except => :show
|
resources :trackers, :except => :show do
|
||||||
|
collection do
|
||||||
|
match 'fields', :via => [:get, :post]
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :issue_statuses, :except => :show do
|
resources :issue_statuses, :except => :show do
|
||||||
collection do
|
collection do
|
||||||
post 'update_issue_done_ratio'
|
post 'update_issue_done_ratio'
|
||||||
|
|
|
@ -185,4 +185,34 @@ class TrackersControllerTest < ActionController::TestCase
|
||||||
assert_redirected_to :action => 'index'
|
assert_redirected_to :action => 'index'
|
||||||
assert_not_nil flash[:error]
|
assert_not_nil flash[:error]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_get_fields
|
||||||
|
get :fields
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'fields'
|
||||||
|
|
||||||
|
assert_select 'form' do
|
||||||
|
assert_select 'input[type=checkbox][name=?][value=assigned_to_id]', 'trackers[1][core_fields][]'
|
||||||
|
assert_select 'input[type=checkbox][name=?][value=2]', 'trackers[1][custom_field_ids][]'
|
||||||
|
|
||||||
|
assert_select 'input[type=hidden][name=?][value=]', 'trackers[1][core_fields][]'
|
||||||
|
assert_select 'input[type=hidden][name=?][value=]', 'trackers[1][custom_field_ids][]'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_post_fields
|
||||||
|
post :fields, :trackers => {
|
||||||
|
'1' => {'core_fields' => ['assigned_to_id', 'due_date', ''], 'custom_field_ids' => ['1', '2']},
|
||||||
|
'2' => {'core_fields' => [''], 'custom_field_ids' => ['']}
|
||||||
|
}
|
||||||
|
assert_redirected_to '/trackers/fields'
|
||||||
|
|
||||||
|
tracker = Tracker.find(1)
|
||||||
|
assert_equal %w(assigned_to_id due_date), tracker.core_fields
|
||||||
|
assert_equal [1, 2], tracker.custom_field_ids.sort
|
||||||
|
|
||||||
|
tracker = Tracker.find(2)
|
||||||
|
assert_equal [], tracker.core_fields
|
||||||
|
assert_equal [], tracker.custom_field_ids.sort
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,5 +67,13 @@ class RoutingTrackersTest < ActionController::IntegrationTest
|
||||||
{ :controller => 'trackers', :action => 'destroy',
|
{ :controller => 'trackers', :action => 'destroy',
|
||||||
:format => 'xml', :id => '1' }
|
:format => 'xml', :id => '1' }
|
||||||
)
|
)
|
||||||
|
assert_routing(
|
||||||
|
{ :method => 'get', :path => "/trackers/fields" },
|
||||||
|
{ :controller => 'trackers', :action => 'fields' }
|
||||||
|
)
|
||||||
|
assert_routing(
|
||||||
|
{ :method => 'post', :path => "/trackers/fields" },
|
||||||
|
{ :controller => 'trackers', :action => 'fields' }
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue