Sha256: d9914d8b14a7e5ee214569c3308106440963db481464c2a09a010be5d0f2c8b4

Contents?: true

Size: 1.54 KB

Versions: 30

Compression:

Stored size: 1.54 KB

Contents

module ActiveAdmin::ReportTemplatesHelper
  def localize_report_fields(data)
    if data.is_a? Array
      data.map do |x|
        localize_report_entry x
      end
    else
      localize_report_entry data
    end
  end

  def localize_report_entry(entry)
    model, name = entry.split '.'

    title =  I18n.t("activerecord.models.#{model}", :count => 1) 
    title += ' / '
    title += I18n.t("activerecord.attributes.#{model}.#{name}")

    [title, entry]
  end

  def localize_report_calculations(builder)
    builder.calculations.keys.map do |x|
      title = I18n.t "smartkiosk.reports.data.#{builder.keyword}.calculations.#{x}"
      [title, x]
    end
  end

  def localize_report_condition_title(builder, field)
    I18n.t "smartkiosk.reports.data.#{builder.keyword}.conditions.#{field}.title"
  end

  def localize_report_condition_value(builder, field, value)
    condition  = builder.conditions[field]
    collection = if condition.is_a?(Array)
      I18n.t "smartkiosk.reports.data.#{builder.keyword}.conditions.#{field}.values"
    else
      condition.call().with_indifferent_access
    end

    return value.is_a?(Array) ? value.map{|x| collection[x]}.join(', ') : collection[value]
  end

  def localize_report_conditions(builder, field)
    condition = builder.conditions[field]

    if condition.is_a?(Array)
      return condition.map do |x|
        title = I18n.t "smartkiosk.reports.data.#{builder.keyword}.conditions.#{field}.values.#{x}"
        [title, x]
      end
    elsif condition.is_a?(Proc)
      return condition.call().invert
    end
  end
end 

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
smartkiosk-server-0.11.6 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.11.5 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.11.4 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.11.3 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.11.2 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.11.1 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.11 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.19 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.18 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.17 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.16 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.15 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.14 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.13 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.12 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.11 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.10 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.9 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.8 app/helpers/active_admin/report_templates_helper.rb
smartkiosk-server-0.10.7 app/helpers/active_admin/report_templates_helper.rb