diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 8b103422..0f3c24d5 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -165,7 +165,24 @@ class PostsController < ApplicationController if service.update.persisted? site.touch forget_content + end + if htmx? + if post.persisted? + swap_modals + + @value = post.title.value + @uuid = post.uuid.value + @name = params.require(:name) + + render render_path_from_attribute, layout: false + else + headers['HX-Retarget'] = "##{params.require(:form)}" + headers['HX-Reswap'] = 'outerHTML' + + render 'posts/form', layout: false, post: post, site: site, **params.permit(:form, :base, :dir, :locale) + end + elsif post.persisted? redirect_to site_post_path(site, post) else render 'posts/edit'