activeadmin_favorites 0.1.7 → 0.1.9
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 +11 -0
- data/README.md +5 -7
- data/activeadmin_favorites.gemspec +1 -1
- data/app/assets/controllers/activeadmin_favorites/personalization_controller.js +20 -0
- data/app/views/active_admin/favorites/_filter_favorite_button.html.erb +18 -0
- data/app/views/active_admin/favorites/_personalization_trigger.html.erb +2 -1
- data/lib/activeadmin/favorites/install.rb +4 -1
- data/lib/activeadmin/favorites/version.rb +1 -1
- data/lib/activeadmin/favorites/view_paths.rb +19 -5
- metadata +4 -4
- data/app/views/active_admin/_html_head.html.erb +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3509bb00158d9a807b7ff01e637302b061ae0a30b6e3adf2ca985c4c23c2376c
|
|
4
|
+
data.tar.gz: '0876219df16bdf67f790adb9541b55677a2938eef7ad81e006951aad6e875905'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed84a8a3710e2b13a3509afec58f33ad49b8d050c290ba8375029bc6ef28bdc491d4887d66b93ac464f1604a25f41ee7bf880e5f7a62c043156a662afd1b9d82
|
|
7
|
+
data.tar.gz: d368aef63d1250df6627bafb17d6956082473873dcd3a2a3a2f27b525c7a69eccedd1cbc9ef2604b8af88725aa3b40803ac238b933b6aa887dd13188d370f1c0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.1.9 (2026-11-04)
|
|
4
|
+
|
|
5
|
+
- Show Add to favorites / Edit favorite as a star icon button on index action rows (accessible name only; filled when an owned favorite matches).
|
|
6
|
+
- Hide the Personalize page cog when the page lens catalog is empty; keep the favorites hub at `/admin/favorites`.
|
|
7
|
+
- CI: refresh lockfiles for current advisories (`loofah` 2.25.3, `nokogiri` 1.19.7, `rack` 3.2.8, `rails-html-sanitizer` 1.7.2, `sqlite3` 2.10.2) and raise the sqlite3 development floor.
|
|
8
|
+
|
|
9
|
+
## 0.1.8 (2026-10-29)
|
|
10
|
+
|
|
11
|
+
- Fix Active Admin view-path detection so sibling gems such as `activeadmin-command_palette` are not treated as Active Admin. Prefer `ActiveAdmin::Engine.root`, with a fallback that requires a digit version segment after `activeadmin-`.
|
|
12
|
+
- Remove the gem `active_admin/_html_head` override. Hosts must link `activeadmin_favorites/personalization_menu` from their own Active Admin head.
|
|
13
|
+
|
|
3
14
|
## 0.1.7 (2026-10-29)
|
|
4
15
|
|
|
5
16
|
- 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.
|
data/README.md
CHANGED
|
@@ -61,9 +61,7 @@ When using ActionPolicy, add `save_lens_favorite?` and `reset?` to `ActiveAdmin:
|
|
|
61
61
|
|
|
62
62
|
### Stylesheet
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
If the host overrides that partial, add the link there:
|
|
64
|
+
Link `activeadmin_favorites/personalization_menu` from the host Active Admin 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. The gem does not ship `active_admin/_html_head`, so customized host heads keep their stylesheet names and extra tags.
|
|
67
65
|
|
|
68
66
|
```erb
|
|
69
67
|
<%= stylesheet_link_tag "activeadmin_favorites/personalization_menu" %>
|
|
@@ -110,11 +108,11 @@ Catalog entries are discovered at render time from ActiveAdmin columns, filters,
|
|
|
110
108
|
|
|
111
109
|
The gem installs:
|
|
112
110
|
|
|
113
|
-
- **Add to favorites** on index pages (
|
|
114
|
-
- **Personalize page** cogwheel on index and show pages
|
|
115
|
-
- **Favorites** hub with type tabs (all, filters, lens, combined)
|
|
111
|
+
- **Add to favorites** star icon on index pages (outline when unsaved, filled when an owned filter favorite matches the current query; label is the accessible name only)
|
|
112
|
+
- **Personalize page** cogwheel on index and show pages (hidden when the page lens catalog is empty)
|
|
113
|
+
- **Favorites** hub at `/admin/favorites` with type tabs (all, filters, lens, combined)
|
|
116
114
|
|
|
117
|
-
Defaults are stored in `active_admin_view_lens_defaults`. Named lens favorites and combined favorites use `admin_favorites.layout`.
|
|
115
|
+
Defaults are stored in `active_admin_view_lens_defaults`. Named lens favorites and combined favorites use `admin_favorites.layout`. The favorites hub stays reachable from `/admin/favorites` and from personalization menus on pages that still have catalog entries.
|
|
118
116
|
|
|
119
117
|
## Development
|
|
120
118
|
|
|
@@ -55,7 +55,7 @@ Gem::Specification.new do |spec|
|
|
|
55
55
|
spec.add_development_dependency "rake", "~> 13"
|
|
56
56
|
spec.add_development_dependency "rspec", "~> 3"
|
|
57
57
|
spec.add_development_dependency "rspec-rails", ">= 6"
|
|
58
|
-
spec.add_development_dependency "sqlite3", ">= 2.
|
|
58
|
+
spec.add_development_dependency "sqlite3", ">= 2.10.2"
|
|
59
59
|
spec.add_development_dependency "rubocop-rails", "~> 2.34"
|
|
60
60
|
spec.add_development_dependency "rubocop-rspec", "~> 3.8"
|
|
61
61
|
spec.add_development_dependency "rubocop-thread_safety", "~> 0.7"
|
|
@@ -18,6 +18,19 @@ export default class extends Controller {
|
|
|
18
18
|
|
|
19
19
|
connect() {
|
|
20
20
|
this.catalogLoaded = false
|
|
21
|
+
this.boundApplyEmptyCatalogVisibility = () => this.applyEmptyCatalogVisibility()
|
|
22
|
+
// Catalog JSON is rendered at the end of the resource page; wait for full parse.
|
|
23
|
+
if (document.readyState === "loading") {
|
|
24
|
+
document.addEventListener("DOMContentLoaded", this.boundApplyEmptyCatalogVisibility, {once: true})
|
|
25
|
+
} else {
|
|
26
|
+
this.applyEmptyCatalogVisibility()
|
|
27
|
+
}
|
|
28
|
+
document.addEventListener("turbo:load", this.boundApplyEmptyCatalogVisibility)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
disconnect() {
|
|
32
|
+
document.removeEventListener("DOMContentLoaded", this.boundApplyEmptyCatalogVisibility)
|
|
33
|
+
document.removeEventListener("turbo:load", this.boundApplyEmptyCatalogVisibility)
|
|
21
34
|
}
|
|
22
35
|
|
|
23
36
|
prepareMenu() {
|
|
@@ -40,6 +53,11 @@ export default class extends Controller {
|
|
|
40
53
|
}
|
|
41
54
|
}
|
|
42
55
|
|
|
56
|
+
applyEmptyCatalogVisibility() {
|
|
57
|
+
// Start hidden in markup; reveal only when the deferred catalog has entries.
|
|
58
|
+
this.element.classList.toggle("hidden", this.catalogEntries().length === 0)
|
|
59
|
+
}
|
|
60
|
+
|
|
43
61
|
escapeHtml(value) {
|
|
44
62
|
return String(value)
|
|
45
63
|
.replaceAll("&", "&")
|
|
@@ -60,9 +78,11 @@ export default class extends Controller {
|
|
|
60
78
|
if (groups.length === 0) {
|
|
61
79
|
this.catalogGroupsTarget.innerHTML =
|
|
62
80
|
`<p class="favorites-personalization-menu__empty">${this.escapeHtml(this.emptyCatalogLabelValue)}</p>`
|
|
81
|
+
this.applyEmptyCatalogVisibility()
|
|
63
82
|
return
|
|
64
83
|
}
|
|
65
84
|
|
|
85
|
+
this.applyEmptyCatalogVisibility()
|
|
66
86
|
this.catalogGroupsTarget.innerHTML = groups.map((group) => {
|
|
67
87
|
const label = this.escapeHtml(this.groupLabelsValue[group] || group.replace(/_/g, " "))
|
|
68
88
|
const items = grouped[group].map((entry) => {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%= link_to(
|
|
2
|
+
destination,
|
|
3
|
+
class: "action-item-button inline-flex items-center justify-center",
|
|
4
|
+
aria: {label: label},
|
|
5
|
+
data: {testid: "filter-favorite", favorited: favorited},
|
|
6
|
+
title: label
|
|
7
|
+
) do %>
|
|
8
|
+
<% if favorited %>
|
|
9
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
|
10
|
+
<path fill-rule="evenodd" d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z" clip-rule="evenodd" />
|
|
11
|
+
</svg>
|
|
12
|
+
<% else %>
|
|
13
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
14
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z" />
|
|
15
|
+
</svg>
|
|
16
|
+
<% end %>
|
|
17
|
+
<span class="sr-only"><%= label %></span>
|
|
18
|
+
<% end %>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
menu_id = "personalization-menu-#{resource_key}-#{action_name}"
|
|
8
8
|
%>
|
|
9
9
|
<div
|
|
10
|
-
class="relative"
|
|
10
|
+
class="relative hidden"
|
|
11
11
|
data-controller="<%= stimulus_controller %>"
|
|
12
12
|
data-<%= stimulus_controller %>-resource-key-value="<%= resource_key %>"
|
|
13
13
|
data-<%= stimulus_controller %>-action-name-value="<%= action_name %>"
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
show_rows: t("active_admin.favorites.groups.show_rows", default: "Rows")
|
|
27
27
|
}.to_json %>"
|
|
28
28
|
data-<%= stimulus_controller %>-empty-catalog-label-value="<%= t("active_admin.favorites.no_personalization_items") %>"
|
|
29
|
+
data-testid="page-personalization"
|
|
29
30
|
>
|
|
30
31
|
<button
|
|
31
32
|
type="button"
|
|
@@ -58,6 +58,7 @@ module ActiveAdmin
|
|
|
58
58
|
config.add_action_item(FILTER_FAVOURITE_ACTION, only: :index, priority: 5) do
|
|
59
59
|
sanitized_query = Favorite.sanitize_query_string(request.query_string)
|
|
60
60
|
user = send(ActiveAdmin::Favorites.config.current_user_method)
|
|
61
|
+
favorited = false
|
|
61
62
|
|
|
62
63
|
if sanitized_query.blank?
|
|
63
64
|
label = I18n.t("active_admin.favorites.add_favorite")
|
|
@@ -74,6 +75,7 @@ module ActiveAdmin
|
|
|
74
75
|
}
|
|
75
76
|
lookup[ActiveAdmin::Favorites.config.user_foreign_key] = user.id
|
|
76
77
|
owned_existing = Favorite.filters_kind.find_by(lookup)
|
|
78
|
+
favorited = owned_existing.present?
|
|
77
79
|
|
|
78
80
|
label = if owned_existing
|
|
79
81
|
I18n.t("active_admin.favorites.edit_favorite")
|
|
@@ -93,7 +95,8 @@ module ActiveAdmin
|
|
|
93
95
|
end
|
|
94
96
|
end
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
render partial: "active_admin/favorites/filter_favorite_button",
|
|
99
|
+
locals: {label: label, destination: destination, favorited: favorited}
|
|
97
100
|
end
|
|
98
101
|
end
|
|
99
102
|
|
|
@@ -4,8 +4,7 @@ module ActiveAdmin
|
|
|
4
4
|
module Favorites
|
|
5
5
|
# Place this engine's views immediately before ActiveAdmin's so resource
|
|
6
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
|
|
8
|
-
# shadow customized templates such as active_admin/_html_head.
|
|
7
|
+
# view paths, so favorites can otherwise sit ahead of the host app/views.
|
|
9
8
|
module ViewPaths
|
|
10
9
|
module_function
|
|
11
10
|
|
|
@@ -35,7 +34,16 @@ module ActiveAdmin
|
|
|
35
34
|
end
|
|
36
35
|
|
|
37
36
|
def active_admin_views_root(path_strings)
|
|
38
|
-
|
|
37
|
+
engine_root = active_admin_engine_views_root
|
|
38
|
+
return engine_root if engine_root && path_strings.include?(engine_root)
|
|
39
|
+
|
|
40
|
+
path_strings.find { |path| path.match?(ACTIVE_ADMIN_GEM_VIEWS) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def active_admin_engine_views_root
|
|
44
|
+
return unless defined?(::ActiveAdmin::Engine)
|
|
45
|
+
|
|
46
|
+
::ActiveAdmin::Engine.root.join("app/views").to_s
|
|
39
47
|
end
|
|
40
48
|
|
|
41
49
|
def already_before_active_admin?(path_strings, favorites_root, active_admin_root)
|
|
@@ -49,10 +57,16 @@ module ActiveAdmin
|
|
|
49
57
|
moved
|
|
50
58
|
end
|
|
51
59
|
|
|
60
|
+
# Versioned Active Admin gem only (`activeadmin-4...`), not siblings such as
|
|
61
|
+
# `activeadmin-command_palette-...`.
|
|
62
|
+
ACTIVE_ADMIN_GEM_VIEWS = %r{/gems/activeadmin-\d[^/]*/app/views\z}
|
|
63
|
+
|
|
52
64
|
module_function :reorder_path_strings, :active_admin_views_root,
|
|
53
|
-
:already_before_active_admin?,
|
|
65
|
+
:active_admin_engine_views_root, :already_before_active_admin?,
|
|
66
|
+
:place_before_active_admin
|
|
54
67
|
private_class_method :reorder_path_strings, :active_admin_views_root,
|
|
55
|
-
:already_before_active_admin?,
|
|
68
|
+
:active_admin_engine_views_root, :already_before_active_admin?,
|
|
69
|
+
:place_before_active_admin
|
|
56
70
|
end
|
|
57
71
|
end
|
|
58
72
|
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.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrei Makarov
|
|
@@ -189,14 +189,14 @@ dependencies:
|
|
|
189
189
|
requirements:
|
|
190
190
|
- - ">="
|
|
191
191
|
- !ruby/object:Gem::Version
|
|
192
|
-
version: 2.
|
|
192
|
+
version: 2.10.2
|
|
193
193
|
type: :development
|
|
194
194
|
prerelease: false
|
|
195
195
|
version_requirements: !ruby/object:Gem::Requirement
|
|
196
196
|
requirements:
|
|
197
197
|
- - ">="
|
|
198
198
|
- !ruby/object:Gem::Version
|
|
199
|
-
version: 2.
|
|
199
|
+
version: 2.10.2
|
|
200
200
|
- !ruby/object:Gem::Dependency
|
|
201
201
|
name: rubocop-rails
|
|
202
202
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -355,7 +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/
|
|
358
|
+
- app/views/active_admin/favorites/_filter_favorite_button.html.erb
|
|
359
359
|
- app/views/active_admin/favorites/_lens_catalog_data.html.erb
|
|
360
360
|
- app/views/active_admin/favorites/_macro_fields.html.erb
|
|
361
361
|
- app/views/active_admin/favorites/_personalization_trigger.html.erb
|
|
@@ -1,14 +0,0 @@
|
|
|
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 %>
|