5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 20:26:22 +00:00

feat: soportar htmx al actualizar posts

This commit is contained in:
f 2024-06-04 17:09:04 -03:00
parent 74ed69d52c
commit 5a6ee375b1
No known key found for this signature in database

View file

@ -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'