Class: Jav::Dashboards::BaseDashboard

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::DescendantsTracker, Concerns::VisibleInDashboard
Defined in:
lib/jav/dashboards/base_dashboard.rb

Class Method Summary collapse

Methods included from Concerns::VisibleInDashboard

call_block, is_hidden?, is_visible?

Class Method Details

.card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {}, visible: nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jav/dashboards/base_dashboard.rb', line 23

def card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {}, visible: nil)
  options_deprecation_message if options.present?
  self.items_holder ||= []

  self.items_holder << klass.new(
    dashboard: self,
    label: label,
    description: description,
    cols: cols,
    rows: rows,
    refresh_every: refresh_every,
    options: options,
    arguments: arguments,
    index: index,
    visible: visible
  )
  self.index += 1
end

.classesObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/jav/dashboards/base_dashboard.rb', line 62

def classes
  case grid_cols
  when 3
    "sm:grid-cols-3"
  when 4
    "sm:grid-cols-4"
  when 5
    "sm:grid-cols-5"
  when 6
    "sm:grid-cols-6"
  else
    "sm:grid-cols-3"
  end
end

.divider(**args) ⇒ Object



50
51
52
53
54
# File 'lib/jav/dashboards/base_dashboard.rb', line 50

def divider(**args)
  self.items_holder ||= []

  self.items_holder << BaseDivider.new(dashboard: self, **args)
end

.item_at_index(index) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/jav/dashboards/base_dashboard.rb', line 42

def item_at_index(index)
  items.find do |item|
    next if item.index.blank?

    item.index == index
  end
end

.itemsObject



56
57
58
59
60
# File 'lib/jav/dashboards/base_dashboard.rb', line 56

def items
  items = self.items_holder || []

  items.filter(&:is_visible?)
end


77
78
79
# File 'lib/jav/dashboards/base_dashboard.rb', line 77

def navigation_label
  name
end


81
82
83
# File 'lib/jav/dashboards/base_dashboard.rb', line 81

def navigation_path
  Jav::App.view_context.jav.dashboard_path id
end

.options_deprecation_messageObject



19
20
21
# File 'lib/jav/dashboards/base_dashboard.rb', line 19

def options_deprecation_message
  Rails.logger.warn "DEPRECATION WARNING: Card options parameter is deprecated in favor of arguments parameter and will be removed from Jav version 3.0.0"
end