Projects selection on custom field form (#15136).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12225 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
4eea64d38f
commit
13e381d31d
|
@ -1,5 +1,9 @@
|
||||||
<%= error_messages_for 'custom_field' %>
|
<%= error_messages_for 'custom_field' %>
|
||||||
|
|
||||||
|
<% if @custom_field.is_a?(IssueCustomField) %>
|
||||||
|
<div class="splitcontentleft">
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<p><%= f.text_field :name, :required => true %></p>
|
<p><%= f.text_field :name, :required => true %></p>
|
||||||
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :disabled => !@custom_field.new_record? %></p>
|
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :disabled => !@custom_field.new_record? %></p>
|
||||||
|
@ -46,20 +50,6 @@
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<% case @custom_field.class.name
|
<% case @custom_field.class.name
|
||||||
when "IssueCustomField" %>
|
when "IssueCustomField" %>
|
||||||
|
|
||||||
<fieldset><legend><%=l(:label_tracker_plural)%></legend>
|
|
||||||
<% Tracker.sorted.all.each do |tracker| %>
|
|
||||||
<%= check_box_tag "custom_field[tracker_ids][]",
|
|
||||||
tracker.id,
|
|
||||||
(@custom_field.trackers.include? tracker),
|
|
||||||
:id => "custom_field_tracker_ids_#{tracker.id}" %>
|
|
||||||
<label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>">
|
|
||||||
<%= h(tracker.name) %>
|
|
||||||
</label>
|
|
||||||
<% end %>
|
|
||||||
<%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
<p><%= f.check_box :is_required %></p>
|
<p><%= f.check_box :is_required %></p>
|
||||||
<p><%= f.check_box :is_for_all %></p>
|
<p><%= f.check_box :is_for_all %></p>
|
||||||
<p><%= f.check_box :is_filter %></p>
|
<p><%= f.check_box :is_filter %></p>
|
||||||
|
@ -113,6 +103,33 @@ when "IssueCustomField" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
|
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
|
||||||
</div>
|
</div>
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
|
|
||||||
|
<% if @custom_field.is_a?(IssueCustomField) %>
|
||||||
|
</div>
|
||||||
|
<div class="splitcontentright">
|
||||||
|
<fieldset class="box"><legend><%=l(:label_tracker_plural)%></legend>
|
||||||
|
<% Tracker.sorted.all.each do |tracker| %>
|
||||||
|
<%= check_box_tag "custom_field[tracker_ids][]",
|
||||||
|
tracker.id,
|
||||||
|
(@custom_field.trackers.include? tracker),
|
||||||
|
:id => "custom_field_tracker_ids_#{tracker.id}" %>
|
||||||
|
<label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>">
|
||||||
|
<%= h(tracker.name) %>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
<%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="box" id="custom_field_project_ids"><legend><%= l(:label_project_plural) %></legend>
|
||||||
|
<%= render_project_nested_lists(Project.all) do |p|
|
||||||
|
content_tag('label', check_box_tag('custom_field[project_ids][]', p.id, @custom_field.projects.to_a.include?(p), :id => nil) + ' ' + h(p))
|
||||||
|
end %>
|
||||||
|
<%= hidden_field_tag('custom_field[project_ids][]', '', :id => nil) %>
|
||||||
|
<p><%= check_all_links 'custom_field_project_ids' %></p>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% include_calendar_headers_tags %>
|
<% include_calendar_headers_tags %>
|
||||||
|
|
||||||
|
@ -123,4 +140,8 @@ function toggleCustomFieldRoles(){
|
||||||
}
|
}
|
||||||
$("#custom_field_visible_on, #custom_field_visible_off").change(toggleCustomFieldRoles);
|
$("#custom_field_visible_on, #custom_field_visible_off").change(toggleCustomFieldRoles);
|
||||||
$(document).ready(toggleCustomFieldRoles);
|
$(document).ready(toggleCustomFieldRoles);
|
||||||
|
|
||||||
|
$("#custom_field_is_for_all").change(function(){
|
||||||
|
$("#custom_field_project_ids input").attr("disabled", $(this).is(":checked"));
|
||||||
|
}).trigger('change');
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -4,5 +4,4 @@
|
||||||
|
|
||||||
<%= labelled_form_for :custom_field, @custom_field, :url => custom_field_path(@custom_field), :html => {:method => :put, :id => 'custom_field_form'} do |f| %>
|
<%= labelled_form_for :custom_field, @custom_field, :url => custom_field_path(@custom_field), :html => {:method => :put, :id => 'custom_field_form'} do |f| %>
|
||||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
<%= submit_tag l(:button_save) %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<%= labelled_form_for :custom_field, @custom_field, :url => custom_fields_path, :html => {:id => 'custom_field_form'} do |f| %>
|
<%= labelled_form_for :custom_field, @custom_field, :url => custom_fields_path, :html => {:id => 'custom_field_form'} do |f| %>
|
||||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
<%= hidden_field_tag 'type', @custom_field.type %>
|
<%= hidden_field_tag 'type', @custom_field.type %>
|
||||||
<%= submit_tag l(:button_save) %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= javascript_tag do %>
|
<%= javascript_tag do %>
|
||||||
|
|
|
@ -2,11 +2,7 @@
|
||||||
Copyright (C) 2006-2013 Jean-Philippe Lang */
|
Copyright (C) 2006-2013 Jean-Philippe Lang */
|
||||||
|
|
||||||
function checkAll(id, checked) {
|
function checkAll(id, checked) {
|
||||||
if (checked) {
|
$('#'+id).find('input[type=checkbox]:enabled').attr('checked', checked);
|
||||||
$('#'+id).find('input[type=checkbox]').attr('checked', true);
|
|
||||||
} else {
|
|
||||||
$('#'+id).find('input[type=checkbox]').removeAttr('checked');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleCheckboxesBySelector(selector) {
|
function toggleCheckboxesBySelector(selector) {
|
||||||
|
|
|
@ -433,7 +433,7 @@ ul.projects li {list-style-type:none;}
|
||||||
#projects-index ul.projects div.root a.project { font-family: "Trebuchet MS", Verdana, sans-serif; font-weight: bold; font-size: 16px; margin: 0 0 10px 0; }
|
#projects-index ul.projects div.root a.project { font-family: "Trebuchet MS", Verdana, sans-serif; font-weight: bold; font-size: 16px; margin: 0 0 10px 0; }
|
||||||
.my-project { padding-left: 18px; background: url(../images/fav.png) no-repeat 0 50%; }
|
.my-project { padding-left: 18px; background: url(../images/fav.png) no-repeat 0 50%; }
|
||||||
|
|
||||||
#notified-projects ul, #tracker_project_ids ul {max-height:250px; overflow-y:auto;}
|
#notified-projects ul, #tracker_project_ids ul, #custom_field_project_ids ul {max-height:250px; overflow-y:auto;}
|
||||||
|
|
||||||
#related-issues li img {vertical-align:middle;}
|
#related-issues li img {vertical-align:middle;}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
require File.expand_path('../../test_helper', __FILE__)
|
require File.expand_path('../../test_helper', __FILE__)
|
||||||
|
|
||||||
class CustomFieldsControllerTest < ActionController::TestCase
|
class CustomFieldsControllerTest < ActionController::TestCase
|
||||||
fixtures :custom_fields, :custom_values, :trackers, :users
|
fixtures :custom_fields, :custom_values, :trackers, :users, :projects
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
|
@ -52,10 +52,22 @@ class CustomFieldsControllerTest < ActionController::TestCase
|
||||||
assert_select 'option[value=user]', :text => 'User'
|
assert_select 'option[value=user]', :text => 'User'
|
||||||
assert_select 'option[value=version]', :text => 'Version'
|
assert_select 'option[value=version]', :text => 'Version'
|
||||||
end
|
end
|
||||||
|
assert_select 'input[type=checkbox][name=?]', 'custom_field[project_ids][]', Project.count
|
||||||
|
assert_select 'input[type=hidden][name=?]', 'custom_field[project_ids][]', 1
|
||||||
assert_select 'input[type=hidden][name=type][value=IssueCustomField]'
|
assert_select 'input[type=hidden][name=type][value=IssueCustomField]'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_new_time_entry_custom_field_should_not_show_trackers_and_projects
|
||||||
|
get :new, :type => 'TimeEntryCustomField'
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'new'
|
||||||
|
assert_select 'form#custom_field_form' do
|
||||||
|
assert_select 'input[name=?]', 'custom_field[tracker_ids][]', 0
|
||||||
|
assert_select 'input[name=?]', 'custom_field[project_ids][]', 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_default_value_should_be_an_input_for_string_custom_field
|
def test_default_value_should_be_an_input_for_string_custom_field
|
||||||
get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'string'}
|
get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'string'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -118,6 +130,17 @@ class CustomFieldsControllerTest < ActionController::TestCase
|
||||||
assert_equal 1, field.trackers.size
|
assert_equal 1, field.trackers.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_create_with_project_ids
|
||||||
|
assert_difference 'CustomField.count' do
|
||||||
|
post :create, :type => "IssueCustomField", :custom_field => {
|
||||||
|
:name => "foo", :field_format => "string", :is_for_all => "0", :project_ids => ["1", "3", ""]
|
||||||
|
}
|
||||||
|
assert_response 302
|
||||||
|
end
|
||||||
|
field = IssueCustomField.order("id desc").first
|
||||||
|
assert_equal [1, 3], field.projects.map(&:id).sort
|
||||||
|
end
|
||||||
|
|
||||||
def test_create_with_failure
|
def test_create_with_failure
|
||||||
assert_no_difference 'CustomField.count' do
|
assert_no_difference 'CustomField.count' do
|
||||||
post :create, :type => "IssueCustomField", :custom_field => {:name => ''}
|
post :create, :type => "IssueCustomField", :custom_field => {:name => ''}
|
||||||
|
|
Loading…
Reference in New Issue