Class: Decidim::MetricChartsPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::MetricChartsPresenter
- Defined in:
- app/presenters/decidim/metric_charts_presenter.rb
Overview
A presenter to render metrics in pages
Instance Method Summary collapse
-
#highlighted ⇒ Object
Public: Render a collection of primary metrics.
- #highlighted_metrics ⇒ Object
-
#not_highlighted ⇒ Object
Public: Render a collection of metrics that are not primary.
- #not_highlighted_metrics ⇒ Object
- #render_charts(charts) ⇒ Object
- #render_metrics(metrics) ⇒ Object
- #view_context ⇒ Object
Instance Method Details
#highlighted ⇒ Object
Public: Render a collection of primary metrics.
13 14 15 |
# File 'app/presenters/decidim/metric_charts_presenter.rb', line 13 def highlighted render_metrics(highlighted_metrics) end |
#highlighted_metrics ⇒ Object
22 23 24 |
# File 'app/presenters/decidim/metric_charts_presenter.rb', line 22 def highlighted_metrics Decidim.metrics_registry.filtered(highlight: true, scope: "home") end |
#not_highlighted ⇒ Object
Public: Render a collection of metrics that are not primary.
18 19 20 |
# File 'app/presenters/decidim/metric_charts_presenter.rb', line 18 def not_highlighted render_metrics(not_highlighted_metrics) end |
#not_highlighted_metrics ⇒ Object
26 27 28 |
# File 'app/presenters/decidim/metric_charts_presenter.rb', line 26 def not_highlighted_metrics Decidim.metrics_registry.filtered(highlight: false, scope: "home") end |
#render_charts(charts) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/presenters/decidim/metric_charts_presenter.rb', line 30 def render_charts(charts) safe_join( charts.map do |metric_manifest| render_metric(metric_manifest.metric_name, title: I18n.t("decidim.metrics.#{metric_manifest.metric_name}.title"), description: I18n.t("decidim.metrics.#{metric_manifest.metric_name}.description"), download: true, data: { ratio: "11:4", axis: true }).html_safe end ) end |
#render_metrics(metrics) ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/presenters/decidim/metric_charts_presenter.rb', line 42 def render_metrics(metrics) safe_join( metrics.map do |metric| render_metric(metric.metric_name, klass: metrics_class) end ) end |
#view_context ⇒ Object
8 9 10 |
# File 'app/presenters/decidim/metric_charts_presenter.rb', line 8 def view_context @view_context ||= __getobj__.fetch(:view_context, ActionController::Base.new.view_context) end |