Redmine/app/views/custom_fields/_form.html.erb

131 lines
4.5 KiB
Plaintext
Raw Normal View History

<%= error_messages_for 'custom_field' %>
<script type="text/javascript">
//<![CDATA[
function toggle_custom_field_format() {
var format = $("#custom_field_field_format").val();
var p_length = $("#custom_field_min_length");
var p_regexp = $("#custom_field_regexp");
var p_values = $("#custom_field_possible_values");
var p_searchable = $("#custom_field_searchable");
var p_default = $("#custom_field_default_value");
var p_multiple = $("#custom_field_multiple");
// can't change type on JQuery objects
var p_default2 = document.getElementById("custom_field_default_value");
p_default2.type = 'text';
p_default.parent().show();
switch (format) {
case "list":
p_length.parent().hide();
p_regexp.parent().hide();
p_searchable.parent().show();
p_values.parent().show();
p_multiple.parent().show();
break;
case "bool":
p_default2.type = 'checkbox';
p_length.parent().hide();
p_regexp.parent().hide();
p_searchable.parent().hide();
p_values.parent().hide();
p_multiple.parent().hide();
break;
case "date":
p_length.parent().hide();
p_regexp.parent().hide();
p_searchable.parent().hide();
p_values.parent().hide();
p_multiple.parent().hide();
break;
case "float":
case "int":
p_length.parent().show();
p_regexp.parent().show();
p_searchable.parent().hide();
p_values.parent().hide();
p_multiple.parent().hide();
break;
case "user":
case "version":
p_length.parent().hide();
p_regexp.parent().hide();
p_searchable.parent().hide();
p_values.parent().hide();
p_multiple.parent().show();
p_default.parent().hide();
break;
default:
p_length.parent().show();
p_regexp.parent().show();
p_searchable.parent().show();
p_values.parent().hide();
p_multiple.parent().hide();
break;
}
}
//]]>
</script>
<div class="box tabular">
<p><%= f.text_field :name, :required => true %></p>
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :onchange => "toggle_custom_field_format();",
:disabled => !@custom_field.new_record? %></p>
<p><%= f.check_box :multiple, :disabled => @custom_field.multiple && !@custom_field.new_record? %></p>
<p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
<%= f.text_field :min_length, :size => 5, :no_label => true %> -
<%= f.text_field :max_length, :size => 5, :no_label => true %><br />(<%=l(:text_min_max_length_info)%>)</p>
<p><%= f.text_field :regexp, :size => 50 %><br />(<%=l(:text_regexp_info)%>)</p>
<p>
<%= f.text_area :possible_values, :value => @custom_field.possible_values.to_a.join("\n"), :rows => 15 %>
<em class="info"><%= l(:text_custom_field_possible_values_info) %></em>
</p>
<p><%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %></p>
<%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
</div>
<div class="box tabular">
<% case @custom_field.class.name
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>
&nbsp;
<p><%= f.check_box :is_required %></p>
<p><%= f.check_box :is_for_all %></p>
<p><%= f.check_box :is_filter %></p>
<p><%= f.check_box :searchable %></p>
<% when "UserCustomField" %>
<p><%= f.check_box :is_required %></p>
<p><%= f.check_box :visible %></p>
<p><%= f.check_box :editable %></p>
<% when "ProjectCustomField" %>
<p><%= f.check_box :is_required %></p>
<p><%= f.check_box :visible %></p>
<p><%= f.check_box :searchable %></p>
<% when "TimeEntryCustomField" %>
<p><%= f.check_box :is_required %></p>
<% else %>
<p><%= f.check_box :is_required %></p>
<% end %>
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
</div>
<%= javascript_tag "toggle_custom_field_format();" %>