Chris@0
|
1 <%= error_messages_for 'custom_field' %>
|
Chris@0
|
2
|
Chris@0
|
3 <script type="text/javascript">
|
Chris@0
|
4 //<![CDATA[
|
Chris@0
|
5 function toggle_custom_field_format() {
|
Chris@0
|
6 format = $("custom_field_field_format");
|
Chris@0
|
7 p_length = $("custom_field_min_length");
|
Chris@0
|
8 p_regexp = $("custom_field_regexp");
|
Chris@0
|
9 p_values = $("custom_field_possible_values");
|
Chris@0
|
10 p_searchable = $("custom_field_searchable");
|
Chris@0
|
11 p_default = $("custom_field_default_value");
|
Chris@0
|
12
|
Chris@0
|
13 p_default.setAttribute('type','text');
|
Chris@0
|
14 Element.show(p_default.parentNode);
|
Chris@0
|
15
|
Chris@0
|
16 switch (format.value) {
|
Chris@0
|
17 case "list":
|
Chris@0
|
18 Element.hide(p_length.parentNode);
|
Chris@0
|
19 Element.hide(p_regexp.parentNode);
|
Chris@0
|
20 if (p_searchable) Element.show(p_searchable.parentNode);
|
Chris@0
|
21 Element.show(p_values);
|
Chris@0
|
22 break;
|
Chris@0
|
23 case "bool":
|
Chris@0
|
24 p_default.setAttribute('type','checkbox');
|
Chris@0
|
25 Element.hide(p_length.parentNode);
|
Chris@0
|
26 Element.hide(p_regexp.parentNode);
|
Chris@0
|
27 if (p_searchable) Element.hide(p_searchable.parentNode);
|
Chris@0
|
28 Element.hide(p_values);
|
Chris@0
|
29 break;
|
Chris@0
|
30 case "date":
|
Chris@0
|
31 Element.hide(p_length.parentNode);
|
Chris@0
|
32 Element.hide(p_regexp.parentNode);
|
Chris@0
|
33 if (p_searchable) Element.hide(p_searchable.parentNode);
|
Chris@0
|
34 Element.hide(p_values);
|
Chris@0
|
35 break;
|
Chris@0
|
36 case "float":
|
Chris@0
|
37 case "int":
|
Chris@0
|
38 Element.show(p_length.parentNode);
|
Chris@0
|
39 Element.show(p_regexp.parentNode);
|
Chris@0
|
40 if (p_searchable) Element.hide(p_searchable.parentNode);
|
Chris@0
|
41 Element.hide(p_values);
|
Chris@0
|
42 break;
|
Chris@0
|
43 default:
|
Chris@0
|
44 Element.show(p_length.parentNode);
|
Chris@0
|
45 Element.show(p_regexp.parentNode);
|
Chris@0
|
46 if (p_searchable) Element.show(p_searchable.parentNode);
|
Chris@0
|
47 Element.hide(p_values);
|
Chris@0
|
48 break;
|
Chris@0
|
49 }
|
Chris@0
|
50 }
|
Chris@0
|
51
|
Chris@0
|
52 //]]>
|
Chris@0
|
53 </script>
|
Chris@0
|
54
|
Chris@0
|
55 <div class="box">
|
Chris@0
|
56 <p><%= f.text_field :name, :required => true %></p>
|
Chris@0
|
57 <p><%= f.select :field_format, custom_field_formats_for_select, {}, :onchange => "toggle_custom_field_format();",
|
Chris@0
|
58 :disabled => !@custom_field.new_record? %></p>
|
Chris@0
|
59 <p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
|
Chris@0
|
60 <%= f.text_field :min_length, :size => 5, :no_label => true %> -
|
Chris@0
|
61 <%= f.text_field :max_length, :size => 5, :no_label => true %><br>(<%=l(:text_min_max_length_info)%>)</p>
|
Chris@0
|
62 <p><%= f.text_field :regexp, :size => 50 %><br>(<%=l(:text_regexp_info)%>)</p>
|
Chris@0
|
63 <p id="custom_field_possible_values"><%= f.text_area :possible_values, :value => @custom_field.possible_values.to_a.join("\n"),
|
Chris@0
|
64 :cols => 20,
|
Chris@0
|
65 :rows => 15 %>
|
Chris@0
|
66 <br /><em><%= l(:text_custom_field_possible_values_info) %></em></p>
|
Chris@0
|
67 <p><%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %></p>
|
Chris@0
|
68 <%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
|
Chris@0
|
69 </div>
|
Chris@0
|
70
|
Chris@0
|
71 <div class="box">
|
Chris@0
|
72 <% case @custom_field.class.name
|
Chris@0
|
73 when "IssueCustomField" %>
|
Chris@0
|
74
|
Chris@0
|
75 <fieldset><legend><%=l(:label_tracker_plural)%></legend>
|
Chris@0
|
76 <% for tracker in @trackers %>
|
Chris@0
|
77 <%= check_box_tag "custom_field[tracker_ids][]", tracker.id, (@custom_field.trackers.include? tracker) %> <%= tracker.name %>
|
Chris@0
|
78 <% end %>
|
Chris@0
|
79 <%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
|
Chris@0
|
80 </fieldset>
|
Chris@0
|
81
|
Chris@0
|
82 <p><%= f.check_box :is_required %></p>
|
Chris@0
|
83 <p><%= f.check_box :is_for_all %></p>
|
Chris@0
|
84 <p><%= f.check_box :is_filter %></p>
|
Chris@0
|
85 <p><%= f.check_box :searchable %></p>
|
Chris@0
|
86
|
Chris@0
|
87 <% when "UserCustomField" %>
|
Chris@0
|
88 <p><%= f.check_box :is_required %></p>
|
chris@37
|
89 <p><%= f.check_box :visible %></p>
|
Chris@0
|
90 <p><%= f.check_box :editable %></p>
|
Chris@0
|
91
|
Chris@0
|
92 <% when "ProjectCustomField" %>
|
Chris@0
|
93 <p><%= f.check_box :is_required %></p>
|
chris@37
|
94 <p><%= f.check_box :visible %></p>
|
Chris@0
|
95 <p><%= f.check_box :searchable %></p>
|
Chris@0
|
96
|
Chris@0
|
97 <% when "TimeEntryCustomField" %>
|
Chris@0
|
98 <p><%= f.check_box :is_required %></p>
|
Chris@0
|
99
|
Chris@0
|
100 <% else %>
|
Chris@0
|
101 <p><%= f.check_box :is_required %></p>
|
Chris@0
|
102
|
Chris@0
|
103 <% end %>
|
Chris@0
|
104 <%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
|
Chris@0
|
105 </div>
|
Chris@0
|
106 <%= javascript_tag "toggle_custom_field_format();" %>
|