Feature #3543 » 0101-adstec-custom_field_richtext.patch
| redmine/app/helpers/custom_fields_helper.rb 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
| 42 | 42 |
calendar_for(field_id) |
| 43 | 43 |
when "text" |
| 44 | 44 |
text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 3, :style => 'width:90%') |
| 45 |
when "richtext" |
|
| 46 |
text_area_tag(field_name, custom_value.value, :id => field_id, :rows => 6, :style => 'width:99%') |
|
| 45 | 47 |
when "bool" |
| 46 | 48 |
hidden_field_tag(field_name, '0') + check_box_tag(field_name, '1', custom_value.true?, :id => field_id) |
| 47 | 49 |
when "list" |
| ... | ... | |
| 76 | 78 |
calendar_for(field_id) |
| 77 | 79 |
when "text" |
| 78 | 80 |
text_area_tag(field_name, '', :id => field_id, :rows => 3, :style => 'width:90%') |
| 81 |
when "richtext" |
|
| 82 |
text_area_tag(field_name, '', :id => field_id, :rows => 5, :style => 'width:90%') |
|
| 79 | 83 |
when "bool" |
| 80 | 84 |
select_tag(field_name, options_for_select([[l(:label_no_change_option), ''], |
| 81 | 85 |
[l(:general_text_yes), '1'], |
| redmine/app/helpers/issues_helper.rb 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
| 33 | 33 |
|
| 34 | 34 |
def render_custom_fields_rows(issue) |
| 35 | 35 |
return if issue.custom_field_values.empty? |
| 36 |
# values that share a column |
|
| 36 | 37 |
ordered_values = [] |
| 37 |
half = (issue.custom_field_values.size / 2.0).ceil |
|
| 38 |
half.times do |i| |
|
| 39 |
ordered_values << issue.custom_field_values[i] |
|
| 40 |
ordered_values << issue.custom_field_values[i + half] |
|
| 38 |
# values that have their own column |
|
| 39 |
ordered_values_single = [] |
|
| 40 |
issue.custom_field_values.size.times do |i| |
|
| 41 |
if issue.custom_field_values[i].custom_field.field_format=="richtext" |
|
| 42 |
ordered_values_single << issue.custom_field_values[i] |
|
| 43 |
else |
|
| 44 |
ordered_values << issue.custom_field_values[i] |
|
| 45 |
end |
|
| 41 | 46 |
end |
| 42 | 47 |
s = "<tr>\n" |
| 43 | 48 |
n = 0 |
| ... | ... | |
| 47 | 52 |
n += 1 |
| 48 | 53 |
end |
| 49 | 54 |
s << "</tr>\n" |
| 55 |
ordered_values_single.compact.each do |value| |
|
| 56 |
s << "<tr>\n" |
|
| 57 |
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"
|
|
| 58 |
s << "</tr>\n" |
|
| 59 |
end |
|
| 60 |
# output the result |
|
| 50 | 61 |
s |
| 51 | 62 |
end |
| 52 | 63 |
|
| redmine/app/models/custom_field.rb 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
| 22 | 22 |
|
| 23 | 23 |
FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 },
|
| 24 | 24 |
"text" => { :name => :label_text, :order => 2 },
|
| 25 |
"int" => { :name => :label_integer, :order => 3 },
|
|
| 26 |
"float" => { :name => :label_float, :order => 4 },
|
|
| 27 |
"list" => { :name => :label_list, :order => 5 },
|
|
| 28 |
"date" => { :name => :label_date, :order => 6 },
|
|
| 29 |
"bool" => { :name => :label_boolean, :order => 7 }
|
|
| 25 |
"richtext" => { :name => :label_richtext, :order => 3 },
|
|
| 26 |
"int" => { :name => :label_integer, :order => 4 },
|
|
| 27 |
"float" => { :name => :label_float, :order => 5 },
|
|
| 28 |
"list" => { :name => :label_list, :order => 6 },
|
|
| 29 |
"date" => { :name => :label_date, :order => 7 },
|
|
| 30 |
"bool" => { :name => :label_boolean, :order => 8 }
|
|
| 30 | 31 |
}.freeze |
| 31 | 32 | |
| 32 | 33 |
validates_presence_of :name, :field_format |
| ... | ... | |
| 71 | 72 |
casted = nil |
| 72 | 73 |
unless value.blank? |
| 73 | 74 |
case field_format |
| 74 |
when 'string', 'text', 'list' |
|
| 75 |
when 'string', 'text', 'list', 'richtext'
|
|
| 75 | 76 |
casted = value |
| 76 | 77 |
when 'date' |
| 77 | 78 |
casted = begin; value.to_date; rescue; nil end |
| ... | ... | |
| 91 | 92 |
# Returns false, if the custom field can not be used for sorting. |
| 92 | 93 |
def order_statement |
| 93 | 94 |
case field_format |
| 94 |
when 'string', 'text', 'list', 'date', 'bool' |
|
| 95 |
when 'string', 'richtext', 'text', 'list', 'date', 'bool'
|
|
| 95 | 96 |
# COALESCE is here to make sure that blank and NULL values are sorted equally |
| 96 | 97 |
"COALESCE((SELECT cv_sort.value FROM #{CustomValue.table_name} cv_sort" +
|
| 97 | 98 |
" WHERE cv_sort.customized_type='#{self.class.customized_class.name}'" +
|
| redmine/app/models/query.rb 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
| 537 | 537 |
|
| 538 | 538 |
custom_fields.select(&:is_filter?).each do |field| |
| 539 | 539 |
case field.field_format |
| 540 |
when "richtext" |
|
| 541 |
options = { :type => :text, :order => 20 }
|
|
| 540 | 542 |
when "text" |
| 541 | 543 |
options = { :type => :text, :order => 20 }
|
| 542 | 544 |
when "list" |
| redmine/app/views/issues/_form.rhtml 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
| 30 | 30 | |
| 31 | 31 |
<%= call_hook(:view_issues_form_details_bottom, { :issue => @issue, :form => f }) %>
|
| 32 | 32 | |
| 33 |
<!-- add toolbar for description field --> |
|
| 33 | 34 |
<%= wikitoolbar_for 'issue_description' %> |
| 35 |
<!-- add toolbar for custom fields --> |
|
| 36 |
<% @issue.custom_field_values.each do |value| %> |
|
| 37 |
<% if value.custom_field.field_format == "richtext" %> |
|
| 38 |
<%= wikitoolbar_for "issue_custom_field_values_#{value.custom_field.id}" %>
|
|
| 39 |
<% end %> |
|
| 40 |
<% end %> |
|
| redmine/app/views/issues/_form_custom_fields.rhtml 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
| 1 | 1 |
<div class="splitcontentleft"> |
| 2 | 2 |
<% i = 0 %> |
| 3 |
<% split_on = (@issue.custom_field_values.size / 2.0).ceil - 1 %> |
|
| 3 |
<% single_field = [] %> |
|
| 4 |
<% double_field = [] %> |
|
| 4 | 5 |
<% @issue.custom_field_values.each do |value| %> |
| 6 |
<% if value.custom_field.field_format == "richtext" %> |
|
| 7 |
<% single_field << value %> |
|
| 8 |
<% else %> |
|
| 9 |
<% double_field << value %> |
|
| 10 |
<% end %> |
|
| 11 |
<% end %> |
|
| 12 | ||
| 13 |
<% split_on = (double_field.size / 2.0).ceil - 1 %> |
|
| 14 |
<% double_field.each do |value| %> |
|
| 5 | 15 |
<p><%= custom_field_tag_with_label :issue, value %></p> |
| 6 |
<% if i == split_on -%> |
|
| 7 |
</div><div class="splitcontentright"> |
|
| 8 |
<% end -%> |
|
| 9 |
<% i += 1 -%> |
|
| 16 |
<% if i == split_on -%>
|
|
| 17 |
</div><div class="splitcontentright">
|
|
| 18 |
<% end -%>
|
|
| 19 |
<% i += 1 -%>
|
|
| 10 | 20 |
<% end -%> |
| 11 | 21 |
</div> |
| 12 | 22 |
<div style="clear:both;"> </div> |
| 23 |
<% single_field.each do |value| %> |
|
| 24 |
<p><%= custom_field_tag_with_label :issue, value %></p> |
|
| 25 |
<% end -%> |
|
| redmine/config/locales/de.yml 2010-05-05 13:50:50.000000000 +0200 | ||
|---|---|---|
| 460 | 460 |
label_boolean: Boolean |
| 461 | 461 |
label_string: Text |
| 462 | 462 |
label_text: Langer Text |
| 463 |
label_richtext: Wiki Text |
|
| 463 | 464 |
label_attribute: Attribut |
| 464 | 465 |
label_attribute_plural: Attribute |
| 465 | 466 |
label_download: "{{count}} Download"
|