Revision 912:5e80956cc792 app/views/custom_fields

View differences:

app/views/custom_fields/_form.html.erb
1
<%= error_messages_for 'custom_field' %>
2

  
3
<script type="text/javascript">
4
//<![CDATA[
5
function toggle_custom_field_format() {
6
  format = $("custom_field_field_format");
7
  p_length = $("custom_field_min_length");
8
  p_regexp = $("custom_field_regexp");
9
  p_values = $("custom_field_possible_values");
10
  p_searchable = $("custom_field_searchable");
11
  p_default = $("custom_field_default_value");
12

  
13
  p_default.setAttribute('type','text');
14
  Element.show(p_default.parentNode);
15

  
16
  switch (format.value) {
17
    case "list":
18
      Element.hide(p_length.parentNode);
19
      Element.hide(p_regexp.parentNode);
20
      if (p_searchable) Element.show(p_searchable.parentNode);
21
      Element.show(p_values.parentNode);
22
      break;
23
    case "bool":
24
      p_default.setAttribute('type','checkbox');
25
      Element.hide(p_length.parentNode);
26
      Element.hide(p_regexp.parentNode);
27
      if (p_searchable) Element.hide(p_searchable.parentNode);
28
      Element.hide(p_values.parentNode);
29
      break;
30
    case "date":
31
      Element.hide(p_length.parentNode);
32
      Element.hide(p_regexp.parentNode);
33
      if (p_searchable) Element.hide(p_searchable.parentNode);
34
      Element.hide(p_values.parentNode);
35
      break;
36
    case "float":
37
    case "int":
38
      Element.show(p_length.parentNode);
39
      Element.show(p_regexp.parentNode);
40
      if (p_searchable) Element.hide(p_searchable.parentNode);
41
      Element.hide(p_values.parentNode);
42
      break;
43
    case "user":
44
    case "version":
45
      Element.hide(p_length.parentNode);
46
      Element.hide(p_regexp.parentNode);
47
      if (p_searchable) Element.hide(p_searchable.parentNode);
48
      Element.hide(p_values.parentNode);
49
      Element.hide(p_default.parentNode);
50
      break;
51
    default:
52
      Element.show(p_length.parentNode);
53
      Element.show(p_regexp.parentNode);
54
      if (p_searchable) Element.show(p_searchable.parentNode);
55
      Element.hide(p_values.parentNode);
56
      break;
57
  }
58
}
59

  
60
//]]>
61
</script>
62

  
63
<div class="box">
64
<p><%= f.text_field :name, :required => true %></p>
65
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :onchange => "toggle_custom_field_format();",
66
                                                                    :disabled => !@custom_field.new_record? %></p>
67
<p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
68
   <%= f.text_field :min_length, :size => 5, :no_label => true %> - 
69
   <%= f.text_field :max_length, :size => 5, :no_label => true %><br />(<%=l(:text_min_max_length_info)%>)</p>
70
<p><%= f.text_field :regexp, :size => 50 %><br />(<%=l(:text_regexp_info)%>)</p>
71
<p>
72
  <%= f.text_area :possible_values, :value => @custom_field.possible_values.to_a.join("\n"), :rows => 15 %>
73
  <br /><em><%= l(:text_custom_field_possible_values_info) %></em>
74
</p>
75
<p><%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %></p>
76
<%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
77
</div>
78

  
79
<div class="box">
80
<% case @custom_field.class.name
81
when "IssueCustomField" %>
82

  
83
    <fieldset><legend><%=l(:label_tracker_plural)%></legend>
84
    <% for tracker in @trackers %>
85
      <%= check_box_tag "custom_field[tracker_ids][]",
86
                        tracker.id,
87
                        (@custom_field.trackers.include? tracker),
88
                        :id => "custom_field_tracker_ids_#{tracker.id}" %>
89
      <label class="no-css" for="custom_field_tracker_ids_<%=tracker.id%>">
90
        <%= h(tracker.name) %>
91
      </label>
92
    <% end %>
93
    <%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
94
    </fieldset>
95
    &nbsp;
96
    <p><%= f.check_box :is_required %></p>
97
    <p><%= f.check_box :is_for_all %></p>
98
    <p><%= f.check_box :is_filter %></p>
99
    <p><%= f.check_box :searchable %></p>
100

  
101
<% when "UserCustomField" %>
102
    <p><%= f.check_box :is_required %></p>
103
    <p><%= f.check_box :visible %></p>
104
    <p><%= f.check_box :editable %></p>
105

  
106
<% when "ProjectCustomField" %>
107
    <p><%= f.check_box :is_required %></p>
108
    <p><%= f.check_box :visible %></p>
109
    <p><%= f.check_box :searchable %></p>
110

  
111
<% when "TimeEntryCustomField" %>
112
    <p><%= f.check_box :is_required %></p>
113

  
114
<% else %>
115
    <p><%= f.check_box :is_required %></p>
116

  
117
<% end %>
118
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
119
</div>
120
<%= javascript_tag "toggle_custom_field_format();" %>
app/views/custom_fields/_form.rhtml
1
<%= error_messages_for 'custom_field' %>
2

  
3
<script type="text/javascript">
4
//<![CDATA[
5
function toggle_custom_field_format() {
6
  format = $("custom_field_field_format");
7
  p_length = $("custom_field_min_length");
8
  p_regexp = $("custom_field_regexp");
9
  p_values = $("custom_field_possible_values");
10
  p_searchable = $("custom_field_searchable");
11
  p_default = $("custom_field_default_value");
12
  
13
  p_default.setAttribute('type','text');
14
  Element.show(p_default.parentNode);
15
  
16
  switch (format.value) {
17
    case "list":
18
      Element.hide(p_length.parentNode);
19
      Element.hide(p_regexp.parentNode);
20
      if (p_searchable) Element.show(p_searchable.parentNode);
21
      Element.show(p_values.parentNode);
22
      break;
23
    case "bool":
24
      p_default.setAttribute('type','checkbox');
25
      Element.hide(p_length.parentNode);
26
      Element.hide(p_regexp.parentNode);
27
      if (p_searchable) Element.hide(p_searchable.parentNode);
28
      Element.hide(p_values.parentNode);
29
      break;
30
    case "date":
31
      Element.hide(p_length.parentNode);
32
      Element.hide(p_regexp.parentNode);
33
      if (p_searchable) Element.hide(p_searchable.parentNode);
34
      Element.hide(p_values.parentNode);
35
      break;
36
    case "float":
37
    case "int":
38
      Element.show(p_length.parentNode);
39
      Element.show(p_regexp.parentNode);
40
      if (p_searchable) Element.hide(p_searchable.parentNode);
41
      Element.hide(p_values.parentNode);
42
      break;
43
		case "user":
44
    case "version":
45
      Element.hide(p_length.parentNode);
46
      Element.hide(p_regexp.parentNode);
47
      if (p_searchable) Element.hide(p_searchable.parentNode);
48
      Element.hide(p_values.parentNode);
49
      Element.hide(p_default.parentNode);
50
		  break;
51
    default:
52
      Element.show(p_length.parentNode);
53
      Element.show(p_regexp.parentNode);
54
      if (p_searchable) Element.show(p_searchable.parentNode);
55
      Element.hide(p_values.parentNode);
56
      break;
57
  }
58
}
59

  
60
//]]>
61
</script>
62

  
63
<div class="box">
64
<p><%= f.text_field :name, :required => true %></p>
65
<p><%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :onchange => "toggle_custom_field_format();",
66
																																		:disabled => !@custom_field.new_record? %></p>
67
<p><label for="custom_field_min_length"><%=l(:label_min_max_length)%></label>
68
   <%= f.text_field :min_length, :size => 5, :no_label => true %> - 
69
   <%= f.text_field :max_length, :size => 5, :no_label => true %><br>(<%=l(:text_min_max_length_info)%>)</p>
70
<p><%= f.text_field :regexp, :size => 50 %><br>(<%=l(:text_regexp_info)%>)</p>
71
<p>
72
	<%= f.text_area :possible_values, :value => @custom_field.possible_values.to_a.join("\n"), :rows => 15 %>
73
  <br /><em><%= l(:text_custom_field_possible_values_info) %></em>
74
</p>
75
<p><%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %></p>
76
<%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
77
</div>
78

  
79
<div class="box">
80
<% case @custom_field.class.name
81
when "IssueCustomField" %>
82
    
83
    <fieldset><legend><%=l(:label_tracker_plural)%></legend>
84
    <% for tracker in @trackers %>
85
        <%= check_box_tag "custom_field[tracker_ids][]", tracker.id, (@custom_field.trackers.include? tracker) %> <%= tracker.name %>
86
    <% end %>
87
		<%= hidden_field_tag "custom_field[tracker_ids][]", '' %>
88
    </fieldset>
89
    &nbsp;
90
    <p><%= f.check_box :is_required %></p>
91
    <p><%= f.check_box :is_for_all %></p>
92
    <p><%= f.check_box :is_filter %></p>
93
    <p><%= f.check_box :searchable %></p>
94
    
95
<% when "UserCustomField" %>
96
    <p><%= f.check_box :is_required %></p>
97
    <p><%= f.check_box :visible %></p>
98
    <p><%= f.check_box :editable %></p>
99

  
100
<% when "ProjectCustomField" %>
101
    <p><%= f.check_box :is_required %></p>
102
    <p><%= f.check_box :visible %></p>
103
    <p><%= f.check_box :searchable %></p>
104

  
105
<% when "TimeEntryCustomField" %>
106
    <p><%= f.check_box :is_required %></p>
107

  
108
<% else %>
109
    <p><%= f.check_box :is_required %></p>
110
    
111
<% end %>
112
<%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
113
</div>
114
<%= javascript_tag "toggle_custom_field_format();" %>
app/views/custom_fields/_index.html.erb
1
<table class="list">
2
  <thead><tr>
3
    <th width="30%"><%=l(:field_name)%></th>
4
    <th><%=l(:field_field_format)%></th>
5
    <th><%=l(:field_is_required)%></th>
6
    <% if tab[:name] == 'IssueCustomField' %>
7
      <th><%=l(:field_is_for_all)%></th>
8
      <th><%=l(:label_used_by)%></th>
9
    <% end %>
10
    <th><%=l(:button_sort)%></th>
11
    <th width="10%"></th>
12
  </tr></thead>
13
  <tbody>
14
  <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
15
    <tr class="<%= cycle("odd", "even") %>">
16
      <td><%= link_to h(custom_field.name), :action => 'edit', :id => custom_field %></td>
17
      <td align="center"><%= l(Redmine::CustomFieldFormat.label_for(custom_field.field_format)) %></td>
18
      <td align="center"><%= checked_image custom_field.is_required? %></td>
19
      <% if tab[:name] == 'IssueCustomField' %>
20
      <td align="center"><%= checked_image custom_field.is_for_all? %></td>
21
      <td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
22
      <% end %>
23
      <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
24
      <td class="buttons">
25
        <%= link_to(l(:button_delete), { :action => 'destroy', :id => custom_field },
26
                                       :method => :post,
27
                                       :confirm => l(:text_are_you_sure),
28
                                       :class => 'icon icon-del') %>
29
      </td>
30
    </tr>
31
  <% end; reset_cycle %>
32
  </tbody>
33
</table>
34

  
35
<p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
app/views/custom_fields/_index.rhtml
1
<table class="list">
2
  <thead><tr>
3
	<th width="30%"><%=l(:field_name)%></th>
4
	<th><%=l(:field_field_format)%></th>
5
	<th><%=l(:field_is_required)%></th>
6
	<% if tab[:name] == 'IssueCustomField' %>
7
	<th><%=l(:field_is_for_all)%></th>
8
	<th><%=l(:label_used_by)%></th>
9
	<% end %>
10
	<th><%=l(:button_sort)%></th>
11
	<th width="10%"></th>
12
  </tr></thead>
13
  <tbody>
14
	<% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
15
		<tr class="<%= cycle("odd", "even") %>">
16
			<td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
17
			<td align="center"><%= l(Redmine::CustomFieldFormat.label_for(custom_field.field_format)) %></td>
18
			<td align="center"><%= checked_image custom_field.is_required? %></td>
19
			<% if tab[:name] == 'IssueCustomField' %>
20
			<td align="center"><%= checked_image custom_field.is_for_all? %></td>
21
			<td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
22
			<% end %>
23
		  <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
24
			<td class="buttons">
25
				<%= link_to(l(:button_delete), { :action => 'destroy', :id => custom_field },
26
																			 :method => :post,
27
																			 :confirm => l(:text_are_you_sure),
28
																			 :class => 'icon icon-del') %>
29
		  </td>
30
		</tr>
31
	<% end; reset_cycle %>
32
  </tbody>
33
</table>
34

  
35
<p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
app/views/custom_fields/edit.html.erb
1
<h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
2
  &#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
3
  &#187; <%=h @custom_field.name %></h2>
4

  
5
<% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "edit", :id => @custom_field } do |f| %>
6
<%= render :partial => 'form', :locals => { :f => f } %>
7
<%= submit_tag l(:button_save) %>
8
<% end %>
app/views/custom_fields/edit.rhtml
1
<h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %> 
2
  &#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.type %>
3
  &#187; <%=h @custom_field.name %></h2>
4

  
5
<% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "edit", :id => @custom_field } do |f| %>
6
<%= render :partial => 'form', :locals => { :f => f } %>
7
<%= submit_tag l(:button_save) %>
8
<% end %>
app/views/custom_fields/index.html.erb
1
<h2><%=l(:label_custom_field_plural)%></h2>
2

  
3
<%= render_tabs custom_fields_tabs %>
4

  
5
<% html_title(l(:label_custom_field_plural)) -%>
app/views/custom_fields/index.rhtml
1
<h2><%=l(:label_custom_field_plural)%></h2>
2

  
3
<%= render_tabs custom_fields_tabs %>
4

  
5
<% html_title(l(:label_custom_field_plural)) -%>
app/views/custom_fields/new.html.erb
1
<h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
2
  &#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.class.name %>
3
  &#187; <%= l(:label_custom_field_new) %></h2>
4

  
5
<% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "new" } do |f| %>
6
<%= render :partial => 'form', :locals => { :f => f } %>
7
<%= hidden_field_tag 'type', @custom_field.type %>
8
<%= submit_tag l(:button_save) %>
9
<% end %>
app/views/custom_fields/new.rhtml
1
<h2><%= link_to l(:label_custom_field_plural), :controller => 'custom_fields', :action => 'index' %>
2
  &#187; <%= link_to l(@custom_field.type_name), :controller => 'custom_fields', :action => 'index', :tab => @custom_field.type %>
3
  &#187; <%= l(:label_custom_field_new) %></h2>
4

  
5
<% labelled_tabular_form_for :custom_field, @custom_field, :url => { :action => "new" } do |f| %>
6
<%= render :partial => 'form', :locals => { :f => f } %>
7
<%= hidden_field_tag 'type', @custom_field.type %>
8
<%= submit_tag l(:button_save) %>
9
<% end %>

Also available in: Unified diff