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
# 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)

@ -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

Loading…
Cancel
Save