Merge branch 'feature/dependent' of https://dev.finn.de/git/reporting-engine into feature/dependent

pull/6827/head
Tim Felgentreff 14 years ago
commit 350a6f42b0
  1. 31
      lib/report/filter/base.rb
  2. 4
      lib/widget/filters/multi_values.rb

@ -28,17 +28,16 @@ class Report::Filter
# Filter::Project.dependent --> Filter::Issue # Filter::Project.dependent --> Filter::Issue
# This could result in a UI where, if the Prject-filter was selected, # This could result in a UI where, if the Prject-filter was selected,
# the Issue-filter automatically shows up. # the Issue-filter automatically shows up.
def self.dependent(klass) # Arguments:
self.dependents << klass # - 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 end
def self.has_dependents? def self.has_dependent?
@dependents && !@dependents.empty? !!@dependent
end
def self.dependents(*args)
@dependents ||= []
@dependents += args
end end
def self.cached(*args) def self.cached(*args)
@ -50,17 +49,17 @@ class Report::Filter
# all_dependents computes the depentends of this filter and recursively # all_dependents computes the depentends of this filter and recursively
# all_dependents of this class' dependents. # all_dependents of this class' dependents.
def self.all_dependents def self.all_dependents
self.cached(:compute_injected_dependents) self.cached(:compute_all_dependents)
end end
def self.compute_all_dependents def self.compute_all_dependents
if self.has_dependents? dependents = []
self.dependents.inject(self.dependents) do |ary, dep| dep = dependent
ary + dep.injected_dependents while !dep.nil? do
end.uniq dependents << dep
else dep = dep.dependent
[]
end end
dependents
end end
def value=(val) def value=(val)

@ -11,8 +11,8 @@ class Widget::Filters::MultiValues < Widget::Filters::Base
:multiple => "multiple" } :multiple => "multiple" }
# multiple will be disabled/enabled later by JavaScript anyhow. # multiple will be disabled/enabled later by JavaScript anyhow.
# We need to specify multiple here because of an IE6-bug. # We need to specify multiple here because of an IE6-bug.
if filter_class.has_dependents? if filter_class.has_dependent?
dependents = filter_class.dependents.map {|d| d.underscore_name}.to_json dependents = filter_class.all_dependents.map {|d| d.underscore_name}.to_json
select_options.merge! :"data-dependents" => dependents.gsub!('"', "'") select_options.merge! :"data-dependents" => dependents.gsub!('"', "'")
end end
box = content_tag :select, select_options do box = content_tag :select, select_options do

Loading…
Cancel
Save