Index: app/helpers/issues_helper.rb
===================================================================
--- app/helpers/issues_helper.rb (revision 3544)
+++ app/helpers/issues_helper.rb (working copy)
@@ -43,11 +43,14 @@
n = 0
ordered_values.compact.each do |value|
s << "\n
\n" if n > 0 && (n % 2) == 0
- s << "\t#{ h(value.custom_field.name) }: #{ simple_format_without_paragraph(h(show_value(value))) } \n"
+ s << "\t#{ h(value.custom_field.name) }: "
+ s << value.custom_field.field_format == "group_list" ? show_value_on_view(value) : simple_format_without_paragraph(h(show_value(value)))
+ s << " \n"
n += 1
end
s << " \n"
- s
+
+ return s
end
def sidebar_queries
@@ -115,11 +118,20 @@
unless no_html
label = content_tag('strong', label)
- old_value = content_tag("i", h(old_value)) if detail.old_value
+
+ if !custom_field.nil? && custom_field.field_format == 'group_list'
+ old_value = content_tag("i", old_value) if detail.old_value
+ else
+ old_value = content_tag("i", h(old_value)) if detail.old_value
+ end
+
old_value = content_tag("strike", old_value) if detail.old_value and (!detail.value or detail.value.empty?)
+
if detail.property == 'attachment' && !value.blank? && a = Attachment.find_by_id(detail.prop_key)
# Link to the attachment if it has not been removed
value = link_to_attachment(a)
+ elsif !custom_field.nil? && custom_field.field_format == 'group_list'
+ value = content_tag("i", value) if value
else
value = content_tag("i", h(value)) if value
end
Index: app/helpers/custom_fields_helper.rb
===================================================================
--- app/helpers/custom_fields_helper.rb (revision 3544)
+++ app/helpers/custom_fields_helper.rb (working copy)
@@ -49,6 +49,20 @@
(custom_field.default_value.blank? ? "--- #{l(:actionview_instancetag_blank_option)} --- " : '') :
' '
select_tag(field_name, blank_option + options_for_select(custom_field.possible_values, custom_value.value), :id => field_id)
+
+ when 'group_list'
+ groups = @project.principals
+ groups.delete_if { |group| group.type != 'Group' }
+
+ custom_field.possible_values.clear()
+ groups.each { |group| custom_field.possible_values << group if group.type == 'Group' }
+
+ blank_option = custom_field.is_required? ?
+ (custom_field.default_value.blank? ? "--- #{l(:actionview_instancetag_blank_option)} --- " : '') :
+ ' '
+
+ select_tag(field_name, blank_option + options_for_select(groups.collect { |x| [x.lastname, x.id] }, custom_value.value), :id => field_id)
+
else
text_field_tag(field_name, custom_value.value, :id => field_id)
end
@@ -101,6 +115,8 @@
begin; format_date(value.to_date); rescue; value end
when "bool"
l(value == "1" ? :general_text_Yes : :general_text_No)
+ when 'group_list':
+ link_to_group(Group.find(:first, :conditions => [ 'id = ?', value]))
else
value
end
@@ -110,4 +126,22 @@
def custom_field_formats_for_select
CustomField::FIELD_FORMATS.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] }
end
+
+ # Return a string used to display a custom value on the issues view
+ def format_value_for_view(value, field_format)
+ return "-" unless value && !value.empty?
+
+ case field_format
+ when 'group_list'
+ link_to_group(Group.find(:first, :conditions => [ 'id = ?', value]))
+ else
+ format_value(value, field_format)
+ end
+ end
+
+ def show_value_on_view(custom_value)
+ return "" unless custom_value
+ format_value_for_view(custom_value.value, custom_value.custom_field.field_format)
+ end
+
end
Index: app/helpers/application_helper.rb
===================================================================
--- app/helpers/application_helper.rb (revision 3544)
+++ app/helpers/application_helper.rb (working copy)
@@ -58,6 +58,15 @@
end
end
+ # Displays a link to the group
+ def link_to_group(group, options={})
+ if group.is_a?(Group)
+ link_to group.lastname, :controller => 'groups', :action => 'show', :id => group
+ else
+ h(group.to_s)
+ end
+ end
+
# Displays a link to +issue+ with its subject.
# Examples:
#
Index: app/models/issue.rb
===================================================================
--- app/models/issue.rb (revision 3544)
+++ app/models/issue.rb (working copy)
@@ -328,6 +328,9 @@
# Author and assignee are always notified unless they have been locked
notified << author if author && author.active?
notified << assigned_to if assigned_to && assigned_to.active?
+
+ ## EEH: TODO: add Group-email addresses here at some point
+
notified.uniq!
# Remove users that can not view the issue
notified.reject! {|user| !visible?(user)}
Index: app/models/custom_field.rb
===================================================================
--- app/models/custom_field.rb (revision 3544)
+++ app/models/custom_field.rb (working copy)
@@ -25,8 +25,9 @@
"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 }
+ "date" => { :name => :label_date, :order => 6 },
+ "bool" => { :name => :label_boolean, :order => 7 },
+ "group_list" => { :name => :label_group_list, :order => 8 },
}.freeze
validates_presence_of :name, :field_format
Index: app/views/custom_fields/_form.rhtml
===================================================================
--- app/views/custom_fields/_form.rhtml (revision 3544)
+++ app/views/custom_fields/_form.rhtml (working copy)
@@ -20,6 +20,15 @@
if (p_searchable) Element.show(p_searchable.parentNode);
Element.show(p_values);
break;
+
+ case 'group_list':
+ p_default.setAttribute('type','combolist');
+ Element.hide(p_length.parentNode);
+ Element.hide(p_regexp.parentNode);
+ if (p_searchable) Element.show(p_searchable.parentNode);
+ Element.hide(p_values);
+ break;
+
case "bool":
p_default.setAttribute('type','checkbox');
Element.hide(p_length.parentNode);
Index: app/views/projects/show.rhtml
===================================================================
--- app/views/projects/show.rhtml (revision 3544)
+++ app/views/projects/show.rhtml (working copy)
@@ -16,7 +16,7 @@
<% end %>
<% @project.custom_values.each do |custom_value| %>
<% if !custom_value.value.blank? %>
- <%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
+ <%= custom_value.custom_field.name%>: <%= custom_value.custom_field.field_format == "group_list" ? h(show_value_on_view(custom_value)) : h(show_value(custom_value)) %>
<% end %>
<% end %>
Index: config/locales/en.yml
===================================================================
--- config/locales/en.yml (revision 3544)
+++ config/locales/en.yml (working copy)
@@ -475,6 +475,10 @@
label_and_its_subprojects: "{{value}} and its subprojects"
label_min_max_length: Min - Max length
label_list: List
+
+ ## EEH: TODO: Translation
+ label_group_list: Group List
+
label_date: Date
label_integer: Integer
label_float: Float