activeadmin_favorites 0.1.6 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d95f2a47f409353aaaa307098bf24dc0b94abc2bf116f47101259a81f8e481a
4
- data.tar.gz: 9842f18c72d0e9fbe731b934a5d58c0eae9633eb0438849a57b8d09c10b87aaf
3
+ metadata.gz: 87ee6c5a7e74841630d69de986dcc7dfef4f799e094f696529b3fe51b6c53552
4
+ data.tar.gz: b9381534a09f71b745c9d3a317d4890c0a21391c27be544e421be5b76cda43c2
5
5
  SHA512:
6
- metadata.gz: 52d6fd9962c311fcee1f14c98211478337761a916eb074e83ebb641063370eb16c8b81ad921f45d59af4c8ad0b4e328fa83c6b52e9ef6423fa823ce660d1c9a5
7
- data.tar.gz: ba88cae3210e174538ec0dd397f7085f451093e9b86c364219d4ba2453302917fbb0c7d6918843a2d83abffb8a7ea11a1dc765811f2cd160ab70188dded4dbec
6
+ metadata.gz: 422903c24269839ed1142a83e6c8fcc1f5aff493eba16a6d91574869eaaf8c64dcdde3b650c8ce4a90a29f56c4bdc2f656881204e44bb6a60b135eb7ece956e7
7
+ data.tar.gz: f9bf4dabb5f05f413a031b90694af82929117f14c5b3855c05be0c057f39d66441a83e68d755826ef4ff180a3e367f4f04d18a66a9e57c8d23c29f5965a8e893
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  ## 0.1.6 (2026-10-27)
4
8
 
5
9
  - Link the personalization menu stylesheet from Active Admin's HTML head so hosts no longer need a Tailwind `@import` of the Propshaft path.
data/README.md CHANGED
@@ -61,9 +61,9 @@ When using ActionPolicy, add `save_lens_favorite?` and `reset?` to `ActiveAdmin:
61
61
 
62
62
  ### Stylesheet
63
63
 
64
- The engine links `activeadmin_favorites/personalization_menu` from Active Admin's HTML head 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.
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
- If the host overrides `active_admin/_html_head`, add the link there:
66
+ If the host overrides that partial, add the link there:
67
67
 
68
68
  ```erb
69
69
  <%= stylesheet_link_tag "activeadmin_favorites/personalization_menu" %>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveAdmin
4
4
  module Favorites
5
- VERSION = "0.1.6"
5
+ VERSION = "0.1.7"
6
6
  end
7
7
  end
@@ -2,15 +2,17 @@
2
2
 
3
3
  module ActiveAdmin
4
4
  module Favorites
5
- # Place this engine's views ahead of ActiveAdmin's so resource index/show
6
- # overrides (catalog injection) win, while the host app/views path stays first.
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.equal?(path_strings)
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
- return path_strings unless path_strings.include?(favorites_root)
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
- active_admin_root = path_strings.find do |path|
31
- path.match?(%r{/gems/activeadmin-[^/]+/app/views\z})
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
- favorites_index = path_strings.index(favorites_root)
36
- active_admin_index = path_strings.index(active_admin_root)
37
- return path_strings if favorites_index < active_admin_index
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.delete_at(favorites_index)
47
+ moved.delete(favorites_root)
41
48
  moved.insert(moved.index(active_admin_root), favorites_root)
42
49
  moved
43
50
  end
44
- module_function :reorder_path_strings
45
- private_class_method :reorder_path_strings
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
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.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov