effective_pages 3.4.13 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 370a0872726ab5cc18dca40bf8bdafaef20ac8cfc145600fa1679abe2253059f
4
- data.tar.gz: e9e3de8d9fd1e68ee1421a96cf6a0fb15af8014421edf95493e2146d067e8f26
3
+ metadata.gz: cf8ab6a872f5612cfc81a80d9a4616ef18ca85dc6b360e693fb24cd6039ced4e
4
+ data.tar.gz: 903d3aec8b320e7a69e6cd01a971e2ef3c09f57ed38103e357e031b9fd418090
5
5
  SHA512:
6
- metadata.gz: 16f78050a37aa5785fea91281c439dd6ad275377374969569f4e5d9b34b8b287b9d930494eb91b7481f6ac29a57a42e52ea8ededfeb5775928c7e1b32188c034
7
- data.tar.gz: cbea464d3c44f65a05b0d20bad91ea2e18d12c40968885f09fcfa9f4d80605148dfee04c3cb3e0364e72b4328de82a332a4f1f1add499278568d9d1ba749edc6
6
+ metadata.gz: d4c3f5328c83713f2efba331743bcd99870432f2ba9d5defcda5926a82c2ad6d124191fec7987cb87442cc6d681869d8a4ccbf917394657f4d30be940b208479
7
+ data.tar.gz: 7a8fad535372027cd5b87b2b0f72508f26731d6e07b3d0ef7e6b6bb007396674306cbe9e8f37974ad134d577d65989036a7d7774331d08dec0345191a7f02e2a
@@ -0,0 +1,15 @@
1
+ module Admin
2
+ class AlertsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_pages) }
5
+
6
+ include Effective::CrudController
7
+
8
+ page_title 'Alerts'
9
+
10
+ def permitted_params
11
+ params.require(:effective_alert).permit!
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ class EffectiveAlertsDatatable < Effective::Datatable
2
+
3
+ datatable do
4
+ col :id, visible: false
5
+ col :updated_at, visible: false
6
+
7
+ col :enabled
8
+
9
+ col :rich_text_body, label: 'Content'
10
+
11
+ actions_col
12
+ end
13
+
14
+ collection do
15
+ Effective::Alert.deep.all
16
+ end
17
+
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module EffectiveAlertsHelper
3
+
4
+ def effective_alerts
5
+ @_effective_alerts ||= Effective::Alert.all.enabled
6
+ end
7
+
8
+ def render_effective_alerts
9
+ effective_alerts
10
+ .map { |alert| render 'effective/alerts/alert', alert: alert }
11
+ .join
12
+ .html_safe
13
+ end
14
+
15
+ end
@@ -0,0 +1,25 @@
1
+ module Effective
2
+ class Alert < ApplicationRecord
3
+ self.table_name = (EffectivePages.alerts_table_name || :alerts).to_s
4
+
5
+ log_changes if respond_to?(:log_changes)
6
+
7
+ has_rich_text :body
8
+
9
+ effective_resource do
10
+ enabled :boolean
11
+
12
+ timestamps
13
+ end
14
+
15
+ scope :deep, -> { with_rich_text_body }
16
+ scope :enabled, -> { where(enabled: true) }
17
+
18
+ validates :body, presence: true
19
+
20
+ def to_s
21
+ 'alert'
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ = tabs do
2
+ = tab 'Alert' do
3
+ = render '/admin/alerts/form_alert', alert: alert
4
+
5
+ - if alert.persisted?
6
+ = tab 'Logs' do
7
+ = render_datatable(alert.log_changes_datatable, inline: true, namespace: :admin)
@@ -0,0 +1,9 @@
1
+ = effective_form_with(model: [:admin, alert], engine: true) do |f|
2
+ = f.check_box :enabled, hint: 'Toggle activation of this alert'
3
+
4
+ - if defined?(EffectiveArticleEditor)
5
+ = f.article_editor :body, label: 'Content', hint: 'Content to be displayed'
6
+ - else
7
+ = f.rich_text_area :body, label: 'Content', hint: 'Content to be displayed'
8
+
9
+ = effective_submit(f)
@@ -0,0 +1,4 @@
1
+ %div{class: "alert alert-warning", role: 'alert'}
2
+ .container
3
+ .row
4
+ .col= alert.body
@@ -3,6 +3,7 @@ EffectivePages.setup do |config|
3
3
  config.page_sections_table_name = :page_sections
4
4
  config.page_banners_table_name = :page_banners
5
5
  config.carousel_items_table_name = :carousel_items
6
+ config.alerts_table_name = :alerts
6
7
 
7
8
  # The menu names a page can belong to
8
9
  config.menus = [:main, :footer]
data/config/routes.rb CHANGED
@@ -7,6 +7,7 @@ EffectivePages::Engine.routes.draw do
7
7
  resources :page_banners, except: [:show]
8
8
  resources :menus, only: [:index]
9
9
  resources :carousel_items, except: [:show]
10
+ resources :alerts, except: [:show]
10
11
  end
11
12
 
12
13
  scope module: 'effective' do
@@ -75,6 +75,12 @@ class CreateEffectivePages < ActiveRecord::Migration[4.2]
75
75
  t.timestamps
76
76
  end
77
77
 
78
+ create_table <%= @alerts_table_name %>, if_not_exists: true do |t|
79
+ t.boolean :enabled
80
+
81
+ t.timestamps
82
+ end
83
+
78
84
  end
79
85
 
80
86
  def self.down
@@ -82,6 +88,7 @@ class CreateEffectivePages < ActiveRecord::Migration[4.2]
82
88
  drop_table <%= @page_banners_table_name %>
83
89
  drop_table <%= @page_sections_table_name %>
84
90
  drop_table <%= @carousel_items_table_name %>
91
+ drop_table <%= @alerts_table_name %>
85
92
  end
86
93
 
87
94
  end
@@ -11,6 +11,7 @@ module EffectivePages
11
11
  helper EffectivePageSectionsHelper
12
12
  helper EffectivePageBannersHelper
13
13
  helper EffectiveMenusHelper
14
+ helper EffectiveAlertsHelper
14
15
  end
15
16
  end
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePages
2
- VERSION = '3.4.13'.freeze
2
+ VERSION = '3.5.0'.freeze
3
3
  end
@@ -7,7 +7,7 @@ require 'effective_pages/version'
7
7
  module EffectivePages
8
8
  def self.config_keys
9
9
  [
10
- :pages_table_name, :page_sections_table_name, :page_banners_table_name, :carousel_items_table_name,
10
+ :pages_table_name, :page_sections_table_name, :page_banners_table_name, :carousel_items_table_name, :alerts_table_name,
11
11
  :pages_path, :excluded_pages, :layouts_path, :excluded_layouts,
12
12
  :site_og_image, :site_og_image_width, :site_og_image_height,
13
13
  :site_title, :site_title_suffix, :fallback_meta_description, :google_analytics_code,
@@ -24,6 +24,7 @@ module EffectivePages
24
24
  @page_sections_table_name = ':' + EffectivePages.page_sections_table_name.to_s
25
25
  @page_banners_table_name = ':' + EffectivePages.page_banners_table_name.to_s
26
26
  @carousel_items_table_name = ':' + EffectivePages.carousel_items_table_name.to_s
27
+ @alerts_table_name = ':' + EffectivePages.alerts_table_name.to_s
27
28
 
28
29
  migration_template ('../' * 3) + 'db/migrate/01_create_effective_pages.rb.erb', 'db/migrate/create_effective_pages.rb'
29
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.13
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-31 00:00:00.000000000 Z
11
+ date: 2023-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -78,26 +78,32 @@ files:
78
78
  - app/assets/config/effective_pages_manifest.js
79
79
  - app/assets/javascripts/effective_pages.js
80
80
  - app/assets/javascripts/effective_pages/google_analytics.js
81
+ - app/controllers/admin/alerts_controller.rb
81
82
  - app/controllers/admin/carousel_items_controller.rb
82
83
  - app/controllers/admin/menus_controller.rb
83
84
  - app/controllers/admin/page_banners_controller.rb
84
85
  - app/controllers/admin/page_sections_controller.rb
85
86
  - app/controllers/admin/pages_controller.rb
86
87
  - app/controllers/effective/pages_controller.rb
88
+ - app/datatables/effective_alerts_datatable.rb
87
89
  - app/datatables/effective_carousel_items_datatable.rb
88
90
  - app/datatables/effective_page_banners_datatable.rb
89
91
  - app/datatables/effective_page_sections_datatable.rb
90
92
  - app/datatables/effective_pages_datatable.rb
91
93
  - app/datatables/effective_pages_menu_datatable.rb
94
+ - app/helpers/effective_alerts_helper.rb
92
95
  - app/helpers/effective_carousels_helper.rb
93
96
  - app/helpers/effective_menus_helper.rb
94
97
  - app/helpers/effective_page_banners_helper.rb
95
98
  - app/helpers/effective_page_sections_helper.rb
96
99
  - app/helpers/effective_pages_helper.rb
100
+ - app/models/effective/alert.rb
97
101
  - app/models/effective/carousel_item.rb
98
102
  - app/models/effective/page.rb
99
103
  - app/models/effective/page_banner.rb
100
104
  - app/models/effective/page_section.rb
105
+ - app/views/admin/alerts/_form.html.haml
106
+ - app/views/admin/alerts/_form_alert.html.haml
101
107
  - app/views/admin/carousel_items/_form.html.haml
102
108
  - app/views/admin/carousel_items/_form_carousel_item.html.haml
103
109
  - app/views/admin/carousel_items/index.html.haml
@@ -112,6 +118,7 @@ files:
112
118
  - app/views/admin/pages/_form_menu.html.haml
113
119
  - app/views/admin/pages/_form_page.html.haml
114
120
  - app/views/admin/pages/_rich_text_areas.html.haml
121
+ - app/views/effective/alerts/_alert.html.haml
115
122
  - app/views/effective/carousels/_carousel.html.haml
116
123
  - app/views/effective/pages/_menu.html.haml
117
124
  - app/views/effective/pages/_page_menu.html.haml