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:
parent
74ed69d52c
commit
5a6ee375b1
1 changed files with 17 additions and 0 deletions
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue