summaryrefslogtreecommitdiffstats
path: root/app/views/custom_fields
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-08-07 16:58:51 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-08-07 16:58:51 +0000
commit599736aca7b9b5bd47d39fdf72c9fc1127730497 (patch)
tree1aabc950dccab01b701b45c43a13cee79b491fbe /app/views/custom_fields
parent1749fbf3e6169c7aa304c967ab4ff7ea4217e61e (diff)
downloadredmine-599736aca7b9b5bd47d39fdf72c9fc1127730497.tar.gz
redmine-599736aca7b9b5bd47d39fdf72c9fc1127730497.zip
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
Diffstat (limited to 'app/views/custom_fields')
-rw-r--r--app/views/custom_fields/_form.html.erb86
-rw-r--r--app/views/custom_fields/edit.html.erb2
-rw-r--r--app/views/custom_fields/new.html.erb12
-rw-r--r--app/views/custom_fields/new.js.erb1
4 files changed, 27 insertions, 74 deletions
diff --git a/app/views/custom_fields/_form.html.erb b/app/views/custom_fields/_form.html.erb
index 7ffbbaedc..dcfcc32ec 100644
--- a/app/views/custom_fields/_form.html.erb
+++ b/app/views/custom_fields/_form.html.erb
@@ -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();" %>
diff --git a/app/views/custom_fields/edit.html.erb b/app/views/custom_fields/edit.html.erb
index dce34736f..43a8ebf30 100644
--- a/app/views/custom_fields/edit.html.erb
+++ b/app/views/custom_fields/edit.html.erb
@@ -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 %>
diff --git a/app/views/custom_fields/new.html.erb b/app/views/custom_fields/new.html.erb
index cde4fab58..71e7197ec 100644
--- a/app/views/custom_fields/new.html.erb
+++ b/app/views/custom_fields/new.html.erb
@@ -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 %>
diff --git a/app/views/custom_fields/new.js.erb b/app/views/custom_fields/new.js.erb
new file mode 100644
index 000000000..d77c97f07
--- /dev/null
+++ b/app/views/custom_fields/new.js.erb
@@ -0,0 +1 @@
+$('#content').html('<%= escape_javascript(render :template => 'custom_fields/new', :layout => nil, :formats => [:html]) %>')