Skip to content

Commit

Permalink
Add hooks for resource admin toolbars
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Jul 22, 2024
1 parent 58b4e7f commit 2688245
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 32 deletions.
2 changes: 2 additions & 0 deletions app/views/trestle/resource/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

<% toolbar(:primary) do |t| %>
<%= t.save_or_dismiss(:update) %>
<%= hook("edit.toolbar.primary", t) %>
<% end %>

<% toolbar(:secondary) do |t| %>
<%= t.delete %>
<%= hook("edit.toolbar.secondary", t) %>
<% end %>

<%= resource_turbo_frame(instance) do %>
Expand Down
5 changes: 5 additions & 0 deletions app/views/trestle/resource/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

<% toolbar(:primary) do |t| %>
<%= t.new %>
<%= hook("index.toolbar.primary", t) %>
<% end %>

<% toolbar(:secondary) do |t| %>
<%= hook("index.toolbar.secondary", t) %>
<% end %>

<% content_for(:utilities) do %>
Expand Down
5 changes: 5 additions & 0 deletions app/views/trestle/resource/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

<% toolbar(:primary) do |t| %>
<%= t.save_or_dismiss(:create) %>
<%= hook("new.toolbar.primary", t) %>
<% end %>

<% toolbar(:secondary) do |t| %>
<%= hook("new.toolbar.secondary", t) %>
<% end %>

<%= resource_turbo_frame(instance) do %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/trestle/resource/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

<% toolbar(:primary) do |t| %>
<%= t.save_or_dismiss(:update) %>
<%= hook("show.toolbar.primary", t) %>
<% end %>

<% toolbar(:secondary) do |t| %>
<%= t.delete %>
<%= hook("show.toolbar.secondary", t) %>
<% end %>

<%= resource_turbo_frame(instance) do %>
Expand Down
9 changes: 9 additions & 0 deletions sandbox/app/admin/articles_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
scope :active
end

hook "index.toolbar.secondary" do |t|
t.link "Batch Action (GET)", action: :batch_get, style: :info, data: { controller: "batch-action" }
t.link "Batch Action (POST)", action: :batch_post, style: :warning, data: { controller: "confirm batch-action", turbo_method: :post }
end

hook "new.toolbar.secondary" do |t|
t.link "Cancel", action: :index
end

table do
selectable_column
column :title, link: true, truncate: false
Expand Down
32 changes: 0 additions & 32 deletions sandbox/app/views/admin/articles/index.html.erb

This file was deleted.

0 comments on commit 2688245

Please sign in to comment.