effective_pages 3.8.4 → 3.9.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 +4 -4
- data/README.md +27 -0
- data/app/datatables/effective_pages_menu_datatable.rb +2 -0
- data/app/helpers/effective_menus_helper.rb +1 -3
- data/app/models/effective/page.rb +16 -3
- data/app/views/effective/pages/_menu.html.haml +3 -6
- data/app/views/effective/pages/_page_menu.html.haml +6 -6
- data/db/migrate/101_create_effective_pages.rb +2 -0
- data/lib/effective_pages/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de13a6ce9afb0cee9e8401e076c3416a159f9a64f4a5fb7cf70c890de442263f
|
4
|
+
data.tar.gz: dfa2b67769948a6e25c5c20e3b1520260f494d0722165cfd5a78eeff1aeb3ce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11295b2af4904ad5469948123e4e910302fa4e3d7c29a79b55bd4500b7456f458e31f5f389c587725a7d534a21c4e138daff27b525fae74d874c8344948cd1d7
|
7
|
+
data.tar.gz: 5e2bbcef490e3b25c6ba565fd64fab7ee4a7091377fef64ca664a4be1edfa54d64b0810c2b5005a7e33e63c04e54ff65f2955c5e705f5ec9e03bb39ff513c654
|
data/README.md
CHANGED
@@ -6,6 +6,33 @@ Create content pages ontop of one or more templates -- just regular Rails views
|
|
6
6
|
|
7
7
|
Use this gem to create a fully-functional CMS that provides full or restricted editing for your end users.
|
8
8
|
|
9
|
+
## Upgrading to 3.9.0
|
10
|
+
|
11
|
+
Add a migration
|
12
|
+
|
13
|
+
```
|
14
|
+
class UpgradeEffectivePagesThreeNine < ActiveRecord::Migration[7.0]
|
15
|
+
def change
|
16
|
+
# Add a counter cache
|
17
|
+
add_column :pages, :menu_children_count, :integer, default: 0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
Run a one time script
|
23
|
+
|
24
|
+
```
|
25
|
+
# rake upgrade_effective_pages_to_three_nine
|
26
|
+
task upgrade_effective_pages_to_three_nine: :environment do
|
27
|
+
puts "Starting effective pages 3.9.0 upgrade"
|
28
|
+
|
29
|
+
Effective::Page.where(menu_children_count: 0).find_each do |page|
|
30
|
+
Effective::Page.reset_counters(page.slug, :menu_children)
|
31
|
+
end
|
32
|
+
|
33
|
+
puts 'All done'
|
34
|
+
end
|
35
|
+
```
|
9
36
|
|
10
37
|
## effective_pages 3.0
|
11
38
|
|
@@ -14,6 +14,8 @@ class EffectivePagesMenuDatatable < Effective::Datatable
|
|
14
14
|
col :menu_url, label: 'Redirect Url'
|
15
15
|
col :menu_position, label: 'Position', visible: false
|
16
16
|
|
17
|
+
col :menu_children_count, label: 'Children Count', visible: false
|
18
|
+
|
17
19
|
# We only support depth 2 and 3.
|
18
20
|
col :menu_children, label: 'Children' do |page|
|
19
21
|
page.menu_children.group_by { |child| child.menu_group.presence }.values.flatten.map do |child|
|
@@ -28,8 +28,6 @@ module EffectiveMenusHelper
|
|
28
28
|
(
|
29
29
|
[content_tag(:li, link_to(root, root_path, title: root), class: 'breadcrumb-item')] +
|
30
30
|
parents.map do |page|
|
31
|
-
page.try(:strict_loading!, false)
|
32
|
-
|
33
31
|
next if page.menu_root_with_children? # Don't show root pages because they have no content
|
34
32
|
|
35
33
|
url = (page.menu_url.presence || effective_pages.page_path(page))
|
@@ -62,7 +60,7 @@ module EffectiveMenusHelper
|
|
62
60
|
def admin_menu_parent_collection(page = nil)
|
63
61
|
raise('expected a page') if page.present? && !page.kind_of?(Effective::Page)
|
64
62
|
|
65
|
-
pages = Effective::Page.
|
63
|
+
pages = Effective::Page.deep_menuable.menuable.root_level.where.not(id: page)
|
66
64
|
|
67
65
|
if EffectivePages.max_menu_depth == 2
|
68
66
|
# You can only select root level pages
|
@@ -14,7 +14,7 @@ module Effective
|
|
14
14
|
belongs_to :page_banner, optional: true
|
15
15
|
|
16
16
|
# These parent / children are for the menu as well
|
17
|
-
belongs_to :menu_parent, class_name: 'Effective::Page', optional: true
|
17
|
+
belongs_to :menu_parent, class_name: 'Effective::Page', optional: true, touch: true, counter_cache: :menu_children_count
|
18
18
|
|
19
19
|
has_many :menu_children, -> { Effective::Page.menuable }, class_name: 'Effective::Page',
|
20
20
|
foreign_key: :menu_parent_id, inverse_of: :menu_parent
|
@@ -47,6 +47,8 @@ module Effective
|
|
47
47
|
menu_url :string # Redirect to this url instead of the page url
|
48
48
|
menu_position :integer # Position in the menu
|
49
49
|
|
50
|
+
menu_children_count :integer # Counter cache
|
51
|
+
|
50
52
|
# Banners
|
51
53
|
banner :boolean # Should we display a banner?
|
52
54
|
banner_random :boolean # Display a random banner
|
@@ -59,11 +61,14 @@ module Effective
|
|
59
61
|
end
|
60
62
|
|
61
63
|
scope :deep, -> {
|
62
|
-
base = includes(:page_banner, :tags, :rich_texts
|
64
|
+
base = includes(:page_banner, :tags, :rich_texts)
|
65
|
+
base = base.deep_menuable
|
63
66
|
base = base.includes(:pg_search_document) if defined?(PgSearch)
|
64
67
|
base
|
65
68
|
}
|
66
69
|
|
70
|
+
scope :deep_menuable, -> { includes(:menu_parent, menu_children: [:menu_parent, :menu_children]) }
|
71
|
+
|
67
72
|
scope :draft, -> { where(draft: true) }
|
68
73
|
scope :published, -> { where(draft: false) }
|
69
74
|
scope :sorted, -> { order(:title) }
|
@@ -186,13 +191,21 @@ module Effective
|
|
186
191
|
end
|
187
192
|
|
188
193
|
def menu_parent?
|
189
|
-
menu? &&
|
194
|
+
menu? && menu_children_present?
|
190
195
|
end
|
191
196
|
|
192
197
|
def menu_child?
|
193
198
|
menu? && menu_parent_id.present?
|
194
199
|
end
|
195
200
|
|
201
|
+
def menu_children_present?
|
202
|
+
menu_children_count > 0
|
203
|
+
end
|
204
|
+
|
205
|
+
def menu_children_blank?
|
206
|
+
menu_children_count <= 0
|
207
|
+
end
|
208
|
+
|
196
209
|
end
|
197
210
|
|
198
211
|
end
|
@@ -7,14 +7,11 @@
|
|
7
7
|
- next if (page.authenticate_user || page.roles.present?) && current_user.blank?
|
8
8
|
- next if page.roles.present? && (current_user.roles & page.roles).blank?
|
9
9
|
|
10
|
-
-
|
11
|
-
|
12
|
-
- if menu_children.blank?
|
10
|
+
- if page.menu_children_blank?
|
13
11
|
= nav_link_to(page.menu_to_s, (page.menu_url.presence || effective_pages.page_path(page)))
|
14
|
-
|
15
|
-
- if menu_children.present?
|
12
|
+
- else
|
16
13
|
= nav_dropdown(page.menu_to_s, groups: true) do
|
17
|
-
- menu_children.group_by { |menu| menu.menu_group.presence }.each do |menu_group, pages|
|
14
|
+
- page.menu_children.group_by { |menu| menu.menu_group.presence }.each do |menu_group, pages|
|
18
15
|
= nav_dropdown_group(menu_group || '') do
|
19
16
|
- pages.each do |page|
|
20
17
|
- next unless EffectiveResources.authorized?(self, :show, page)
|
@@ -1,15 +1,15 @@
|
|
1
1
|
- raise('expected a page') unless page.present?
|
2
2
|
|
3
|
-
- children =
|
3
|
+
- children = []
|
4
4
|
|
5
|
-
- if page.
|
5
|
+
- if page.menu_children_present?
|
6
|
+
- children = page.menu_children
|
6
7
|
= nav_link_to(page.menu_to_s, (page.menu_url.presence || effective_pages.page_path(page)))
|
7
8
|
|
8
9
|
- # if this is a third depth page, show the parent and siblings
|
9
|
-
- if page.
|
10
|
-
- page.menu_parent.
|
11
|
-
|
12
|
-
- if page.menu_parent.menu_children.present?
|
10
|
+
- if page.menu_children_blank? && page.menu_parent.try(:menu_parent_id).present?
|
11
|
+
- if page.menu_parent.menu_children_present?
|
12
|
+
- page.menu_parent.try(:strict_loading!, false)
|
13
13
|
- children = page.menu_parent.menu_children
|
14
14
|
= nav_link_to(page.menu_parent.menu_to_s, (page.menu_parent.menu_url.presence || effective_pages.page_path(page.menu_parent)))
|
15
15
|
|