activeadmin_favorites 0.1.8 → 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 +6 -0
- data/README.md +4 -4
- 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
- metadata +4 -3
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,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 0.1.8 (2026-10-29)
|
|
4
10
|
|
|
5
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-`.
|
data/README.md
CHANGED
|
@@ -108,11 +108,11 @@ Catalog entries are discovered at render time from ActiveAdmin columns, filters,
|
|
|
108
108
|
|
|
109
109
|
The gem installs:
|
|
110
110
|
|
|
111
|
-
- **Add to favorites** on index pages (
|
|
112
|
-
- **Personalize page** cogwheel on index and show pages
|
|
113
|
-
- **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)
|
|
114
114
|
|
|
115
|
-
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.
|
|
116
116
|
|
|
117
117
|
## Development
|
|
118
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
|
|
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,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/favorites/_filter_favorite_button.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
|