diff --git a/app/helpers/trestle/turbo/frame_helper.rb b/app/helpers/trestle/turbo/frame_helper.rb index 4f4252a6..fa570fd0 100644 --- a/app/helpers/trestle/turbo/frame_helper.rb +++ b/app/helpers/trestle/turbo/frame_helper.rb @@ -1,34 +1,6 @@ module Trestle module Turbo module FrameHelper - # Renders a container for an index view. An index turbo frame - # is by default reloadable (it will be refreshed by the `reload` turbo stream - # action), and has the Turbo visit behavior always set to "advance". - # - # attributes - Additional HTML attributes to add to the tag - # - # Examples - # - # <%= index_turbo_frame do %> ... - # - # <%= index_turbo_frame id: "articles-index", - # data: { - # reloadable_url_value: admin.path(:articles) - # } do %> ... - # - # Returns a HTML-safe String. - def index_turbo_frame(**attributes, &block) - defaults = { - id: "index", - data: { - controller: "reloadable", - turbo_action: "advance" - } - } - - tag.turbo_frame(**defaults.merge(attributes), &block) - end - # Renders a container for an instance/resource view. A resource # turbo frame sets its DOM id from the given instance and has a default target of # "_top" (except for modal requests). @@ -53,6 +25,16 @@ def resource_turbo_frame(instance, **attributes, &block) tag.turbo_frame(**defaults.merge(attributes), &block) end + + # [DEPRECATED] + # + # The #content turbo-frame found in app/views/trestle/application/_layout.html.erb + # is now used as a common top-level hook for the 'reloadable' Stimulus controller. + def index_turbo_frame(**attributes, &block) + Trestle.deprecator.warn("The index_turbo_frame helper is deprecated and will be removed in future versions of Trestle.") + yield + nil + end end end end diff --git a/app/views/layouts/trestle/admin.html.erb b/app/views/layouts/trestle/admin.html.erb index 2942c890..8b3f6fc2 100644 --- a/app/views/layouts/trestle/admin.html.erb +++ b/app/views/layouts/trestle/admin.html.erb @@ -43,9 +43,9 @@
<%= render "trestle/shared/header" %> - +
<%= yield %> - +
<%= render "trestle/shared/footer" %>
diff --git a/app/views/layouts/trestle/admin.turbo_stream.erb b/app/views/layouts/trestle/admin.turbo_stream.erb deleted file mode 100644 index 91a381e4..00000000 --- a/app/views/layouts/trestle/admin.turbo_stream.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= yield %> - -<%= turbo_stream.flash unless modal_request? %> -<%= turbo_stream.reload %> diff --git a/app/views/trestle/application/_layout.html.erb b/app/views/trestle/application/_layout.html.erb index f3fabe0b..a9b39700 100644 --- a/app/views/trestle/application/_layout.html.erb +++ b/app/views/trestle/application/_layout.html.erb @@ -1,22 +1,26 @@ -<%= render "header", hide_breadcrumbs: local_assigns.fetch(:hide_breadcrumbs, false) if local_assigns.fetch(:header, true) %> + + <%= render "header", hide_breadcrumbs: local_assigns.fetch(:hide_breadcrumbs, false) if local_assigns.fetch(:header, true) %> -
- - <%= render "trestle/flash/flash" %> - +
+ + <%= render "trestle/flash/flash" %> + - <%= render "utilities" %> - <%= render "tabs", data: { controller: "tabs tab-errors" } %> + + <%= render "utilities" %> + <%= render "tabs", data: { controller: "tabs tab-errors" } %> - <% if local_assigns.fetch(:wrapper, true) %> - <%= container do |c| %> - <%= yield %> + <% if local_assigns.fetch(:wrapper, true) %> + <%= container do |c| %> + <%= yield %> - <% c.sidebar do %> - <%= content_for(:sidebar) %> - <% end if content_for?(:sidebar) %> - <% end %> - <% else %> - <%= yield %> - <% end %> -
+ <% c.sidebar do %> + <%= content_for(:sidebar) %> + <% end if content_for?(:sidebar) %> + <% end %> + <% else %> + <%= yield %> + <% end %> + +
+
diff --git a/app/views/trestle/resource/create.turbo_stream.erb b/app/views/trestle/resource/create.turbo_stream.erb index dd366fff..bb051f2e 100644 --- a/app/views/trestle/resource/create.turbo_stream.erb +++ b/app/views/trestle/resource/create.turbo_stream.erb @@ -1 +1,2 @@ <%= turbo_stream.replace admin.build_instance({}, params), template: "trestle/resource/#{instance.persisted? ? "show" : "new"}" %> +<%= turbo_stream.reload if modal_request? && instance.persisted? %> diff --git a/app/views/trestle/resource/destroy.turbo_stream.erb b/app/views/trestle/resource/destroy.turbo_stream.erb index 6e003df4..a00e98d8 100644 --- a/app/views/trestle/resource/destroy.turbo_stream.erb +++ b/app/views/trestle/resource/destroy.turbo_stream.erb @@ -1 +1,3 @@ <%= turbo_stream.close_modal instance %> +<%= turbo_stream.flash %> +<%= turbo_stream.reload %> diff --git a/app/views/trestle/resource/index.html.erb b/app/views/trestle/resource/index.html.erb index d1eec9b5..e4ece34b 100644 --- a/app/views/trestle/resource/index.html.erb +++ b/app/views/trestle/resource/index.html.erb @@ -14,19 +14,17 @@ <% end if admin.scopes.any? %> <%= render layout: "layout" do %> - <%= index_turbo_frame do %> - <% if hook?("resource.index.header") %> -
- <%= hook("resource.index.header") %> -
- <% end %> + <% if hook?("resource.index.header") %> +
+ <%= hook("resource.index.header") %> +
+ <% end %> - <%= render "trestle/table/table", table: admin.table, collection: collection %> + <%= render "trestle/table/table", table: admin.table, collection: collection %> - <% end %> diff --git a/app/views/trestle/resource/update.turbo_stream.erb b/app/views/trestle/resource/update.turbo_stream.erb index 1a984346..7594a176 100644 --- a/app/views/trestle/resource/update.turbo_stream.erb +++ b/app/views/trestle/resource/update.turbo_stream.erb @@ -1 +1,2 @@ <%= turbo_stream.replace instance, template: "trestle/resource/show" %> +<%= turbo_stream.reload if modal_request? %>