Feature #3543 » 0101-adstec-custom_field_richtext.patch
| redmine/app/helpers/custom_fields_helper.rb 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
|
calendar_for(field_id)
|
||
|
when "text"
|
||
|
text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 3, :style => 'width:90%')
|
||
|
when "richtext"
|
||
|
text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 6, :style => 'width:99%')
|
||
|
when "bool"
|
||
|
hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, :id => field_id)
|
||
|
when "list"
|
||
| ... | ... | |
|
calendar_for(field_id)
|
||
|
when "text"
|
||
|
text_area_tag(field_name, '', :id => field_id, :rows => 3, :style => 'width:90%')
|
||
|
when "richtext"
|
||
|
text_area_tag(field_name, '', :id => field_id, :rows => 5, :style => 'width:90%')
|
||
|
when "bool"
|
||
|
select_tag(field_name, options_for_select([[l(:label_no_change_option), ''],
|
||
|
[l(:general_text_yes), '1'],
|
||
| redmine/app/helpers/issues_helper.rb 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
|
|
||
|
def render_custom_fields_rows(issue)
|
||
|
return if issue.custom_field_values.empty?
|
||
|
# values that share a column
|
||
|
ordered_values = []
|
||
|
half = (issue.custom_field_values.size / 2.0).ceil
|
||
|
half.times do |i|
|
||
|
ordered_values << issue.custom_field_values[i]
|
||
|
ordered_values << issue.custom_field_values[i + half]
|
||
|
# values that have their own column
|
||
|
ordered_values_single = []
|
||
|
issue.custom_field_values.size.times do |i|
|
||
|
if issue.custom_field_values[i].custom_field.field_format=="richtext"
|
||
|
ordered_values_single << issue.custom_field_values[i]
|
||
|
else
|
||
|
ordered_values << issue.custom_field_values[i]
|
||
|
end
|
||
|
end
|
||
|
s = "<tr>\n"
|
||
|
n = 0
|
||
| ... | ... | |
|
n += 1
|
||
|
end
|
||
|
s << "</tr>\n"
|
||
|
ordered_values_single.compact.each do |value|
|
||
|
s << "<tr>\n"
|
||
|
s << "\t<th colspan=\"4\">#{ h(value.custom_field.name) }:</th></tr><tr><td colspan=\"4\" class=\"wiki\">#{textilizable(h(show_value(value)))}</td>\n"
|
||
|
s << "</tr>\n"
|
||
|
end
|
||
|
# output the result
|
||
|
s
|
||
|
end
|
||
|
|
||
| redmine/app/models/custom_field.rb 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
|
|
||
|
FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 },
|
||
|
"text" => { :name => :label_text, :order => 2 },
|
||
|
"int" => { :name => :label_integer, :order => 3 },
|
||
|
"float" => { :name => :label_float, :order => 4 },
|
||
|
"list" => { :name => :label_list, :order => 5 },
|
||
|
"date" => { :name => :label_date, :order => 6 },
|
||
|
"bool" => { :name => :label_boolean, :order => 7 }
|
||
|
"richtext" => { :name => :label_richtext, :order => 3 },
|
||
|
"int" => { :name => :label_integer, :order => 4 },
|
||
|
"float" => { :name => :label_float, :order => 5 },
|
||
|
"list" => { :name => :label_list, :order => 6 },
|
||
|
"date" => { :name => :label_date, :order => 7 },
|
||
|
"bool" => { :name => :label_boolean, :order => 8 }
|
||
|
}.freeze
|
||
|
validates_presence_of :name, :field_format
|
||
| ... | ... | |
|
casted = nil
|
||
|
unless value.blank?
|
||
|
case field_format
|
||
|
when 'string', 'text', 'list'
|
||
|
when 'string', 'text', 'list', 'richtext'
|
||
|
casted = value
|
||
|
when 'date'
|
||
|
casted = begin; value.to_date; rescue; nil end
|
||
| ... | ... | |
|
# Returns false, if the custom field can not be used for sorting.
|
||
|
def order_statement
|
||
|
case field_format
|
||
|
when 'string', 'text', 'list', 'date', 'bool'
|
||
|
when 'string', 'richtext', 'text', 'list', 'date', 'bool'
|
||
|
# COALESCE is here to make sure that blank and NULL values are sorted equally
|
||
|
"COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
|
||
|
" WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
|
||
| redmine/app/models/query.rb 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
|
|
||
|
custom_fields.select(&:is_filter?).each do |field|
|
||
|
case field.field_format
|
||
|
when "richtext"
|
||
|
options = { :type => :text, :order => 20 }
|
||
|
when "text"
|
||
|
options = { :type => :text, :order => 20 }
|
||
|
when "list"
|
||
| redmine/app/views/issues/_form.rhtml 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
|
<%= call_hook(:view_issues_form_details_bottom, { :issue => @issue, :form => f }) %>
|
||
|
<!-- add toolbar for description field -->
|
||
|
<%= wikitoolbar_for 'issue_description' %>
|
||
|
<!-- add toolbar for custom fields -->
|
||
|
<% @issue.custom_field_values.each do |value| %>
|
||
|
<% if value.custom_field.field_format == "richtext" %>
|
||
|
<%= wikitoolbar_for "issue_custom_field_values_#{value.custom_field.id}" %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
| redmine/app/views/issues/_form_custom_fields.rhtml 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
|
<div class="splitcontentleft">
|
||
|
<% i = 0 %>
|
||
|
<% split_on = (@issue.custom_field_values.size / 2.0).ceil - 1 %>
|
||
|
<% single_field = [] %>
|
||
|
<% double_field = [] %>
|
||
|
<% @issue.custom_field_values.each do |value| %>
|
||
|
<% if value.custom_field.field_format == "richtext" %>
|
||
|
<% single_field << value %>
|
||
|
<% else %>
|
||
|
<% double_field << value %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
<% split_on = (double_field.size / 2.0).ceil - 1 %>
|
||
|
<% double_field.each do |value| %>
|
||
|
<p><%= custom_field_tag_with_label :issue, value %></p>
|
||
|
<% if i == split_on -%>
|
||
|
</div><div class="splitcontentright">
|
||
|
<% end -%>
|
||
|
<% i += 1 -%>
|
||
|
<% if i == split_on -%>
|
||
|
</div><div class="splitcontentright">
|
||
|
<% end -%>
|
||
|
<% i += 1 -%>
|
||
|
<% end -%>
|
||
|
</div>
|
||
|
<div style="clear:both;"> </div>
|
||
|
<% single_field.each do |value| %>
|
||
|
<p><%= custom_field_tag_with_label :issue, value %></p>
|
||
|
<% end -%>
|
||
| redmine/config/locales/de.yml 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
|
label_boolean: Boolean
|
||
|
label_string: Text
|
||
|
label_text: Langer Text
|
||
|
label_richtext: Wiki Text
|
||
|
label_attribute: Attribut
|
||
|
label_attribute_plural: Attribute
|
||
|
label_download: "{{count}} Download"
|
||