Module: Integral::Backend::BaseHelper

Includes:
SupportHelper
Defined in:
app/helpers/integral/backend/base_helper.rb

Overview

Base Backend Helper

Instance Method Summary collapse

Methods included from SupportHelper

#anchor_to, #display_media_query_indicator?, #method_missing, #render_flashes, #respond_to?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Integral::SupportHelper

Instance Method Details

#body_data_attributesObject

Data which is embedded into the backend <body> tag



26
27
28
29
30
31
32
33
# File 'app/helpers/integral/backend/base_helper.rb', line 26

def body_data_attributes
  {
    locale: I18n.locale,
    'user-name' => current_user.name,
    'user-email' => current_user.email,
    'user-created-at' => current_user.created_at.to_i
  }
end

#dataset_dashboard_atgObject

Donut Graph - At a Glance



52
53
54
55
56
57
58
59
60
61
62
# File 'app/helpers/integral/backend/base_helper.rb', line 52

def dataset_dashboard_atg
  data = [
    { scope: Integral::Page, label: 'Total Pages' },
    { scope: Integral::List, label: 'Total Lists' },
    { scope: Integral::Image, label: 'Total Images' },
    { scope: Integral::User, label: 'Total Users' }
  ]

  data.prepend(scope: Integral::Post, label: 'Total Posts') if Integral.blog_enabled?
  data
end

#dataset_dashboard_last_weekObject

Line graph - Last week



65
66
67
68
69
70
71
72
73
74
75
# File 'app/helpers/integral/backend/base_helper.rb', line 65

def dataset_dashboard_last_week
  data = [
    { scope: Integral::Page, label: 'Pages' },
    { scope: Integral::List, label: 'Lists' },
    { scope: Integral::Image, label: 'Images' },
    { scope: Integral::User, label: 'Users' }
  ]

  data.prepend(scope: Integral::Post, label: 'Posts') if Integral.blog_enabled?
  data
end

#google_tag_manager(type = :script) ⇒ String

Backend Google Tag Manager Snippet

Returns:

  • (String)

    GTM Container if ID has been supplied



37
38
39
# File 'app/helpers/integral/backend/base_helper.rb', line 37

def google_tag_manager(type = :script)
  GoogleTagManager.render(Integral.gtm_container_id, type)
end

#page_titleString

Returns title provided through yield or i18n scoped to controller namespace & action.

Returns:

  • (String)

    title provided through yield or i18n scoped to controller namespace & action



9
10
11
12
13
14
# File 'app/helpers/integral/backend/base_helper.rb', line 9

def page_title
  return content_for(:title) if content_for?(:title)

  # Scope is set to current controller namespace & action
  t('title', scope: "#{controller_path.tr('/', '.')}.#{action_name}")
end

#render_data_gridObject

Renders a grid from a local partial within a datagrid container



17
18
19
20
21
22
23
# File 'app/helpers/integral/backend/base_helper.rb', line 17

def render_data_grid
  return (:div, render(partial: 'grid', locals: { grid: @grid }), data: { 'grid' => true, 'form' => 'grid_form' }) unless block_given?

   :div, data: { 'grid' => true, 'form' => 'grid_form' } do
    yield
  end
end

#render_donut_chart(dataset) ⇒ Object

Renders a donut chart



47
48
49
# File 'app/helpers/integral/backend/base_helper.rb', line 47

def render_donut_chart(dataset)
  ChartRenderer::Donut.render(dataset)
end

#render_line_chart(dataset) ⇒ Object

Renders a line chart



42
43
44
# File 'app/helpers/integral/backend/base_helper.rb', line 42

def render_line_chart(dataset)
  ChartRenderer::Line.render(dataset)
end