summaryrefslogtreecommitdiffstats
path: root/app/views/custom_fields/_form.html.erb
blob: c5e2824c591efe5f450c4bd569b4317bc9a37ee0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<%= error_messages_for 'custom_field' %>

<div class="splitcontentleft">
<div class="box tabular">
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :disabled => !@custom_field.new_record? %></p>
<p><%= f.text_field :name, :required => true %></p>
<p><%= f.text_area :description, :rows => 7 %></p>

<% if @custom_field.format.multiple_supported %>
<p>
  <%= f.check_box :multiple %>
  <% if !@custom_field.new_record? && @custom_field.multiple %>
  <em class="info"><%= l(:text_turning_multiple_off) %></em>
  <% end %>
</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, :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',
              :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',
              :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), :id => nil %>
          <%= role.name %>
        </label>
      <% end %>
      <%= hidden_field_tag 'custom_field[role_ids][]', '' %>
    </p>

<% when "UserCustomField" %>
    <p><%= f.check_box :is_required %></p>
    <p><%= f.check_box :visible %></p>
    <p><%= f.check_box :editable %></p>
    <p><%= f.check_box :is_filter %></p>

<% 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" %>
    <p><%= f.check_box :is_required %></p>
    <p><%= f.check_box :is_filter %></p>

<% when "GroupCustomField" %>
    <p><%= f.check_box :is_required %></p>
    <p><%= f.check_box :is_filter %></p>

<% when "TimeEntryCustomField" %>
    <p><%= f.check_box :is_required %></p>
    <p><%= f.check_box :is_filter %></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>

<% if @custom_field.is_a?(IssueCustomField) %>
  <fieldset class="box" id="custom_field_tracker_ids"><legend><%=l(:label_tracker_plural)%></legend>
  <% Tracker.sorted.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%>">
      <%= tracker.name %>
    </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>
    <%= render_project_nested_lists(Project.all) do |p|
      content_tag('label', check_box_tag('custom_field[project_ids][]', p.id, @custom_field.projects.to_a.include?(p), :id => nil) + ' ' + p)
    end %>
    <%= hidden_field_tag('custom_field[project_ids][]', '', :id => nil) %>
    <p><%= check_all_links 'custom_field_project_ids' %></p>
  </fieldset>
<% end %>
</div>

<% include_calendar_headers_tags %>