Project

General

Profile

Patch #5119 » group-list_custom_field.diff

Fri Flaj, 2010-03-18 17:19

View differences:

app/helpers/application_helper.rb
58 58
    end
59 59
  end
60 60

  
61
  # Displays a link to the group
62
  def link_to_group(group, options={})
63
    if group.is_a?(Group)
64
      link_to group.lastname, :controller => 'groups', :action => 'show', :id => group
65
    else
66
      h(group.to_s)
67
    end
68
  end
69

  
61 70
  # Displays a link to +issue+ with its subject.
62 71
  # Examples:
63 72
  # 
64
-- a/app/helpers/custom_fields_helper.rb
73
++ b/app/helpers/custom_fields_helper.rb
......
49 49
                       (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') : 
50 50
                       '<option></option>'
51 51
      select_tag(field_name, blank_option + options_for_select(custom_field.possible_values, custom_value.value), :id => field_id)
52

  
53
    when 'group_list'
54
      groups = @project.principals
55
      groups.delete_if { |group| group.type != 'Group' }
56

  
57
      custom_field.possible_values.clear()
58
      groups.each { |group| custom_field.possible_values << group if group.type == 'Group' }
59

  
60
      blank_option = custom_field.is_required? ?
61
                        (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') : 
62
                        '<option></option>'
63

  
64
      select_tag(field_name, blank_option + options_for_select(groups.collect { |x| x.lastname }, custom_value.value), :id => field_id)
65

  
52 66
    else
53 67
      text_field_tag(field_name, custom_value.value, :id => field_id)
54 68
    end
55
-- a/app/models/custom_field.rb
69
++ b/app/models/custom_field.rb
......
25 25
                    "int" => { :name => :label_integer, :order => 3 },
26 26
                    "float" => { :name => :label_float, :order => 4 },
27 27
                    "list" => { :name => :label_list, :order => 5 },
28
			        "date" => { :name => :label_date, :order => 6 },
29
			        "bool" => { :name => :label_boolean, :order => 7 }
28
                    "date" => { :name => :label_date, :order => 6 },
29
                    "bool" => { :name => :label_boolean, :order => 7 },
30
                    "group_list" => { :name => :label_group_list, :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', 'group_list'
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', 'text', 'list', 'date', 'bool', 'group_list'
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}'" +
98
-- a/app/models/issue.rb
99
++ b/app/models/issue.rb
......
328 328
    # Author and assignee are always notified unless they have been locked
329 329
    notified << author if author && author.active?
330 330
    notified << assigned_to if assigned_to && assigned_to.active?
331

  
332
    ## EEH: TODO: add Group-email addresses here at some point
333

  
331 334
    notified.uniq!
332 335
    # Remove users that can not view the issue
333 336
    notified.reject! {|user| !visible?(user)}
334
-- a/app/views/custom_fields/_form.rhtml
337
++ b/app/views/custom_fields/_form.rhtml
......
20 20
      if (p_searchable) Element.show(p_searchable.parentNode);
21 21
      Element.show(p_values);
22 22
      break;
23

  
24
    case 'group_list':
25
      p_default.setAttribute('type','combolist');
26
      Element.hide(p_length.parentNode);
27
      Element.hide(p_regexp.parentNode);
28
      if (p_searchable) Element.show(p_searchable.parentNode);
29
      Element.hide(p_values);
30
      break;
31

  
23 32
    case "bool":
24 33
      p_default.setAttribute('type','checkbox');
25 34
      Element.hide(p_length.parentNode);
26
-- a/config/locales/en.yml
35
++ b/config/locales/en.yml
......
475 475
  label_and_its_subprojects: "{{value}} and its subprojects"
476 476
  label_min_max_length: Min - Max length
477 477
  label_list: List
478

  
479
  ## EEH: TODO: Translation
480
  label_group_list: Group List
481

  
478 482
  label_date: Date
479 483
  label_integer: Integer
480 484
  label_float: Float
(1-1/2)