diff options
author | Go MAEDA <maeda@farend.jp> | 2019-08-18 03:26:19 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-08-18 03:26:19 +0000 |
commit | 79a47823b2bd9cf95001d1519017e63f9ac20872 (patch) | |
tree | d3509050e643771fec3588fd629019a823089dde | |
parent | 0d4ed123886e931183cd1a0e776bc9bd0bf3ff2d (diff) | |
download | redmine-79a47823b2bd9cf95001d1519017e63f9ac20872.tar.gz redmine-79a47823b2bd9cf95001d1519017e63f9ac20872.zip |
Refactor custom fields form (#31859).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@18376 e93f8b46-1217-0410-a6f0-8f06a7374b81
3 files changed, 44 insertions, 84 deletions
diff --git a/app/views/custom_fields/_form.html.erb b/app/views/custom_fields/_form.html.erb index e428a27c6..97d39f96b 100644 --- a/app/views/custom_fields/_form.html.erb +++ b/app/views/custom_fields/_form.html.erb @@ -31,101 +31,37 @@ </div> <div class="splitcontentright"> -<% case @custom_field.class.name -when "IssueCustomField" %> - <div class="box tabular"> - <p><%= f.check_box :is_required %></p> - <% if @custom_field.format.is_filter_supported %> - <p><%= f.check_box :is_filter %></p> - <% end %> - <% if @custom_field.format.searchable_supported %> - <p><%= f.check_box :searchable %></p> - <% end %> - </div> - <%= render :partial => 'visibility_by_role_selector' %> - -<% when "UserCustomField" %> - <div class="box tabular"> - <p><%= f.check_box :is_required %></p> - <p><%= f.check_box :visible %></p> - <p><%= f.check_box :editable %></p> - <% if @custom_field.format.is_filter_supported %> - <p><%= f.check_box :is_filter %></p> - <% end %> - </div> + <div class="box tabular"> + <p><%= f.check_box :is_required %></p> -<% when "ProjectCustomField" %> - <div class="box tabular"> - <p><%= f.check_box :is_required %></p> + <% if %w(UserCustomField ProjectCustomField).include?(@custom_field.class.name) %> <p><%= f.check_box :visible %></p> - <% if @custom_field.format.searchable_supported %> - <p><%= f.check_box :searchable %></p> - <% end %> - <% if @custom_field.format.is_filter_supported %> - <p><%= f.check_box :is_filter %></p> - <% end %> - </div> + <% end %> -<% when "VersionCustomField" %> - <div class="box tabular"> - <p><%= f.check_box :is_required %></p> - <% if @custom_field.format.is_filter_supported %> - <p><%= f.check_box :is_filter %></p> - <% end %> - </div> - -<% when "GroupCustomField" %> - <div class="box tabular"> - <p><%= f.check_box :is_required %></p> - <% if @custom_field.format.is_filter_supported %> - <p><%= f.check_box :is_filter %></p> - <% end %> - </div> + <% if @custom_field.is_a?(UserCustomField) %> + <p><%= f.check_box :editable %></p> + <% end %> -<% when "TimeEntryCustomField" %> - <div class="box tabular"> - <p><%= f.check_box :is_required %></p> - <% if @custom_field.format.is_filter_supported %> + <% if %w(IssueCustomField UserCustomField ProjectCustomField VersionCustomField GroupCustomField TimeEntryCustomField).include?(@custom_field.class.name) && + @custom_field.format.is_filter_supported %> <p><%= f.check_box :is_filter %></p> - <% end %> - </div> - <%= render :partial => 'visibility_by_role_selector' %> + <% end %> -<% else %> - <div class="box tabular"> - <p><%= f.check_box :is_required %></p> + <% if %w(IssueCustomField ProjectCustomField).include?(@custom_field.class.name) && @custom_field.format.searchable_supported %> + <p><%= f.check_box :searchable %></p> + <% end %> + <%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %> </div> -<% end %> -<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %> - -<% if @custom_field.is_a?(IssueCustomField) %> - <fieldset class="box" id="custom_field_tracker_ids"><legend><%= toggle_checkboxes_link("#custom_field_tracker_ids input[type=checkbox]") %><%=l(:label_tracker_plural)%></legend> - <% tracker_ids = @custom_field.tracker_ids %> - <% Tracker.sorted.each do |tracker| %> - <%= check_box_tag "custom_field[tracker_ids][]", - tracker.id, - tracker_ids.include?(tracker.id), - :id => "custom_field_tracker_ids_#{tracker.id}" %> - <label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>"> - <%= tracker.name %> - </label> + <% if %w(IssueCustomField TimeEntryCustomField).include?(@custom_field.class.name) %> + <%= render :partial => 'visibility_by_role_selector', :locals => { :f => f } %> <% end %> - <%= hidden_field_tag "custom_field[tracker_ids][]", '' %> - </fieldset> - <fieldset class="box"><legend><%= toggle_checkboxes_link("#custom_field_project_ids input[type=checkbox]:enabled") %><%= l(:label_project_plural) %></legend> - <p><%= f.check_box :is_for_all, :data => {:disables => '#custom_field_project_ids input'} %></p> + <% if @custom_field.is_a?(IssueCustomField) %> + <%= render :partial => 'visibility_by_tracker_selector', :locals => { :f => f } %> - <div id="custom_field_project_ids"> - <% project_ids = @custom_field.project_ids.to_a %> - <%= render_project_nested_lists(Project.all) do |p| - content_tag('label', check_box_tag('custom_field[project_ids][]', p.id, project_ids.include?(p.id), :id => nil) + ' ' + p) - end %> - <%= hidden_field_tag('custom_field[project_ids][]', '', :id => nil) %> - </div> - </fieldset> -<% end %> + <%= render :partial => 'visibility_by_project_selector', :locals => { :f => f } %> + <% end %> </div> </div> diff --git a/app/views/custom_fields/_visibility_by_project_selector.html.erb b/app/views/custom_fields/_visibility_by_project_selector.html.erb new file mode 100644 index 000000000..d92e5cdab --- /dev/null +++ b/app/views/custom_fields/_visibility_by_project_selector.html.erb @@ -0,0 +1,11 @@ +<fieldset class="box"><legend><%= toggle_checkboxes_link("#custom_field_project_ids input[type=checkbox]:enabled") %><%= l(:label_project_plural) %></legend> + <p><%= f.check_box :is_for_all, :data => {:disables => '#custom_field_project_ids input'} %></p> + + <div id="custom_field_project_ids"> + <% project_ids = @custom_field.project_ids.to_a %> + <%= render_project_nested_lists(Project.all) do |p| + content_tag('label', check_box_tag('custom_field[project_ids][]', p.id, project_ids.include?(p.id), :id => nil) + ' ' + p) + end %> + <%= hidden_field_tag('custom_field[project_ids][]', '', :id => nil) %> + </div> +</fieldset> diff --git a/app/views/custom_fields/_visibility_by_tracker_selector.html.erb b/app/views/custom_fields/_visibility_by_tracker_selector.html.erb new file mode 100644 index 000000000..289849dbb --- /dev/null +++ b/app/views/custom_fields/_visibility_by_tracker_selector.html.erb @@ -0,0 +1,13 @@ +<fieldset class="box" id="custom_field_tracker_ids"><legend><%= toggle_checkboxes_link("#custom_field_tracker_ids input[type=checkbox]") %><%=l(:label_tracker_plural)%></legend> + <% tracker_ids = @custom_field.tracker_ids %> + <% Tracker.sorted.each do |tracker| %> + <%= check_box_tag "custom_field[tracker_ids][]", + tracker.id, + tracker_ids.include?(tracker.id), + :id => "custom_field_tracker_ids_#{tracker.id}" %> + <label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>"> + <%= tracker.name %> + </label> + <% end %> + <%= hidden_field_tag "custom_field[tracker_ids][]", '' %> +</fieldset> |