diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 054bac8..bc9c004 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -56,6 +56,15 @@ module ApplicationHelper 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: # diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 40a4c78..8e3d793 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -49,6 +49,20 @@ module CustomFieldsHelper (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 diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index c7031af..a6c2849 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -25,8 +25,9 @@ class CustomField < ActiveRecord::Base "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 @@ class CustomField < ActiveRecord::Base 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 @@ class CustomField < ActiveRecord::Base # 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}'" + diff --git a/app/models/issue.rb b/app/models/issue.rb index 012661c..3d24229 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -387,6 +387,9 @@ class Issue < ActiveRecord::Base # 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)} diff --git a/app/views/custom_fields/_form.rhtml b/app/views/custom_fields/_form.rhtml index 9871567..fe690b3 100644 --- a/app/views/custom_fields/_form.rhtml +++ b/app/views/custom_fields/_form.rhtml @@ -20,6 +20,15 @@ function toggle_custom_field_format() { 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); diff --git a/config/locales/en.yml b/config/locales/en.yml index 4082670..dfc2085 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -478,6 +478,10 @@ en: 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