Update the new custom field form with remotely.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10163 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-08-07 16:58:51 +00:00
parent 1749fbf3e6
commit 599736aca7
6 changed files with 52 additions and 98 deletions
+14 -72
View File
@@ -1,88 +1,31 @@
<%= 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.select :field_format, custom_field_formats_for_select(@custom_field), {}, :disabled => !@custom_field.new_record? %></p>
<% if @custom_field.format_in? 'list', 'user', 'version' %>
<p><%= f.check_box :multiple, :disabled => @custom_field.multiple && !@custom_field.new_record? %></p>
<% end %>
<% unless @custom_field.format_in? 'list', 'bool', 'date', 'user', 'version' %>
<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>
<% end %>
<% if @custom_field.format_in? 'list' %>
<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>
<% end %>
<% unless @custom_field.format_in? 'user', 'version' %>
<p><%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %></p>
<% end %>
<%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
</div>
@@ -127,4 +70,3 @@ when "IssueCustomField" %>
<% 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();" %>
+1 -1
View File
@@ -2,7 +2,7 @@
&#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
&#187; <%=h @custom_field.name %></h2>
<%= labelled_form_for :custom_field, @custom_field, :url => custom_field_path(@custom_field), :html => {:method => :put} 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 } %>
<%= submit_tag l(:button_save) %>
<% end %>
+11 -1
View File
@@ -2,8 +2,18 @@
&#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
&#187; <%= l(:label_custom_field_new) %></h2>
<%= labelled_form_for :custom_field, @custom_field, :url => custom_fields_path 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 } %>
<%= hidden_field_tag 'type', @custom_field.type %>
<%= submit_tag l(:button_save) %>
<% end %>
<%= javascript_tag do %>
$('#custom_field_field_format').change(function(){
$.ajax({
url: '<%= new_custom_field_path(:format => 'js') %>',
type: 'get',
data: $('#custom_field_form').serialize()
});
});
<% end %>
+1
View File
@@ -0,0 +1 @@
$('#content').html('<%= escape_javascript(render :template => 'custom_fields/new', :layout => nil, :formats => [:html]) %>')