active_admin_prism 0.1.3 → 0.1.4

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: 72cc73689e83be856fdc1e2e321df486dc8cb6033bcca1380aae1d7aed8a15b0
4
- data.tar.gz: 999e31015012d3dcb58de142de2fe050754fba7903612f259f8ab92709388c05
3
+ metadata.gz: 35f7f9fdd5aec6533abb2db1fc8289129bde147d99ae77410af86dae2fc58294
4
+ data.tar.gz: fedf27baf3454219273944d324e2a8fe3ffe4f36b4392415e6cf368517231ac0
5
5
  SHA512:
6
- metadata.gz: f94ead774c60a6c285fa59c624c0f472cd7eb31c2a21d970a7609a74bb3f948d86754d32050d416c7fdfc2fb9fdaa915c3071f998a7832dacb02027ecc606052
7
- data.tar.gz: b71bbf23aceebcf5febdc7690b4b27064d4d1b9dfe050254e931b15060398a35b55ea0a228220386098fd061e57633ab7e1d00ec3bc5af350db520bfdbb2f23f
6
+ metadata.gz: 889376a6a7a2efbd22327d2498f9514b3e2ffbd8fb6aac406d49ca9201e99633490b9c9ec73a4084e25d560d7858ce9d20f2f90ff5e383941efd63f0ed262fb3
7
+ data.tar.gz: 5d6aeef6bd4cc91cba408142d78c9bea49d99b0fe0113fcca8667df419251a4ec5e68237753e6dfe8a1343d95446447dbe9979dc3a14f80a3a2c2bc16da12574
data/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.4
4
+
5
+ - A Pages nav item registered with no `icon:` now gets one automatically
6
+ (`auto_nav_icons`, on by default) — picked deterministically from a
7
+ generic subset of the built-in icon set based on the item's own label,
8
+ so the same label always gets the same icon rather than shuffling
9
+ between page loads. Mainly matters once the sidebar is collapsed to
10
+ its icon-only rail (`sidebar_collapsible`): an unassigned item used to
11
+ render there as just a bare, indistinguishable dot. `icon:` set
12
+ explicitly always wins; `auto_nav_icons = false` restores the old
13
+ no-icon-at-all behavior.
14
+ - Every non-Filters sidebar section (ActiveAdmin core's own "Search
15
+ status" panel, when `active_filters_bar` is off, or a host's own custom
16
+ `sidebar "Title" do ... end` block) now flattens every link/button
17
+ inside it into a single "Sidebar Actions" Select2 dropdown when
18
+ `collapsible_filters` is on, instead of each rendering its own
19
+ individually collapsed icon button with nowhere near enough room in
20
+ the 72px gutter that assumed just one — wrapping every word onto its
21
+ own line, or spilling out unclipped over the main content, instead of
22
+ collapsing cleanly. This dropdown renders in the title bar, next to
23
+ (and styled identically to) the consolidated "Actions" dropdown below,
24
+ so the two read as one "more stuff lives here" row instead of two
25
+ disconnected mechanisms in different parts of the page. Picking an
26
+ option fires a real click on the underlying (hidden but still
27
+ DOM-attached, so Rails UJS's `data-method`/`data-confirm` keeps
28
+ working) link/button and resets right back to its placeholder — same
29
+ "jump menu" click-and-reset flow as the "Actions" dropdown, rather than
30
+ opening the section's content in a nested panel. The section itself is
31
+ discarded outright either way, never rendered in `#sidebar`. The
32
+ Filters panel itself is untouched by any of this — it always keeps its
33
+ own plain icon button exactly as before, whether or not any other
34
+ sections exist. A page with only Filters (the common case) shows no
35
+ dropdown at all.
36
+ - A title bar with more than `action_items_dropdown_threshold` (default:
37
+ `0`, so this applies from a single extra `action_item` on) `action_item`
38
+ buttons now collapses all of them into a single Select2 "jump menu",
39
+ aligned with the index table's own right edge (not the page's corner,
40
+ which a table's own column-driven width often doesn't reach), instead
41
+ of rendering a multi-row wall of individual buttons — a resource
42
+ registering a dozen+ CSV upload / bulk-action links is a real example
43
+ this was built for. Sits in the same row as the "Sidebar Actions"
44
+ dropdown above when both exist on the same page, with a visible gap
45
+ before the (always excluded, always pinned to the true top-right
46
+ corner) "New Resource" button. Both this and the "Sidebar Actions"
47
+ dropdown above always show Select2's search box, even with just one or
48
+ two options — not gated behind a result-count threshold — so either
49
+ reads unambiguously as Select2 regardless of how many items it
50
+ currently has. Picking an option fires that action immediately (a
51
+ plain link navigates, a `button_to` form submits — whatever it
52
+ actually was, `data-confirm`/`data-method` included) and resets right
53
+ back to its placeholder. Purely client-side: it moves each existing
54
+ action_item element as-is into a hidden holding area and `.click()`s
55
+ the real trigger inside it, so whatever a host's own `action_item`
56
+ block rendered keeps working completely unmodified. Set
57
+ `config.action_items_dropdown = false` to always render every
58
+ action_item inline, matching this gem's behavior before this flag
59
+ existed.
60
+ - The active-filters bar (`config.active_filters_bar`) now toggles the
61
+ Filters panel open/closed on click, same as the funnel icon, instead of
62
+ only ever opening it.
63
+ - Following any Pages nav item — a plain leaf link, or a parent group
64
+ like "School" — while the sidebar is collapsed to its icon-only rail
65
+ (`config.sidebar_collapsible`) now expands it back out first. A
66
+ parent's own submenu is force-hidden by CSS while collapsed regardless
67
+ of its "open" class, so without this, clicking one did nothing visible
68
+ at all.
69
+ - An index table wider than its container (many columns, a narrow
70
+ viewport) now fades in a subtle shadow on whichever edge still has
71
+ more columns to scroll toward, clearing once scrolled all the way to
72
+ that side — a table simply cut off flush at the container's edge
73
+ otherwise gave no indication scrolling was even possible.
74
+
3
75
  ## 0.1.3
4
76
 
5
77
  - A hamburger icon button next to the brand, at the top of the Prism
data/INTEGRATION.md CHANGED
@@ -135,6 +135,9 @@ ActiveAdminPrism.configure do |config|
135
135
  config.menu_search = true # default: true
136
136
  config.select2 = false # default: false (opt-in — see below)
137
137
  config.sidebar_collapsible = true # default: true
138
+ config.action_items_dropdown = true # default: true
139
+ config.action_items_dropdown_threshold = 3 # default: 3
140
+ config.auto_nav_icons = true # default: true
138
141
  end
139
142
 
140
143
  ActiveAdminPrism.enable!
@@ -161,6 +164,9 @@ ActiveAdminPrism.enable!
161
164
  | `menu_search` | `true` | No search box renders above the sidebar's "Pages" nav — see [Menu search](#menu-search). |
162
165
  | `select2` | `false` | **Opposite polarity from every other flag above — opt-in, not opt-out.** `false` (the default) leaves every `<select>` exactly as ActiveAdmin renders it. `true` auto-enhances *every* plain `<select>` (filters, form inputs, association pickers — no per-field setup) into a searchable Select2 widget — see [Select2](#select2). |
163
166
  | `sidebar_collapsible` | `true` | No hamburger toggle button renders next to the brand — the sidebar is always full width, with no way to collapse it to an icon-only rail. Desktop-only either way; the mobile off-canvas toggle is unaffected — see [Collapsible sidebar rail](#collapsible-sidebar-rail). |
167
+ | `action_items_dropdown` | `true` | Every `action_item` always renders inline in the title bar, however many there are — no "Actions" dropdown consolidation. See [Consolidated action items](#consolidated-action-items). |
168
+ | `action_items_dropdown_threshold` | `3` | How many `action_item`s a title bar can have before `action_items_dropdown` (if on) collapses them into a dropdown. |
169
+ | `auto_nav_icons` | `true` | A Pages nav item with no explicit `icon:` renders with no icon at all (just its label, or a bare dot once collapsed to the icon-only rail) instead of an automatically-picked one — see [Automatic nav icons](#automatic-nav-icons). |
164
170
 
165
171
  **How this crosses the server/client boundary.** `sidebar`,
166
172
  `colorize_action_icons`, and the `login_*` flags are pure server-side
@@ -292,6 +298,21 @@ passes this hash through untouched) accepts: `:dashboard`, `:users`,
292
298
  `:home`, `:list`, `:folder`, `:bell`, `:search`, `:menu`, `:logout`,
293
299
  `:check`, `:x`, `:chevron_down`, `:eye`, `:pencil`, `:trash`, `:filter`.
294
300
 
301
+ ### Automatic nav icons
302
+
303
+ A menu item registered with no `icon:` at all still gets one, picked from
304
+ a generic subset of the icon set above (`:dashboard`, `:users`, `:cart`,
305
+ `:box`, `:receipt`, `:credit_card`, `:message`, `:settings`, `:home`,
306
+ `:list`, `:folder`, `:bell`, `:search`, `:globe`, `:eye`, `:pencil`,
307
+ `:filter`) based on the item's own label — the same label always maps to
308
+ the same icon (it's a deterministic hash, not re-rolled per request), so
309
+ it never visibly changes between page loads. This is mainly about the
310
+ collapsed icon-only rail (see below): without any icon at all, an
311
+ unassigned item renders there as just a bare dot, indistinguishable from
312
+ any other unassigned item. `icon:` set explicitly always wins. Turn it
313
+ off with `config.auto_nav_icons = false` to go back to rendering no icon
314
+ for such an item (this gem's behavior before this flag existed).
315
+
295
316
  ### Collapsible sidebar rail
296
317
 
297
318
  A hamburger icon button next to the brand, at the top of the sidebar,
@@ -626,17 +647,71 @@ jquery-rails/jquery-ujs. Turn off with `config.styled_confirms = false`.
626
647
  The "Filters" panel (ActiveAdmin's `filters_sidebar_section`) starts
627
648
  collapsed to a single filter-icon button; clicking it expands the full form
628
649
  in place (also keyboard-accessible — Enter/Space toggle it, and it exposes
629
- `aria-expanded`). The index table/main content area reflows to reclaim the
630
- freed-up width while collapsed, and gives it back when expanded. No setup
631
- needed, and it only targets that specific panel — any other sidebar section
632
- (dashboard panels, custom `sidebar :title do ... end` blocks) is untouched.
633
- Turn it off with `config.collapsible_filters = false` to always show it
634
- fully expanded, matching ActiveAdmin's own default (and the table/content
635
- area at its normal, non-reflowing width).
650
+ `aria-expanded`). This is always how Filters behaves, whether or not any
651
+ other collapsible sections exist it's never grouped into a dropdown
652
+ with anything else.
653
+
654
+ Every *other* sidebar section dashboard panels, ActiveAdmin's own
655
+ "Search status" panel (when `active_filters_bar` is off), or any custom
656
+ `sidebar "Title" do ... end` block a host registers — gets collapsed too,
657
+ but consolidated into a single "More Actions" Select2 dropdown instead of
658
+ each getting its own individually collapsed icon button: a stack of those
659
+ has nowhere near enough room in the 72px gutter that assumes just one
660
+ (Filters). This dropdown renders in the *title bar*, next to (and
661
+ styled like) the consolidated action items dropdown below — see
662
+ [Consolidated action items](#consolidated-action-items) — not inside
663
+ `#sidebar` itself, so the two read as one "more stuff lives here" row
664
+ instead of two disconnected mechanisms in different parts of the page.
665
+ Picking an option from it opens that section (closing every other
666
+ non-Filters one — one visible at a time, in `#sidebar`, same as ever)
667
+ and reflows the table just like Filters opening does. A section's own
668
+ header still opens/closes it directly too, keeping the dropdown in sync
669
+ either way. A page with no sections besides Filters (the common case)
670
+ shows no dropdown at all — just the one familiar icon button.
671
+
672
+ Pass your own icon via `sidebar "More Actions", icon: :list do ... end`
673
+ (any name from `lib/prism_icons.rb`) — it's only used on a section's own
674
+ header once it's open, since the collapsed dropdown itself doesn't render
675
+ per-section icons; anything else falls back to a generic one (`:filter`
676
+ for the Filters section specifically, `:list` otherwise). The index
677
+ table/main content area reflows to reclaim the freed-up width while
678
+ *every* section is collapsed, giving it back the moment any one of them
679
+ opens. Turn it off with `config.collapsible_filters = false` to always
680
+ show every section fully expanded, matching ActiveAdmin's own default
681
+ (and the table/content area at its normal, non-reflowing width).
636
682
 
637
683
  The reflow relies on the CSS `:has()` selector (broadly supported in
638
- current browsers); without it, the Filters panel still collapses/expands
639
- correctly, it just won't reclaim the extra width.
684
+ current browsers); without it, sections still collapse/expand correctly,
685
+ the reflow just won't reclaim the extra width.
686
+
687
+ ### Consolidated action items
688
+
689
+ A title bar with more than `action_items_dropdown_threshold` (default:
690
+ `3`) `action_item` buttons collapses all of them into a single Select2
691
+ "jump menu", aligned with the index table's own right edge, instead of a
692
+ multi-row wall of individual buttons — a resource registering a dozen+
693
+ CSV upload / bulk-action links is a real example this was built for.
694
+ (The table's own edge, not the page's: a table's column-driven width
695
+ often doesn't reach the page's full content width, so aligning to the
696
+ container instead would leave the dropdown looking stranded out past
697
+ the table it belongs to.) Picking an option fires that action
698
+ immediately (a plain `link_to` navigates, a `button_to` form submits —
699
+ whatever it actually was, including its own `data-confirm`/`data-method`)
700
+ and the dropdown resets right back to its placeholder, ready for the next
701
+ pick — it's a trigger, not a persistent selection. Purely client-side DOM
702
+ restructuring: `prism.js` moves each existing `action_item` element as-is
703
+ (not a clone) into a hidden holding area and `.click()`s the real
704
+ `<a>`/`<button>` inside it on selection, so whatever a host's own
705
+ `action_item` block rendered keeps working completely unmodified. Select2
706
+ itself is always available for this regardless of `config.select2` (that
707
+ flag only controls auto-enhancing a *host's* own selects) — the library
708
+ ships in this gem's JS either way. A page with only a couple of action
709
+ items (a lone "New Resource" button, say) is left untouched, rendering
710
+ inline exactly as ActiveAdmin does by default — the threshold exists so
711
+ this only kicks in for pages that actually need it. Turn it off entirely
712
+ with `config.action_items_dropdown = false`, or raise/lower
713
+ `config.action_items_dropdown_threshold` to change how many buttons it
714
+ takes before consolidation kicks in.
640
715
 
641
716
  ### Active filters bar
642
717
 
@@ -1035,30 +1110,80 @@ anything Prism itself renders:
1035
1110
  li.select2-results__message <- "No results found" etc.
1036
1111
  ```
1037
1112
 
1038
- ### Filters sidebar panel (`#filters_sidebar_section`)
1113
+ ### Collapsible sidebar sections (`.prism-collapsible-panel`)
1039
1114
 
1040
- Only this specific `SidebarSection` (AA's built-in id for the Filters
1041
- panel) gets the extra icon/collapse markup any other sidebar section
1042
- (dashboard panels, a host's own `sidebar :title do ... end`) is untouched:
1115
+ Every `SidebarSection` gets this markup — not just AA's built-in Filters
1116
+ panel; a host's own `sidebar "Title" do ... end` block gets it too:
1043
1117
 
1044
1118
  ```
1045
1119
  #sidebar <- AA's own right-hand content sidebar (not Prism's left nav)
1046
- .panel#filters_sidebar_section.prism-collapsible-panel[.open]
1120
+ .panel.prism-collapsible-panel[#filters_sidebar_section][.open]
1047
1121
  > h3 <- the icon-only button when collapsed
1048
- svg.prism-filter-icon
1122
+ svg.prism-filter-icon <- :filter for Filters, :list (or your own `icon:`) otherwise
1049
1123
  span.prism-filter-label <- visually hidden (max-width:0) while collapsed
1050
1124
  .panel_contents <- max-height:0 while collapsed, animates open
1051
- form.filter_form
1125
+ form.filter_form <- Filters section specifically
1052
1126
  .filter_form_field[.select_and_search][.filter_date_range]
1053
1127
  ```
1054
1128
 
1055
1129
  `.prism-collapsible-panel` and the icon/label markup are only added when
1056
- `config.collapsible_filters` is `true`; `prism.js` mirrors the panel's
1057
- `.open` state onto `body.prism-filters-open`, which is what
1058
- `#active_admin_content`/`#sidebar`'s reflow rules key off (`:has()` see
1059
- [Collapsible "Filters" sidebar](#collapsible-filters-sidebar)). With the config `false`,
1060
- `body.prism-filters-collapsible-disabled` is the backstop class that forces
1061
- the panel back to always-expanded.
1130
+ `config.collapsible_filters` is `true`; `prism.js` mirrors the Filters
1131
+ section's `.open` state onto `body.prism-filters-open` specifically (kept
1132
+ for any host CSS already keying off it), but `#active_admin_content`/
1133
+ `#sidebar`'s own reflow rule keys off *any* section's `.open` via `:has()`
1134
+ instead see [Collapsible "Filters" sidebar](#collapsible-filters-sidebar).
1135
+ With the config `false`, `body.prism-filters-collapsible-disabled` is the
1136
+ backstop class that forces every section back to always-expanded.
1137
+
1138
+ With at least one collapsible section besides Filters, `prism.js` also
1139
+ adds `.prism-sidebar-multi-panel` to `#sidebar` — which does nothing but
1140
+ hide each non-Filters section's own collapsed-state `> h3` (above) via
1141
+ CSS
1142
+ (`#sidebar.prism-sidebar-multi-panel .prism-collapsible-panel:not(.open):not(#filters_sidebar_section) > h3`),
1143
+ since its trigger lives elsewhere now (Filters' own `> h3` is never
1144
+ hidden by this rule, regardless) — and inserts the actual dropdown into
1145
+ the *title bar's* shared row instead of into `#sidebar` itself:
1146
+
1147
+ ```
1148
+ #titlebar_right
1149
+ div.action_items
1150
+ span#prism-titlebar-actions-row.prism-titlebar-actions-row
1151
+ span.prism-sidebar-panel-select-wrapper
1152
+ select.prism-sidebar-panel-select <- Select2-enhanced; one <option> per non-Filters section, by title
1153
+ span.prism-action-items-dropdown <- see below; may or may not be present on the same page
1154
+ ```
1155
+
1156
+ Selecting an option opens that section (in `#sidebar`, same as ever) and
1157
+ closes every other non-Filters one — Filters itself is excluded entirely
1158
+ and never appears in this dropdown's options.
1159
+
1160
+ ### Consolidated action items markup (`.prism-action-items-dropdown`)
1161
+
1162
+ Only present once `action_item` count exceeds
1163
+ `config.action_items_dropdown_threshold` (see
1164
+ [Consolidated action items](#consolidated-action-items)); shares
1165
+ `#prism-titlebar-actions-row` above with the "More Actions" dropdown when
1166
+ both exist on the same page (whichever one exists lands in that shared
1167
+ row on its own otherwise):
1168
+
1169
+ ```
1170
+ #titlebar_right
1171
+ div.action_items
1172
+ span#prism-titlebar-actions-row.prism-titlebar-actions-row
1173
+ span.prism-action-items-dropdown
1174
+ select.prism-action-items-select <- Select2-enhanced; one <option> per action_item, by its link/button text
1175
+ div.prism-action-items-holding[hidden]
1176
+ span.action_item <- every original action_item element, moved here as-is, never shown
1177
+ a / form <- whatever a host's own action_item block rendered, untouched
1178
+ ```
1179
+
1180
+ Selecting an option finds the real `<a>`/`<button>`/`<input type=submit>`
1181
+ inside the matching `.action_item` in `.prism-action-items-holding` and
1182
+ `.click()`s it directly, then resets the select back to its placeholder.
1183
+ The whole `#prism-titlebar-actions-row` (not each dropdown individually)
1184
+ is what a separate script in `prism.js` aligns to the index table's own
1185
+ right edge — see [Consolidated action items](#consolidated-action-items)
1186
+ for why.
1062
1187
 
1063
1188
  ### Active filters bar (`#prism_active_filters_bar`)
1064
1189
 
data/README.md CHANGED
@@ -12,7 +12,7 @@ theme, troubleshooting). This README is a quick start.
12
12
  ## Live demo
13
13
 
14
14
  A live demo dashboard is running at
15
- **[prism-demo.onrender.com/admin](https://prism-demo.onrender.com/admin)**:
15
+ **[prism-demo.onrender.com/admin](https://prism-demo.onrender.com/admin/login)**:
16
16
 
17
17
  ```
18
18
  Username: admin@example.com
@@ -120,6 +120,8 @@ ActiveAdminPrism.configure do |config|
120
120
  config.menu_search = true # search box that filters the sidebar's Pages nav
121
121
  config.select2 = false # default: false — auto-enhance every <select> into Select2
122
122
  config.sidebar_collapsible = true # sidebar collapses to an icon-only rail (desktop only)
123
+ config.action_items_dropdown = true # many title-bar action_items collapse into an "Actions" dropdown
124
+ config.action_items_dropdown_threshold = 3
123
125
  end
124
126
 
125
127
  ActiveAdminPrism.enable!