Class: Avo::Dashboards::BaseDashboard
- Inherits:
-
Object
- Object
- Avo::Dashboards::BaseDashboard
- Extended by:
- ActiveSupport::DescendantsTracker
- Defined in:
- lib/avo/dashboards/base_dashboard.rb
Class Method Summary collapse
- .card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {}) ⇒ Object
- .classes ⇒ Object
- .divider(**args) ⇒ Object
- .is_hidden? ⇒ Boolean
- .is_visible? ⇒ Boolean
- .item_at_index(index) ⇒ Object
- .items ⇒ Object
- .navigation_label ⇒ Object
- .navigation_path ⇒ Object
- .options_deprecation_message ⇒ Object
Class Method Details
.card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 19 def card(klass, label: nil, description: nil, cols: nil, rows: nil, refresh_every: nil, options: {}, arguments: {}) if .present? self.items_holder ||= [] self.items_holder << klass.new(dashboard: self, label: label, description: description, cols: cols, rows: rows, refresh_every: refresh_every, options: , arguments: arguments, index: index ) self.index += 1 end |
.classes ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 54 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
44 45 46 47 48 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 44 def divider(**args) self.items_holder ||= [] self.items_holder << BaseDivider.new(**args) end |
.is_hidden? ⇒ Boolean
89 90 91 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 89 def is_hidden? !is_visible? end |
.is_visible? ⇒ Boolean
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 77 def is_visible? # Default is true return true if visible == true # Hide if false return false if visible == false if visible.respond_to? :call ::Avo::Hosts::DashboardVisibility.new(block: visible, dashboard: self).handle end end |
.item_at_index(index) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 36 def item_at_index(index) items.find do |item| next if item.index.blank? item.index == index end end |
.items ⇒ Object
50 51 52 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 50 def items self.items_holder end |
.navigation_label ⇒ Object
69 70 71 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 69 def name end |
.navigation_path ⇒ Object
73 74 75 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 73 def Avo::App.view_context.avo.dashboard_path id end |
.options_deprecation_message ⇒ Object
15 16 17 |
# File 'lib/avo/dashboards/base_dashboard.rb', line 15 def Rails.logger.warn "DEPRECATION WARNING: Card options parameter is deprecated in favor of arguments parameter and will be removed from Avo version 3.0.0" end |