backstage 0.1.9 → 0.1.11

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: 3c718b48851548675ae86452a060e6b6c18a21e712e4ea9cfb3f68379ce2828c
4
- data.tar.gz: ddc6fa00de9252402b7b4c5c86cac775f320d5ffd8d1457d07c909da72373575
3
+ metadata.gz: da942f19c113814d2f7a5e738b3b7f7ce1cc1e8b23beeaabe8e9ef7e1f0d1b50
4
+ data.tar.gz: 805dedf4003e77e48d6e9bf5eb426d3f24e91fe61297a97eebd3c1f8a858e8f1
5
5
  SHA512:
6
- metadata.gz: 20732846dea13229b3c45c2dccea6b689401bf627031ca9da44774e9738421def5fdd4cb2a53d46783ec53185fedc76742246ea40123883ac1822ab114086286
7
- data.tar.gz: fb271699d1ed51adf18b1891f0d9989d3660ab7cfeea1606f57cc882ef8bfbd73a6bc7a3613acff14c901413044c4476c348c4638b36c6bfe70afd4cd0582bb2
6
+ metadata.gz: 76d4dd10a000b8aeb880f7df124140c351553e44fd98ee3ab42b980cb7abb315297fc959c50a2f3770c48d289db77b28326d4073677046c43dc83cb12022d29d
7
+ data.tar.gz: 800c78a96cc7e9289edff896f5264d0aa73399c4ae30f1ad6557e100213a1c4975f6da1c823fc0f4842744952320f9fe18f3f6a5f1ebe7a3de9b964742c1999a
data/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.11] — 2026-05-25
11
+
12
+ ### Fixed
13
+
14
+ - Pagination window no longer generates links below page 1 or above the last page when there are fewer than 6 total pages; window is clamped to the valid inner range and skipped entirely when `total_pages <= 2`
15
+ - Sidebar moved from the layout into the edit view, rendering to the right of the form in a two-column grid; links open in a new tab (`target="_blank"`) and blank URLs (e.g. from a proc returning `""`) are skipped silently
16
+
17
+ ## [0.1.10] — 2026-05-25
18
+
19
+ ### Fixed
20
+
21
+ - Dashboard pages now use the same windowed pagination (5 pages around current + first/last links) as resource index pages; pagination logic extracted into a shared `backstage/shared/_pagination` partial
22
+ - Sidebar no longer renders on index, dashboard, or new-record pages; proc-based sidebar links were crashing with `NoMethodError` when `@record` was nil — sidebar is now guarded with `record&.persisted?`
23
+
10
24
  ## [0.1.9] — 2026-05-24
11
25
 
12
26
  ### Fixed
@@ -3,7 +3,8 @@ body { display: grid; grid-template-columns: 200px 1fr; grid-template-rows: auto
3
3
  header { grid-column: 1 / -1; }
4
4
  nav { padding: 1rem; grid-row: 2; grid-column: 1; }
5
5
  main { padding: 1rem; grid-row: 2; grid-column: 2; }
6
- aside { grid-column: 2; padding: 1rem; border-top: 1px solid var(--pico-muted-border-color); }
6
+ .edit-layout { display: grid; grid-template-columns: 1fr 220px; gap: 2rem; align-items: start; }
7
+ .edit-layout aside { border-left: 1px solid var(--pico-muted-border-color); padding-left: 1rem; }
7
8
 
8
9
  /* Override Pico's horizontal nav list */
9
10
  nav ul { flex-direction: column; }
@@ -27,10 +27,4 @@
27
27
  </tbody>
28
28
  </table>
29
29
 
30
- <% if @total_pages > 1 %>
31
- <nav>
32
- <% (1..@total_pages).each do |p| %>
33
- <%= link_to p, url_for(page: p), class: (p == @page ? "current" : nil) %>
34
- <% end %>
35
- </nav>
36
- <% end %>
30
+ <%= render "backstage/shared/pagination" %>
@@ -1,18 +1,35 @@
1
1
  <h1>Edit <%= @resource_config.model_class.model_name.human %></h1>
2
2
 
3
- <%= form_with model: @record, url: resource_path(resource: params[:resource], id: @record.id), method: :patch do |f| %>
4
- <% @resource_config.edit_fields.each do |field| %>
5
- <div>
6
- <%= f.label field.name %>
7
- <%= render partial: field.partial_path, locals: { f: f, field: field, record: @record } %>
8
- </div>
9
- <% end %>
10
- <%= f.submit "Save" %>
11
- <% end %>
3
+ <% sidebar = @resource_config.sidebar_config %>
4
+ <div class="<%= sidebar&.links&.any? ? "edit-layout" : "" %>">
5
+ <div>
6
+ <%= form_with model: @record, url: resource_path(resource: params[:resource], id: @record.id), method: :patch do |f| %>
7
+ <% @resource_config.edit_fields.each do |field| %>
8
+ <div>
9
+ <%= f.label field.name %>
10
+ <%= render partial: field.partial_path, locals: { f: f, field: field, record: @record } %>
11
+ </div>
12
+ <% end %>
13
+ <%= f.submit "Save" %>
14
+ <% end %>
15
+
16
+ <%= link_to "Cancel", resources_path(resource: params[:resource]) %>
12
17
 
13
- <%= link_to "Cancel", resources_path(resource: params[:resource]) %>
18
+ <%= button_to "Delete",
19
+ resource_path(resource: params[:resource], id: @record.id),
20
+ method: :delete,
21
+ data: { confirm_message: "Delete this #{@resource_config.model_class.model_name.human}?" } %>
22
+ </div>
14
23
 
15
- <%= button_to "Delete",
16
- resource_path(resource: params[:resource], id: @record.id),
17
- method: :delete,
18
- data: { confirm_message: "Delete this #{@resource_config.model_class.model_name.human}?" } %>
24
+ <% if sidebar&.links&.any? %>
25
+ <aside>
26
+ <ul>
27
+ <% sidebar.links.each do |link| %>
28
+ <% url = link.url_or_proc.respond_to?(:call) ? link.url_or_proc.call(@record) : link.url_or_proc %>
29
+ <% next if url.blank? %>
30
+ <li><%= link_to link.label, url, target: "_blank" %></li>
31
+ <% end %>
32
+ </ul>
33
+ </aside>
34
+ <% end %>
35
+ </div>
@@ -52,16 +52,4 @@
52
52
  </tbody>
53
53
  </table>
54
54
 
55
- <% if @total_pages > 1 %>
56
- <% window_start = [[@page - 2, 2].max, @total_pages - 4].min
57
- window_end = [[@page + 2, @total_pages - 1].min, 5].max %>
58
- <nav>
59
- <%= link_to "1", url_for(page: 1), class: (@page == 1 ? "current" : nil) %>
60
- <% if window_start > 2 %> &hellip;<% end %>
61
- <% (window_start..window_end).each do |p| %>
62
- &nbsp;<%= link_to p, url_for(page: p), class: (p == @page ? "current" : nil) %>
63
- <% end %>
64
- <% if window_end < @total_pages - 1 %> &hellip;<% end %>
65
- &nbsp;<%= link_to @total_pages, url_for(page: @total_pages), class: (@page == @total_pages ? "current" : nil) %>
66
- </nav>
67
- <% end %>
55
+ <%= render "backstage/shared/pagination" %>
@@ -0,0 +1,15 @@
1
+ <% if @total_pages > 1 %>
2
+ <nav>
3
+ <%= link_to "1", url_for(page: 1), class: (@page == 1 ? "current" : nil) %>
4
+ <% if @total_pages > 2 %>
5
+ <% window_start = [[@page - 2, 2].max, @total_pages - 4].min.clamp(2, @total_pages - 1)
6
+ window_end = [[@page + 2, @total_pages - 1].min, 5].max.clamp(2, @total_pages - 1) %>
7
+ <% if window_start > 2 %> &hellip;<% end %>
8
+ <% (window_start..window_end).each do |p| %>
9
+ &nbsp;<%= link_to p, url_for(page: p), class: (p == @page ? "current" : nil) %>
10
+ <% end %>
11
+ <% if window_end < @total_pages - 1 %> &hellip;<% end %>
12
+ <% end %>
13
+ &nbsp;<%= link_to @total_pages, url_for(page: @total_pages), class: (@page == @total_pages ? "current" : nil) %>
14
+ </nav>
15
+ <% end %>
@@ -44,17 +44,5 @@
44
44
  <main>
45
45
  <%= yield %>
46
46
  </main>
47
- <% sidebar = defined?(@resource_config) && @resource_config&.sidebar_config
48
- record = defined?(@record) ? @record : nil %>
49
- <% if sidebar&.links&.any? %>
50
- <aside>
51
- <ul>
52
- <% sidebar.links.each do |link| %>
53
- <% url = link.url_or_proc.respond_to?(:call) ? link.url_or_proc.call(record) : link.url_or_proc %>
54
- <li><%= link_to link.label, url %></li>
55
- <% end %>
56
- </ul>
57
- </aside>
58
- <% end %>
59
47
  </body>
60
48
  </html>
@@ -1,3 +1,3 @@
1
1
  module Backstage
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backstage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gareth James
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-24 00:00:00.000000000 Z
11
+ date: 2026-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -58,6 +58,7 @@ files:
58
58
  - app/views/backstage/resources/edit.html.erb
59
59
  - app/views/backstage/resources/index.html.erb
60
60
  - app/views/backstage/resources/new.html.erb
61
+ - app/views/backstage/shared/_pagination.html.erb
61
62
  - app/views/layouts/backstage/backstage.html.erb
62
63
  - config/routes.rb
63
64
  - lib/backstage.rb