summaryrefslogtreecommitdiffstats
path: root/app/views/custom_fields
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-12-14 08:22:43 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-12-14 08:22:43 +0000
commit2e2e2cfe425c2664517fb59836fbd3eff5e35861 (patch)
treee3daa66ee8b36d2f1a1468ec9501fba5bc37d71c /app/views/custom_fields
parentc74f6d9f9bcf02ccc480a2028802b83ec5d91aca (diff)
downloadredmine-2e2e2cfe425c2664517fb59836fbd3eff5e35861.tar.gz
redmine-2e2e2cfe425c2664517fb59836fbd3eff5e35861.zip
Merged custom fields format refactoring.
git-svn-id: http://svn.redmine.org/redmine/trunk@12400 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/views/custom_fields')
-rw-r--r--app/views/custom_fields/_form.html.erb71
-rw-r--r--app/views/custom_fields/_index.html.erb2
-rw-r--r--app/views/custom_fields/formats/_bool.html.erb2
-rw-r--r--app/views/custom_fields/formats/_date.html.erb2
-rw-r--r--app/views/custom_fields/formats/_link.html.erb3
-rw-r--r--app/views/custom_fields/formats/_list.html.erb6
-rw-r--r--app/views/custom_fields/formats/_numeric.html.erb2
-rw-r--r--app/views/custom_fields/formats/_regexp.html.erb10
-rw-r--r--app/views/custom_fields/formats/_string.html.erb3
-rw-r--r--app/views/custom_fields/formats/_text.html.erb3
-rw-r--r--app/views/custom_fields/formats/_user.html.erb24
-rw-r--r--app/views/custom_fields/formats/_version.html.erb24
-rw-r--r--app/views/custom_fields/new.html.erb3
13 files changed, 101 insertions, 54 deletions
diff --git a/app/views/custom_fields/_form.html.erb b/app/views/custom_fields/_form.html.erb
index 356d0bca3..a6417bb53 100644
--- a/app/views/custom_fields/_form.html.erb
+++ b/app/views/custom_fields/_form.html.erb
@@ -1,14 +1,12 @@
<%= error_messages_for 'custom_field' %>
-<% if @custom_field.is_a?(IssueCustomField) %>
<div class="splitcontentleft">
-<% end %>
-
<div class="box tabular">
<p><%= f.text_field :name, :required => true %></p>
+<p><%= f.text_area :description, :rows => 7 %></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' %>
+<% if @custom_field.format.multiple_supported %>
<p>
<%= f.check_box :multiple %>
<% if !@custom_field.new_record? && @custom_field.multiple %>
@@ -17,56 +15,38 @@
</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 %>
-
-<% case @custom_field.field_format %>
-<% when 'bool' %>
- <p><%= f.check_box(:default_value) %></p>
-<% when 'text' %>
- <p><%= f.text_area(:default_value, :rows => 8) %></p>
-<% when 'date' %>
- <p><%= f.text_field(:default_value, :size => 10) %></p>
- <%= calendar_for('custom_field_default_value') %>
-<% when 'user', 'version' %>
-<% else %>
- <p><%= f.text_field(:default_value) %></p>
-<% end %>
+<%= render_custom_field_format_partial f, @custom_field %>
<%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
</div>
+<p><%= submit_tag l(:button_save) %></p>
+</div>
+<div class="splitcontentright">
<div class="box tabular">
<% case @custom_field.class.name
when "IssueCustomField" %>
<p><%= f.check_box :is_required %></p>
- <p><%= f.check_box :is_for_all %></p>
+ <p><%= f.check_box :is_for_all, :data => {:disables => '#custom_field_project_ids input'} %></p>
<p><%= f.check_box :is_filter %></p>
+ <% if @custom_field.format.searchable_supported %>
<p><%= f.check_box :searchable %></p>
+ <% end %>
<p>
<label><%= l(:field_visible) %></label>
<label class="block">
- <%= radio_button_tag 'custom_field[visible]', 1, @custom_field.visible?, :id => 'custom_field_visible_on' %>
+ <%= radio_button_tag 'custom_field[visible]', 1, @custom_field.visible?, :id => 'custom_field_visible_on',
+ :data => {:disables => '.custom_field_role input'} %>
<%= l(:label_visibility_public) %>
</label>
<label class="block">
- <%= radio_button_tag 'custom_field[visible]', 0, !@custom_field.visible?, :id => 'custom_field_visible_off' %>
+ <%= radio_button_tag 'custom_field[visible]', 0, !@custom_field.visible?, :id => 'custom_field_visible_off',
+ :data => {:enables => '.custom_field_role input'} %>
<%= l(:label_visibility_roles) %>:
</label>
<% Role.givable.sorted.each do |role| %>
<label class="block custom_field_role" style="padding-left:2em;">
- <%= check_box_tag 'custom_field[role_ids][]', role.id, @custom_field.roles.include?(role) %>
+ <%= check_box_tag 'custom_field[role_ids][]', role.id, @custom_field.roles.include?(role), :id => nil %>
<%= role.name %>
</label>
<% end %>
@@ -82,7 +62,9 @@ when "IssueCustomField" %>
<% when "ProjectCustomField" %>
<p><%= f.check_box :is_required %></p>
<p><%= f.check_box :visible %></p>
+ <% if @custom_field.format.searchable_supported %>
<p><%= f.check_box :searchable %></p>
+ <% end %>
<p><%= f.check_box :is_filter %></p>
<% when "VersionCustomField" %>
@@ -103,12 +85,9 @@ when "IssueCustomField" %>
<% end %>
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
</div>
-<%= submit_tag l(:button_save) %>
<% if @custom_field.is_a?(IssueCustomField) %>
-</div>
-<div class="splitcontentright">
- <fieldset class="box"><legend><%=l(:label_tracker_plural)%></legend>
+ <fieldset class="box" id="custom_field_tracker_ids"><legend><%=l(:label_tracker_plural)%></legend>
<% Tracker.sorted.all.each do |tracker| %>
<%= check_box_tag "custom_field[tracker_ids][]",
tracker.id,
@@ -119,6 +98,7 @@ when "IssueCustomField" %>
</label>
<% end %>
<%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
+ <p><%= check_all_links 'custom_field_tracker_ids' %></p>
</fieldset>
<fieldset class="box" id="custom_field_project_ids"><legend><%= l(:label_project_plural) %></legend>
@@ -128,20 +108,7 @@ when "IssueCustomField" %>
<%= hidden_field_tag('custom_field[project_ids][]', '', :id => nil) %>
<p><%= check_all_links 'custom_field_project_ids' %></p>
</fieldset>
-</div>
<% end %>
+</div>
<% include_calendar_headers_tags %>
-
-<%= javascript_tag do %>
-function toggleCustomFieldRoles(){
- var checked = $("#custom_field_visible_on").is(':checked');
- $('.custom_field_role input').attr('disabled', checked);
-}
-$("#custom_field_visible_on, #custom_field_visible_off").change(toggleCustomFieldRoles);
-$(document).ready(toggleCustomFieldRoles);
-
-$("#custom_field_is_for_all").change(function(){
- $("#custom_field_project_ids input").attr("disabled", $(this).is(":checked"));
-}).trigger('change');
-<% end %>
diff --git a/app/views/custom_fields/_index.html.erb b/app/views/custom_fields/_index.html.erb
index d55d08cfc..4752c2519 100644
--- a/app/views/custom_fields/_index.html.erb
+++ b/app/views/custom_fields/_index.html.erb
@@ -14,7 +14,7 @@
<% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
<tr class="<%= cycle("odd", "even") %>">
<td class="name"><%= link_to h(custom_field.name), edit_custom_field_path(custom_field) %></td>
- <td><%= l(Redmine::CustomFieldFormat.label_for(custom_field.field_format)) %></td>
+ <td><%= l(custom_field.format.label) %></td>
<td><%= checked_image custom_field.is_required? %></td>
<% if tab[:name] == 'IssueCustomField' %>
<td><%= checked_image custom_field.is_for_all? %></td>
diff --git a/app/views/custom_fields/formats/_bool.html.erb b/app/views/custom_fields/formats/_bool.html.erb
new file mode 100644
index 000000000..25c464fb9
--- /dev/null
+++ b/app/views/custom_fields/formats/_bool.html.erb
@@ -0,0 +1,2 @@
+<p><%= f.select :default_value, [[]]+@custom_field.possible_values_options %></p>
+<p><%= edit_tag_style_tag f %></p>
diff --git a/app/views/custom_fields/formats/_date.html.erb b/app/views/custom_fields/formats/_date.html.erb
new file mode 100644
index 000000000..807a9269e
--- /dev/null
+++ b/app/views/custom_fields/formats/_date.html.erb
@@ -0,0 +1,2 @@
+<p><%= f.text_field(:default_value, :size => 10) %></p>
+<%= calendar_for('custom_field_default_value') %>
diff --git a/app/views/custom_fields/formats/_link.html.erb b/app/views/custom_fields/formats/_link.html.erb
new file mode 100644
index 000000000..9b7d342e0
--- /dev/null
+++ b/app/views/custom_fields/formats/_link.html.erb
@@ -0,0 +1,3 @@
+<%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
+<p><%= f.text_field :url_pattern, :size => 50, :label => :field_url %></p>
+<p><%= f.text_field(:default_value) %></p>
diff --git a/app/views/custom_fields/formats/_list.html.erb b/app/views/custom_fields/formats/_list.html.erb
new file mode 100644
index 000000000..9bbd6a243
--- /dev/null
+++ b/app/views/custom_fields/formats/_list.html.erb
@@ -0,0 +1,6 @@
+<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><%= f.text_field(:default_value) %></p>
+<p><%= edit_tag_style_tag f %></p>
diff --git a/app/views/custom_fields/formats/_numeric.html.erb b/app/views/custom_fields/formats/_numeric.html.erb
new file mode 100644
index 000000000..06187485d
--- /dev/null
+++ b/app/views/custom_fields/formats/_numeric.html.erb
@@ -0,0 +1,2 @@
+<%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
+<p><%= f.text_field(:default_value) %></p>
diff --git a/app/views/custom_fields/formats/_regexp.html.erb b/app/views/custom_fields/formats/_regexp.html.erb
new file mode 100644
index 000000000..0b630347a
--- /dev/null
+++ b/app/views/custom_fields/formats/_regexp.html.erb
@@ -0,0 +1,10 @@
+<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 %>
+ <em class="info"><%= l(:text_min_max_length_info) %></em>
+</p>
+<p>
+ <%= f.text_field :regexp, :size => 50 %>
+ <em class="info"><%= l(:text_regexp_info) %></em>
+</p>
diff --git a/app/views/custom_fields/formats/_string.html.erb b/app/views/custom_fields/formats/_string.html.erb
new file mode 100644
index 000000000..0c71243a8
--- /dev/null
+++ b/app/views/custom_fields/formats/_string.html.erb
@@ -0,0 +1,3 @@
+<%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
+<p><%= f.check_box :text_formatting, {:label => :setting_text_formatting}, 'full', '' %></p>
+<p><%= f.text_field(:default_value) %></p>
diff --git a/app/views/custom_fields/formats/_text.html.erb b/app/views/custom_fields/formats/_text.html.erb
new file mode 100644
index 000000000..e72dcab42
--- /dev/null
+++ b/app/views/custom_fields/formats/_text.html.erb
@@ -0,0 +1,3 @@
+<%= render :partial => 'custom_fields/formats/regexp', :locals => {:f => f, :custom_field => custom_field} %>
+<p><%= f.check_box :text_formatting, {:label => :setting_text_formatting}, 'full', '' %></p>
+<p><%= f.text_area(:default_value, :rows => 5) %></p>
diff --git a/app/views/custom_fields/formats/_user.html.erb b/app/views/custom_fields/formats/_user.html.erb
new file mode 100644
index 000000000..3bb4d29c0
--- /dev/null
+++ b/app/views/custom_fields/formats/_user.html.erb
@@ -0,0 +1,24 @@
+<p>
+ <label><%= l(:label_role) %></label>
+ <label class="block">
+ <%= radio_button_tag 'status', 1, custom_field.user_role.blank?, :id => 'custom_field_user_role_all',
+ :data => {:disables => '.custom_field_user_role input'} %>
+ <%= l(:label_all) %>
+ </label>
+ <label class="block">
+ <%= radio_button_tag 'status', 0, custom_field.user_role.present?, :id => 'custom_field_user_role_only',
+ :data => {:enables => '.custom_field_user_role input'} %>
+ <%= l(:label_only) %>:
+ </label>
+ <% Role.givable.sorted.each do |role| %>
+ <label class="block custom_field_user_role" style="padding-left:2em;">
+ <%= check_box_tag 'custom_field[user_role][]',
+ role.id,
+ custom_field.user_role.is_a?(Array) && custom_field.user_role.include?(role.id.to_s),
+ :id => nil %>
+ <%= role.name %>
+ </label>
+ <% end %>
+ <%= hidden_field_tag 'custom_field[user_role][]', '' %>
+</p>
+<p><%= edit_tag_style_tag f %></p>
diff --git a/app/views/custom_fields/formats/_version.html.erb b/app/views/custom_fields/formats/_version.html.erb
new file mode 100644
index 000000000..b8060d20e
--- /dev/null
+++ b/app/views/custom_fields/formats/_version.html.erb
@@ -0,0 +1,24 @@
+<p>
+ <label><%= l(:field_status) %></label>
+ <label class="block">
+ <%= radio_button_tag 'status', 1, custom_field.version_status.blank?, :id => 'custom_field_version_status_all',
+ :data => {:disables => '.custom_field_version_status input'} %>
+ <%= l(:label_all) %>
+ </label>
+ <label class="block">
+ <%= radio_button_tag 'status', 0, custom_field.version_status.present?, :id => 'custom_field_version_status_only',
+ :data => {:enables => '.custom_field_version_status input'} %>
+ <%= l(:label_only) %>:
+ </label>
+ <% Version::VERSION_STATUSES.each do |status| %>
+ <label class="block custom_field_version_status" style="padding-left:2em;">
+ <%= check_box_tag 'custom_field[version_status][]',
+ status,
+ custom_field.version_status.is_a?(Array) && custom_field.version_status.include?(status),
+ :id => nil %>
+ <%= l("version_status_#{status}") %>
+ </label>
+ <% end %>
+ <%= hidden_field_tag 'custom_field[version_status][]', '' %>
+</p>
+<p><%= edit_tag_style_tag f %></p>
diff --git a/app/views/custom_fields/new.html.erb b/app/views/custom_fields/new.html.erb
index 69328412e..6c5809e73 100644
--- a/app/views/custom_fields/new.html.erb
+++ b/app/views/custom_fields/new.html.erb
@@ -12,7 +12,8 @@ $('#custom_field_field_format').change(function(){
$.ajax({
url: '<%= new_custom_field_path(:format => 'js') %>',
type: 'get',
- data: $('#custom_field_form').serialize()
+ data: $('#custom_field_form').serialize(),
+ complete: toggleDisabledInit
});
});
<% end %>