activeadmin_favorites 0.1.5 → 0.1.7
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/CHANGELOG.md +9 -0
- data/README.md +11 -3
- data/app/views/active_admin/_html_head.html.erb +14 -0
- data/lib/activeadmin/favorites/version.rb +1 -1
- data/lib/activeadmin/favorites/view_paths.rb +24 -14
- data/lib/activeadmin/favorites.rb +9 -0
- data/sig/activeadmin/favorites.rbs +3 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 87ee6c5a7e74841630d69de986dcc7dfef4f799e094f696529b3fe51b6c53552
|
|
4
|
+
data.tar.gz: b9381534a09f71b745c9d3a317d4890c0a21391c27be544e421be5b76cda43c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 422903c24269839ed1142a83e6c8fcc1f5aff493eba16a6d91574869eaaf8c64dcdde3b650c8ce4a90a29f56c4bdc2f656881204e44bb6a60b135eb7ece956e7
|
|
7
|
+
data.tar.gz: f9bf4dabb5f05f413a031b90694af82929117f14c5b3855c05be0c057f39d66441a83e68d755826ef4ff180a3e367f4f04d18a66a9e57c8d23c29f5965a8e893
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.1.7 (2026-10-29)
|
|
4
|
+
|
|
5
|
+
- Fix engine view path order so favorites sits immediately before ActiveAdmin and host `app/views` stays ahead of the gem `_html_head`. Rails engines prepend view paths; the previous reorder left favorites first whenever it was already ahead of ActiveAdmin.
|
|
6
|
+
|
|
7
|
+
## 0.1.6 (2026-10-27)
|
|
8
|
+
|
|
9
|
+
- Link the personalization menu stylesheet from Active Admin's HTML head so hosts no longer need a Tailwind `@import` of the Propshaft path.
|
|
10
|
+
- Document `ActiveAdmin::Favorites.personalization_menu_stylesheet_path` for hosts that concatenate the plain CSS into a Tailwind CLI entry.
|
|
11
|
+
|
|
3
12
|
## 0.1.5 (2026-10-26)
|
|
4
13
|
|
|
5
14
|
- Keep personalization menu actions in view while a long catalog scrolls.
|
data/README.md
CHANGED
|
@@ -61,10 +61,18 @@ When using ActionPolicy, add `save_lens_favorite?` and `reset?` to `ActiveAdmin:
|
|
|
61
61
|
|
|
62
62
|
### Stylesheet
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
The engine ships an `active_admin/_html_head` that links `activeadmin_favorites/personalization_menu` so the cogwheel dropdown can scroll the catalog while keeping action buttons in view. The file is plain CSS served through Propshaft; it does not need Tailwind processing. Engine view paths sit immediately before ActiveAdmin's, so a host `app/views/active_admin/_html_head` still wins.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
If the host overrides that partial, add the link there:
|
|
67
|
+
|
|
68
|
+
```erb
|
|
69
|
+
<%= stylesheet_link_tag "activeadmin_favorites/personalization_menu" %>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Do not bare-`@import` that Propshaft logical path into an Active Admin CSS entry that Tailwind CLI compiles from a generated `tmp` file. Tailwind resolves imports from the input file directory, not through Propshaft. Hosts that must fold the rules into one built stylesheet can concatenate the absolute file instead:
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
File.read(ActiveAdmin::Favorites.personalization_menu_stylesheet_path)
|
|
68
76
|
```
|
|
69
77
|
|
|
70
78
|
### Locales
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%= stylesheet_link_tag "active_admin" %>
|
|
2
|
+
<%= stylesheet_link_tag ActiveAdmin::Favorites::PERSONALIZATION_MENU_STYLESHEET %>
|
|
3
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
4
|
+
<%= csrf_meta_tags %>
|
|
5
|
+
<%= csp_meta_tag %>
|
|
6
|
+
<% # On page load or when changing themes, best to add inline in `head` to avoid FOUC %>
|
|
7
|
+
<%= javascript_tag nonce: true do %>
|
|
8
|
+
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
|
9
|
+
document.documentElement.classList.add('dark')
|
|
10
|
+
} else {
|
|
11
|
+
document.documentElement.classList.remove('dark')
|
|
12
|
+
}
|
|
13
|
+
<% end %>
|
|
14
|
+
<%= javascript_importmap_tags "active_admin", importmap: ActiveAdmin.importmap %>
|
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
module ActiveAdmin
|
|
4
4
|
module Favorites
|
|
5
|
-
# Place this engine's views
|
|
6
|
-
# overrides (catalog injection) win
|
|
5
|
+
# Place this engine's views immediately before ActiveAdmin's so resource
|
|
6
|
+
# index/show overrides (catalog injection) win. Rails engines prepend their
|
|
7
|
+
# view paths, so favorites can otherwise sit ahead of the host app/views and
|
|
8
|
+
# shadow customized templates such as active_admin/_html_head.
|
|
7
9
|
module ViewPaths
|
|
8
10
|
module_function
|
|
9
11
|
|
|
10
12
|
def prefer_over_active_admin!(view_paths)
|
|
11
13
|
path_strings = view_paths.to_a.map { |path| path.to_s }
|
|
12
14
|
reordered = reorder_path_strings(path_strings)
|
|
13
|
-
return view_paths if reordered
|
|
15
|
+
return view_paths if reordered == path_strings
|
|
14
16
|
|
|
15
17
|
ActionView::PathSet.new(reordered)
|
|
16
18
|
end
|
|
@@ -25,24 +27,32 @@ module ActiveAdmin
|
|
|
25
27
|
|
|
26
28
|
def reorder_path_strings(path_strings)
|
|
27
29
|
favorites_root = Engine.root.join("app/views").to_s
|
|
28
|
-
|
|
30
|
+
active_admin_root = active_admin_views_root(path_strings)
|
|
31
|
+
return path_strings unless path_strings.include?(favorites_root) && active_admin_root
|
|
32
|
+
return path_strings if already_before_active_admin?(path_strings, favorites_root, active_admin_root)
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
end
|
|
33
|
-
return path_strings unless active_admin_root
|
|
34
|
+
place_before_active_admin(path_strings, favorites_root, active_admin_root)
|
|
35
|
+
end
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
def active_admin_views_root(path_strings)
|
|
38
|
+
path_strings.find { |path| path.match?(%r{/gems/activeadmin-[^/]+/app/views\z}) }
|
|
39
|
+
end
|
|
38
40
|
|
|
41
|
+
def already_before_active_admin?(path_strings, favorites_root, active_admin_root)
|
|
42
|
+
path_strings.index(favorites_root) == path_strings.index(active_admin_root) - 1
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def place_before_active_admin(path_strings, favorites_root, active_admin_root)
|
|
39
46
|
moved = path_strings.dup
|
|
40
|
-
moved.
|
|
47
|
+
moved.delete(favorites_root)
|
|
41
48
|
moved.insert(moved.index(active_admin_root), favorites_root)
|
|
42
49
|
moved
|
|
43
50
|
end
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
|
|
52
|
+
module_function :reorder_path_strings, :active_admin_views_root,
|
|
53
|
+
:already_before_active_admin?, :place_before_active_admin
|
|
54
|
+
private_class_method :reorder_path_strings, :active_admin_views_root,
|
|
55
|
+
:already_before_active_admin?, :place_before_active_admin
|
|
46
56
|
end
|
|
47
57
|
end
|
|
48
58
|
end
|
|
@@ -5,6 +5,8 @@ require "activeadmin/favorites/configuration"
|
|
|
5
5
|
|
|
6
6
|
module ActiveAdmin
|
|
7
7
|
module Favorites
|
|
8
|
+
PERSONALIZATION_MENU_STYLESHEET = "activeadmin_favorites/personalization_menu"
|
|
9
|
+
|
|
8
10
|
class << self
|
|
9
11
|
def config
|
|
10
12
|
@config ||= Configuration.new
|
|
@@ -14,6 +16,13 @@ module ActiveAdmin
|
|
|
14
16
|
yield config
|
|
15
17
|
end
|
|
16
18
|
|
|
19
|
+
# Absolute path to the plain CSS file Propshaft serves. Hosts that
|
|
20
|
+
# concatenate into a Tailwind CLI entry can File.read this path; do not
|
|
21
|
+
# bare-@import the Propshaft logical path from a tmp Tailwind input.
|
|
22
|
+
def personalization_menu_stylesheet_path
|
|
23
|
+
Engine.root.join("app/assets/stylesheets/#{PERSONALIZATION_MENU_STYLESHEET}.css")
|
|
24
|
+
end
|
|
25
|
+
|
|
17
26
|
def install!
|
|
18
27
|
require "activeadmin/favorites/install"
|
|
19
28
|
Install.call
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activeadmin_favorites
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrei Makarov
|
|
@@ -355,6 +355,7 @@ files:
|
|
|
355
355
|
- app/models/active_admin/favorites/lens_favorite.rb
|
|
356
356
|
- app/models/active_admin/favorites/view_lens/layout.rb
|
|
357
357
|
- app/models/active_admin/favorites/view_lens_default.rb
|
|
358
|
+
- app/views/active_admin/_html_head.html.erb
|
|
358
359
|
- app/views/active_admin/favorites/_lens_catalog_data.html.erb
|
|
359
360
|
- app/views/active_admin/favorites/_macro_fields.html.erb
|
|
360
361
|
- app/views/active_admin/favorites/_personalization_trigger.html.erb
|