--- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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: # --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -49,6 +49,20 @@ (custom_field.default_value.blank? ? "" : '') : '' 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? ? "" : '') : + '' + + select_tag(field_name, blank_option + options_for_select(groups.collect { |x| x.lastname }, custom_value.value), :id => field_id) + else text_field_tag(field_name, custom_value.value, :id => field_id) end --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -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 @@ -71,7 +72,7 @@ casted = nil unless value.blank? case field_format - when 'string', 'text', 'list' + when 'string', 'text', 'list', 'group_list' casted = value when 'date' casted = begin; value.to_date; rescue; nil end @@ -91,7 +92,7 @@ # 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', 'text', 'list', 'date', 'bool', 'group_list' # 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}'" + --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -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)} --- a/app/views/custom_fields/_form.rhtml +++ b/app/views/custom_fields/_form.rhtml @@ -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); --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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