Module: Integral::Backend::BaseHelper
- Includes:
- SupportHelper
- Defined in:
- app/helpers/integral/backend/base_helper.rb
Overview
Base Backend Helper
Instance Method Summary collapse
-
#body_data_attributes ⇒ Object
Data which is embedded into the backend <body> tag.
-
#dataset_at_a_glance_pages ⇒ Object
Donut Graph - At a Glance.
-
#dataset_at_a_glance_posts ⇒ Object
Donut Graph - At a Glance.
-
#dataset_dashboard_atg ⇒ Object
Donut Graph - At a Glance.
-
#dataset_dashboard_last_week ⇒ Object
Line graph - Last week.
-
#google_tag_manager(type = :script) ⇒ String
Backend Google Tag Manager Snippet.
-
#page_title ⇒ String
Title provided through yield or i18n scoped to controller namespace & action.
- #recent_activity_grid(options) ⇒ Object
-
#recent_site_activity_grid ⇒ Array
Returns array of VersionDecorators subclassed depending on the Version subclass.
-
#recent_user_activity_grid ⇒ Array
Returns array of VersionDecorators subclassed depending on the Version subclass.
-
#render_card(partial, locals = {}) ⇒ String
Integral card.
-
#render_data_grid ⇒ Object
Renders a grid from a local partial within a datagrid container.
-
#render_donut_chart(dataset) ⇒ Object
Renders a donut chart.
-
#render_line_chart(dataset) ⇒ Object
Renders a line chart.
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_attributes ⇒ Object
Data which is embedded into the backend <body> tag
63 64 65 66 67 68 69 70 |
# File 'app/helpers/integral/backend/base_helper.rb', line 63 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_at_a_glance_pages ⇒ Object
Donut Graph - At a Glance
97 98 99 100 101 102 103 |
# File 'app/helpers/integral/backend/base_helper.rb', line 97 def dataset_at_a_glance_pages [ { scope: Integral::Page.published, label: 'Published' }, { scope: Integral::Page.draft, label: 'Draft ' }, { scope: Integral::Page.archived, label: 'Archived ' } ] end |
#dataset_at_a_glance_posts ⇒ Object
Donut Graph - At a Glance
89 90 91 92 93 94 |
# File 'app/helpers/integral/backend/base_helper.rb', line 89 def dataset_at_a_glance_posts [ { scope: Integral::Post.published, label: 'Published' }, { scope: Integral::Post.draft, label: 'Draft ' } ] end |
#dataset_dashboard_atg ⇒ Object
Donut Graph - At a Glance
106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/helpers/integral/backend/base_helper.rb', line 106 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_week ⇒ Object
Line graph - Last week
119 120 121 122 123 124 125 126 127 128 129 |
# File 'app/helpers/integral/backend/base_helper.rb', line 119 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
74 75 76 |
# File 'app/helpers/integral/backend/base_helper.rb', line 74 def google_tag_manager(type = :script) GoogleTagManager.render(Integral.gtm_container_id, type) end |
#page_title ⇒ String
Returns title provided through yield or i18n scoped to controller namespace & action.
40 41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/integral/backend/base_helper.rb', line 40 def page_title return content_for(:title) if content_for?(:title) return t("devise.#{controller_name}.#{action_name}.title") if devise_controller? # Scope is set to current controller namespace & action t('title', scope: "#{controller_path.tr('/', '.')}.#{action_name}", default: I18n.t("integral.backend.titles.#{action_name}", type_singular: resource_klass.model_name.human.capitalize, type_plural: resource_klass.model_name.human(count: 2).capitalize)) end |
#recent_activity_grid(options) ⇒ Object
35 36 37 |
# File 'app/helpers/integral/backend/base_helper.rb', line 35 def recent_activity_grid() Integral::Grids::ActivitiesGrid.new() end |
#recent_site_activity_grid ⇒ Array
Returns array of VersionDecorators subclassed depending on the Version subclass
25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/integral/backend/base_helper.rb', line 25 def recent_site_activity_grid @recent_site_activity_grid ||= begin = {} [:object] = resource_klass.to_s if resource_klass.present? [:item_id] = @resource.id if @resource.present? recent_activity_grid() end end |
#recent_user_activity_grid ⇒ Array
Returns array of VersionDecorators subclassed depending on the Version subclass
14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/integral/backend/base_helper.rb', line 14 def recent_user_activity_grid @recent_user_activity_grid ||= begin = { user: current_user.id } [:object] = resource_klass.to_s if resource_klass.present? [:item_id] = @resource.id if @resource.present? recent_activity_grid() end end |
#render_card(partial, locals = {}) ⇒ String
Returns Integral card.
9 10 11 |
# File 'app/helpers/integral/backend/base_helper.rb', line 9 def render_card(partial, locals = {}) render(partial: "integral/backend/shared/cards/#{partial}", locals: locals) end |
#render_data_grid ⇒ Object
Renders a grid from a local partial within a datagrid container
52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/integral/backend/base_helper.rb', line 52 def render_data_grid unless block_given? return content_tag(:div, render(partial: 'grid', locals: { grid: @grid }), data: { 'grid' => true, 'form' => 'grid_form' }) end content_tag :div, data: { 'grid' => true, 'form' => 'grid_form' } do yield end end |
#render_donut_chart(dataset) ⇒ Object
Renders a donut chart
84 85 86 |
# File 'app/helpers/integral/backend/base_helper.rb', line 84 def render_donut_chart(dataset) ChartRenderer::Donut.render(dataset) end |
#render_line_chart(dataset) ⇒ Object
Renders a line chart
79 80 81 |
# File 'app/helpers/integral/backend/base_helper.rb', line 79 def render_line_chart(dataset) ChartRenderer::Line.render(dataset) end |