##// END OF EJS Templates
Display custom fields in two columns on the issue form....
Jean-Philippe Lang -
r1072:0b4a02f607a1
parent child
Show More
@@ -0,0 +1,9
1 <div class="splitcontentleft">
2 <% values.each_with_index do |value, i| %>
3 <p><%= custom_field_tag_with_label value %></p>
4 <% if i >= values.size / 2 - 1 %>
5 </div><div class="splitcontentright">
6 <% end %>
7 <% end %>
8 </div>
9 <div style="clear:both;"> </div>
@@ -1,77 +1,77
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module CustomFieldsHelper
18 module CustomFieldsHelper
19
19
20 # Return custom field html tag corresponding to its format
20 # Return custom field html tag corresponding to its format
21 def custom_field_tag(custom_value)
21 def custom_field_tag(custom_value)
22 custom_field = custom_value.custom_field
22 custom_field = custom_value.custom_field
23 field_name = "custom_fields[#{custom_field.id}]"
23 field_name = "custom_fields[#{custom_field.id}]"
24 field_id = "custom_fields_#{custom_field.id}"
24 field_id = "custom_fields_#{custom_field.id}"
25
25
26 case custom_field.field_format
26 case custom_field.field_format
27 when "date"
27 when "date"
28 text_field('custom_value', 'value', :name => field_name, :id => field_id, :size => 10) +
28 text_field('custom_value', 'value', :name => field_name, :id => field_id, :size => 10) +
29 calendar_for(field_id)
29 calendar_for(field_id)
30 when "text"
30 when "text"
31 text_area 'custom_value', 'value', :name => field_name, :id => field_id, :cols => 60, :rows => 3
31 text_area 'custom_value', 'value', :name => field_name, :id => field_id, :rows => 3, :style => 'width:99%'
32 when "bool"
32 when "bool"
33 check_box 'custom_value', 'value', :name => field_name, :id => field_id
33 check_box 'custom_value', 'value', :name => field_name, :id => field_id
34 when "list"
34 when "list"
35 select 'custom_value', 'value', custom_field.possible_values, { :include_blank => true }, :name => field_name, :id => field_id
35 select 'custom_value', 'value', custom_field.possible_values, { :include_blank => true }, :name => field_name, :id => field_id
36 else
36 else
37 text_field 'custom_value', 'value', :name => field_name, :id => field_id
37 text_field 'custom_value', 'value', :name => field_name, :id => field_id
38 end
38 end
39 end
39 end
40
40
41 # Return custom field label tag
41 # Return custom field label tag
42 def custom_field_label_tag(custom_value)
42 def custom_field_label_tag(custom_value)
43 content_tag "label", custom_value.custom_field.name +
43 content_tag "label", custom_value.custom_field.name +
44 (custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>" : ""),
44 (custom_value.custom_field.is_required? ? " <span class=\"required\">*</span>" : ""),
45 :for => "custom_fields_#{custom_value.custom_field.id}",
45 :for => "custom_fields_#{custom_value.custom_field.id}",
46 :class => (custom_value.errors.empty? ? nil : "error" )
46 :class => (custom_value.errors.empty? ? nil : "error" )
47 end
47 end
48
48
49 # Return custom field tag with its label tag
49 # Return custom field tag with its label tag
50 def custom_field_tag_with_label(custom_value)
50 def custom_field_tag_with_label(custom_value)
51 custom_field_label_tag(custom_value) + custom_field_tag(custom_value)
51 custom_field_label_tag(custom_value) + custom_field_tag(custom_value)
52 end
52 end
53
53
54 # Return a string used to display a custom value
54 # Return a string used to display a custom value
55 def show_value(custom_value)
55 def show_value(custom_value)
56 return "" unless custom_value
56 return "" unless custom_value
57 format_value(custom_value.value, custom_value.custom_field.field_format)
57 format_value(custom_value.value, custom_value.custom_field.field_format)
58 end
58 end
59
59
60 # Return a string used to display a custom value
60 # Return a string used to display a custom value
61 def format_value(value, field_format)
61 def format_value(value, field_format)
62 return "" unless value && !value.empty?
62 return "" unless value && !value.empty?
63 case field_format
63 case field_format
64 when "date"
64 when "date"
65 begin; format_date(value.to_date); rescue; value end
65 begin; format_date(value.to_date); rescue; value end
66 when "bool"
66 when "bool"
67 l_YesNo(value == "1")
67 l_YesNo(value == "1")
68 else
68 else
69 value
69 value
70 end
70 end
71 end
71 end
72
72
73 # Return an array of custom field formats which can be used in select_tag
73 # Return an array of custom field formats which can be used in select_tag
74 def custom_field_formats_for_select
74 def custom_field_formats_for_select
75 CustomField::FIELD_FORMATS.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] }
75 CustomField::FIELD_FORMATS.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] }
76 end
76 end
77 end
77 end
@@ -1,59 +1,58
1 <%= error_messages_for 'issue' %>
1 <%= error_messages_for 'issue' %>
2 <div class="box">
2 <div class="box">
3
3
4 <% if @issue.new_record? %>
4 <% if @issue.new_record? %>
5 <p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p>
5 <p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p>
6 <%= observe_field :issue_tracker_id, :url => { :action => :new },
6 <%= observe_field :issue_tracker_id, :url => { :action => :new },
7 :update => :content,
7 :update => :content,
8 :with => "Form.serialize('issue-form')" %>
8 :with => "Form.serialize('issue-form')" %>
9 <% end %>
9 <% end %>
10
10
11 <div class="splitcontentleft">
11 <div class="splitcontentleft">
12 <% if @issue.new_record? %>
12 <% if @issue.new_record? %>
13 <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p>
13 <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p>
14 <% else %>
14 <% else %>
15 <p><label><%= l(:field_status) %></label> <%= @issue.status.name %></p>
15 <p><label><%= l(:field_status) %></label> <%= @issue.status.name %></p>
16 <% end %>
16 <% end %>
17
17
18 <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
18 <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
19 <p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p>
19 <p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p>
20 <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
20 <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
21 <%= prompt_to_remote(l(:label_issue_category_new),
21 <%= prompt_to_remote(l(:label_issue_category_new),
22 l(:label_issue_category_new), 'category[name]',
22 l(:label_issue_category_new), 'category[name]',
23 {:controller => 'projects', :action => 'add_issue_category', :id => @project},
23 {:controller => 'projects', :action => 'add_issue_category', :id => @project},
24 :class => 'small') if authorize_for('projects', 'add_issue_category') %></p>
24 :class => 'small') if authorize_for('projects', 'add_issue_category') %></p>
25 </div>
25 </div>
26
26
27 <div class="splitcontentright">
27 <div class="splitcontentright">
28 <p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
28 <p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
29 <p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p>
29 <p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p>
30 <p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p>
30 <p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p>
31 <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
31 <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
32 </div>
32 </div>
33
33
34 <p><%= f.text_field :subject, :size => 80, :required => true %></p>
34 <p><%= f.text_field :subject, :size => 80, :required => true %></p>
35 <p><%= f.text_area :description, :required => true,
35 <p><%= f.text_area :description, :required => true,
36 :cols => 60,
36 :cols => 60,
37 :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min),
37 :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min),
38 :accesskey => accesskey(:edit),
38 :accesskey => accesskey(:edit),
39 :class => 'wiki-edit' %></p>
39 :class => 'wiki-edit' %></p>
40 <p><%= f.select :fixed_version_id, (@project.versions.sort.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
40 <p><%= f.select :fixed_version_id, (@project.versions.sort.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
41 <% for @custom_value in @custom_values %>
41
42 <p><%= custom_field_tag_with_label @custom_value %></p>
42 <%= render :partial => 'form_custom_fields', :locals => {:values => @custom_values} %>
43 <% end %>
44
43
45 <% if @issue.new_record? %>
44 <% if @issue.new_record? %>
46 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
45 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
47 <%= image_to_function "add.png", "addFileField();return false" %></label>
46 <%= image_to_function "add.png", "addFileField();return false" %></label>
48 <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
47 <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
49 <% end %>
48 <% end %>
50 </div>
49 </div>
51
50
52 <%= wikitoolbar_for 'issue_description' %>
51 <%= wikitoolbar_for 'issue_description' %>
53
52
54 <% content_for :header_tags do %>
53 <% content_for :header_tags do %>
55 <%= javascript_include_tag 'calendar/calendar' %>
54 <%= javascript_include_tag 'calendar/calendar' %>
56 <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
55 <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
57 <%= javascript_include_tag 'calendar/calendar-setup' %>
56 <%= javascript_include_tag 'calendar/calendar-setup' %>
58 <%= stylesheet_link_tag 'calendar' %>
57 <%= stylesheet_link_tag 'calendar' %>
59 <% end %>
58 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now