Module: LcpRuby::DashboardHelper

Defined in:
app/helpers/lcp_ruby/dashboard_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_kpi_value(value, format_type) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/lcp_ruby/dashboard_helper.rb', line 3

def format_kpi_value(value, format_type)
  return value.to_s if value.nil?

  case format_type&.to_s
  when "currency"
    number_with_delimiter(number_with_precision(value, precision: 2))
  when "percentage"
    "#{number_with_precision(value, precision: 1)}%"
  when "decimal"
    number_with_precision(value, precision: 2)
  when "integer"
    number_with_delimiter(value.to_i)
  else
    number_with_delimiter(value)
  end
end

#grid_style_for(zone) ⇒ Object



20
21
22
23
24
25
# File 'app/helpers/lcp_ruby/dashboard_helper.rb', line 20

def grid_style_for(zone)
  pos = zone.grid_position
  return "" if pos.empty?

  pos.map { |prop, val| "#{prop}: #{val}" }.join("; ")
end

#widget_partial_for(zone) ⇒ Object Also known as: zone_partial_for



27
28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/lcp_ruby/dashboard_helper.rb', line 27

def widget_partial_for(zone)
  if zone.widget?
    "lcp_ruby/widgets/#{zone.widget['type']}"
  elsif zone.custom?
    "lcp_ruby/zones/custom_zone"
  elsif zone.record_source?
    "lcp_ruby/widgets/record_show_zone"
  else
    "lcp_ruby/widgets/presenter_zone"
  end
end

#zone_renderable?(data) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/helpers/lcp_ruby/dashboard_helper.rb', line 41

def zone_renderable?(data)
  data.present? && !data[:hidden] && !data[:tab_only]
end