diff --git a/lib/report/filter/base.rb b/lib/report/filter/base.rb index 890cdc1c21..1a29f31ef2 100644 --- a/lib/report/filter/base.rb +++ b/lib/report/filter/base.rb @@ -28,17 +28,16 @@ class Report::Filter # Filter::Project.dependent --> Filter::Issue # This could result in a UI where, if the Prject-filter was selected, # the Issue-filter automatically shows up. - def self.dependent(klass) - self.dependents << klass + # Arguments: + # - any subclass of Reporting::Filter::Base which shall be the dependent filter + # or nil, if you want to remove the dependent relationship + def self.dependent(*args) + @dependent = args.first unless args.empty? + @dependent end - def self.has_dependents? - @dependents && !@dependents.empty? - end - - def self.dependents(*args) - @dependents ||= [] - @dependents += args + def self.has_dependent? + !!@dependent end def self.cached(*args) @@ -50,17 +49,17 @@ class Report::Filter # all_dependents computes the depentends of this filter and recursively # all_dependents of this class' dependents. def self.all_dependents - self.cached(:compute_injected_dependents) + self.cached(:compute_all_dependents) end def self.compute_all_dependents - if self.has_dependents? - self.dependents.inject(self.dependents) do |ary, dep| - ary + dep.injected_dependents - end.uniq - else - [] + dependents = [] + dep = dependent + while !dep.nil? do + dependents << dep + dep = dep.dependent end + dependents end def value=(val) diff --git a/lib/widget/filters/multi_values.rb b/lib/widget/filters/multi_values.rb index 218bb4276b..549f013c49 100644 --- a/lib/widget/filters/multi_values.rb +++ b/lib/widget/filters/multi_values.rb @@ -11,8 +11,8 @@ class Widget::Filters::MultiValues < Widget::Filters::Base :multiple => "multiple" } # multiple will be disabled/enabled later by JavaScript anyhow. # We need to specify multiple here because of an IE6-bug. - if filter_class.has_dependents? - dependents = filter_class.dependents.map {|d| d.underscore_name}.to_json + if filter_class.has_dependent? + dependents = filter_class.all_dependents.map {|d| d.underscore_name}.to_json select_options.merge! :"data-dependents" => dependents.gsub!('"', "'") end box = content_tag :select, select_options do