Module: QueryReport::ColumnModule

Included in:
Report
Defined in:
lib/query_report/column.rb

Defined Under Namespace

Classes: Column

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



8
9
10
# File 'lib/query_report/column.rb', line 8

def columns
  @columns
end

Instance Method Details

#column(name, options = {}, &block) ⇒ Object

Creates a filter and adds to the filters Params:

column

the column on which the filter is done on

options

Options can have the following, options => date | text | whatever options => the comparators used for ransack search, [:gteq, :lteq] options => set true to calculate total for that column options => the column will appear on the web and not appear in PDF or csv if set to true



18
19
20
# File 'lib/query_report/column.rb', line 18

def column(name, options={}, &block)
  @columns << Column.new(self, name, options, block)
end

#column_total_with_colspanObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/query_report/column.rb', line 22

def column_total_with_colspan
  total_with_colspan = []
  colspan = 0
  total_text_printed = false
  columns.each do |column|
    if column.has_total?
      if colspan > 0
        title = total_text_printed ? '' : I18n.t('query_report.total')
        total_with_colspan << (colspan == 1 ? {content: title} : {content: title, colspan: colspan})
      end
      total_with_colspan << {content: column.total}
      total_text_printed = true
      colspan = 0
    else
      colspan += 1
    end
  end
  if colspan > 0
    total_with_colspan << {content: '', colspan: colspan}
  end
  total_with_colspan
end