|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
# Proviedes convinience layer and logic shared between GroupBy::Base and Filter::Base. |
|
|
|
|
# Implements a dubble linked list (FIXME: is that the correct term?). |
|
|
|
|
# Provides convinience layer and logic shared between GroupBy::Base and Filter::Base. |
|
|
|
|
# Implements a double linked list (FIXME: is that the correct term?). |
|
|
|
|
class Report < ActiveRecord::Base |
|
|
|
|
class Chainable |
|
|
|
|
include Enumerable |
|
|
|
@ -63,6 +63,12 @@ class Report < ActiveRecord::Base |
|
|
|
|
name.demodulize.underscore |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def self.put_sql_table_names(table_prefix_placement = {}) |
|
|
|
|
@table_prefix_placement ||= {} |
|
|
|
|
@table_prefix_placement.merge! table_prefix_placement |
|
|
|
|
@table_prefix_placement |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# The given block is called when a new chain is created for a report. |
|
|
|
|
# The query will be given to the block as a parameter. |
|
|
|
@ -72,7 +78,7 @@ class Report < ActiveRecord::Base |
|
|
|
|
engine.chain_initializer.push block |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
inherited_attribute :label |
|
|
|
|
inherited_attribute :label, :default => :translation_needed |
|
|
|
|
inherited_attribute :properties, :list => true |
|
|
|
|
|
|
|
|
|
class << self |
|
|
|
@ -101,7 +107,7 @@ class Report < ActiveRecord::Base |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def to_a |
|
|
|
|
returning([to_hash]) { |a| a.unshift(*child.to_a) unless bottom? } |
|
|
|
|
[to_hash].tap { |a| a.unshift(*child.to_a) unless bottom? } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def top |
|
|
|
@ -285,7 +291,10 @@ class Report < ActiveRecord::Base |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def with_table(fields) |
|
|
|
|
fields.map { |f| field_name_for f, self } |
|
|
|
|
fields.map do |f| |
|
|
|
|
place_field_name = self.class.put_sql_table_names[f] || self.class.put_sql_table_names[f].nil? |
|
|
|
|
place_field_name ? (field_name_for f, self) : f |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def field |
|
|
|
@ -293,4 +302,4 @@ class Report < ActiveRecord::Base |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|