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