@@ -1,5 +1,9 | |||
|
1 | 1 | <%= error_messages_for 'custom_field' %> |
|
2 | 2 | |
|
3 | <% if @custom_field.is_a?(IssueCustomField) %> | |
|
4 | <div class="splitcontentleft"> | |
|
5 | <% end %> | |
|
6 | ||
|
3 | 7 | <div class="box tabular"> |
|
4 | 8 | <p><%= f.text_field :name, :required => true %></p> |
|
5 | 9 | <p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :disabled => !@custom_field.new_record? %></p> |
@@ -46,20 +50,6 | |||
|
46 | 50 | <div class="box tabular"> |
|
47 | 51 | <% case @custom_field.class.name |
|
48 | 52 | when "IssueCustomField" %> |
|
49 | ||
|
50 | <fieldset><legend><%=l(:label_tracker_plural)%></legend> | |
|
51 | <% Tracker.sorted.all.each do |tracker| %> | |
|
52 | <%= check_box_tag "custom_field[tracker_ids][]", | |
|
53 | tracker.id, | |
|
54 | (@custom_field.trackers.include? tracker), | |
|
55 | :id => "custom_field_tracker_ids_#{tracker.id}" %> | |
|
56 | <label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>"> | |
|
57 | <%= h(tracker.name) %> | |
|
58 | </label> | |
|
59 | <% end %> | |
|
60 | <%= hidden_field_tag "custom_field[tracker_ids][]", '' %> | |
|
61 | </fieldset> | |
|
62 | | |
|
63 | 53 | <p><%= f.check_box :is_required %></p> |
|
64 | 54 | <p><%= f.check_box :is_for_all %></p> |
|
65 | 55 | <p><%= f.check_box :is_filter %></p> |
@@ -113,6 +103,33 when "IssueCustomField" %> | |||
|
113 | 103 | <% end %> |
|
114 | 104 | <%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %> |
|
115 | 105 | </div> |
|
106 | <%= submit_tag l(:button_save) %> | |
|
107 | ||
|
108 | <% if @custom_field.is_a?(IssueCustomField) %> | |
|
109 | </div> | |
|
110 | <div class="splitcontentright"> | |
|
111 | <fieldset class="box"><legend><%=l(:label_tracker_plural)%></legend> | |
|
112 | <% Tracker.sorted.all.each do |tracker| %> | |
|
113 | <%= check_box_tag "custom_field[tracker_ids][]", | |
|
114 | tracker.id, | |
|
115 | (@custom_field.trackers.include? tracker), | |
|
116 | :id => "custom_field_tracker_ids_#{tracker.id}" %> | |
|
117 | <label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>"> | |
|
118 | <%= h(tracker.name) %> | |
|
119 | </label> | |
|
120 | <% end %> | |
|
121 | <%= hidden_field_tag "custom_field[tracker_ids][]", '' %> | |
|
122 | </fieldset> | |
|
123 | ||
|
124 | <fieldset class="box" id="custom_field_project_ids"><legend><%= l(:label_project_plural) %></legend> | |
|
125 | <%= render_project_nested_lists(Project.all) do |p| | |
|
126 | content_tag('label', check_box_tag('custom_field[project_ids][]', p.id, @custom_field.projects.to_a.include?(p), :id => nil) + ' ' + h(p)) | |
|
127 | end %> | |
|
128 | <%= hidden_field_tag('custom_field[project_ids][]', '', :id => nil) %> | |
|
129 | <p><%= check_all_links 'custom_field_project_ids' %></p> | |
|
130 | </fieldset> | |
|
131 | </div> | |
|
132 | <% end %> | |
|
116 | 133 | |
|
117 | 134 | <% include_calendar_headers_tags %> |
|
118 | 135 | |
@@ -123,4 +140,8 function toggleCustomFieldRoles(){ | |||
|
123 | 140 | } |
|
124 | 141 | $("#custom_field_visible_on, #custom_field_visible_off").change(toggleCustomFieldRoles); |
|
125 | 142 | $(document).ready(toggleCustomFieldRoles); |
|
143 | ||
|
144 | $("#custom_field_is_for_all").change(function(){ | |
|
145 | $("#custom_field_project_ids input").attr("disabled", $(this).is(":checked")); | |
|
146 | }).trigger('change'); | |
|
126 | 147 | <% end %> |
@@ -4,5 +4,4 | |||
|
4 | 4 | |
|
5 | 5 | <%= labelled_form_for :custom_field, @custom_field, :url => custom_field_path(@custom_field), :html => {:method => :put, :id => 'custom_field_form'} do |f| %> |
|
6 | 6 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
7 | <%= submit_tag l(:button_save) %> | |
|
8 | 7 | <% end %> |
@@ -5,7 +5,6 | |||
|
5 | 5 | <%= labelled_form_for :custom_field, @custom_field, :url => custom_fields_path, :html => {:id => 'custom_field_form'} do |f| %> |
|
6 | 6 | <%= render :partial => 'form', :locals => { :f => f } %> |
|
7 | 7 | <%= hidden_field_tag 'type', @custom_field.type %> |
|
8 | <%= submit_tag l(:button_save) %> | |
|
9 | 8 | <% end %> |
|
10 | 9 | |
|
11 | 10 | <%= javascript_tag do %> |
@@ -2,11 +2,7 | |||
|
2 | 2 | Copyright (C) 2006-2013 Jean-Philippe Lang */ |
|
3 | 3 | |
|
4 | 4 | function checkAll(id, checked) { |
|
5 | if (checked) { | |
|
6 | $('#'+id).find('input[type=checkbox]').attr('checked', true); | |
|
7 | } else { | |
|
8 | $('#'+id).find('input[type=checkbox]').removeAttr('checked'); | |
|
9 | } | |
|
5 | $('#'+id).find('input[type=checkbox]:enabled').attr('checked', checked); | |
|
10 | 6 | } |
|
11 | 7 | |
|
12 | 8 | function toggleCheckboxesBySelector(selector) { |
@@ -433,7 +433,7 ul.projects li {list-style-type:none;} | |||
|
433 | 433 | #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; } |
|
434 | 434 | .my-project { padding-left: 18px; background: url(../images/fav.png) no-repeat 0 50%; } |
|
435 | 435 | |
|
436 | #notified-projects ul, #tracker_project_ids ul {max-height:250px; overflow-y:auto;} | |
|
436 | #notified-projects ul, #tracker_project_ids ul, #custom_field_project_ids ul {max-height:250px; overflow-y:auto;} | |
|
437 | 437 | |
|
438 | 438 | #related-issues li img {vertical-align:middle;} |
|
439 | 439 |
@@ -18,7 +18,7 | |||
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class CustomFieldsControllerTest < ActionController::TestCase |
|
21 | fixtures :custom_fields, :custom_values, :trackers, :users | |
|
21 | fixtures :custom_fields, :custom_values, :trackers, :users, :projects | |
|
22 | 22 | |
|
23 | 23 | def setup |
|
24 | 24 | @request.session[:user_id] = 1 |
@@ -52,10 +52,22 class CustomFieldsControllerTest < ActionController::TestCase | |||
|
52 | 52 | assert_select 'option[value=user]', :text => 'User' |
|
53 | 53 | assert_select 'option[value=version]', :text => 'Version' |
|
54 | 54 | end |
|
55 | assert_select 'input[type=checkbox][name=?]', 'custom_field[project_ids][]', Project.count | |
|
56 | assert_select 'input[type=hidden][name=?]', 'custom_field[project_ids][]', 1 | |
|
55 | 57 | assert_select 'input[type=hidden][name=type][value=IssueCustomField]' |
|
56 | 58 | end |
|
57 | 59 | end |
|
58 | 60 | |
|
61 | def test_new_time_entry_custom_field_should_not_show_trackers_and_projects | |
|
62 | get :new, :type => 'TimeEntryCustomField' | |
|
63 | assert_response :success | |
|
64 | assert_template 'new' | |
|
65 | assert_select 'form#custom_field_form' do | |
|
66 | assert_select 'input[name=?]', 'custom_field[tracker_ids][]', 0 | |
|
67 | assert_select 'input[name=?]', 'custom_field[project_ids][]', 0 | |
|
68 | end | |
|
69 | end | |
|
70 | ||
|
59 | 71 | def test_default_value_should_be_an_input_for_string_custom_field |
|
60 | 72 | get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'string'} |
|
61 | 73 | assert_response :success |
@@ -118,6 +130,17 class CustomFieldsControllerTest < ActionController::TestCase | |||
|
118 | 130 | assert_equal 1, field.trackers.size |
|
119 | 131 | end |
|
120 | 132 | |
|
133 | def test_create_with_project_ids | |
|
134 | assert_difference 'CustomField.count' do | |
|
135 | post :create, :type => "IssueCustomField", :custom_field => { | |
|
136 | :name => "foo", :field_format => "string", :is_for_all => "0", :project_ids => ["1", "3", ""] | |
|
137 | } | |
|
138 | assert_response 302 | |
|
139 | end | |
|
140 | field = IssueCustomField.order("id desc").first | |
|
141 | assert_equal [1, 3], field.projects.map(&:id).sort | |
|
142 | end | |
|
143 | ||
|
121 | 144 | def test_create_with_failure |
|
122 | 145 | assert_no_difference 'CustomField.count' do |
|
123 | 146 | post :create, :type => "IssueCustomField", :custom_field => {:name => ''} |
General Comments 0
You need to be logged in to leave comments.
Login now