mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 06:16:22 +00:00
42 lines
1.2 KiB
Text
42 lines
1.2 KiB
Text
|
-#
|
||
|
El formulario del artículo, con HTMX activado.
|
||
|
|
||
|
@param :site [Site]
|
||
|
@param :post [Post]
|
||
|
@param :locale [Symbol, String]
|
||
|
@param :dir [Symbol, String]
|
||
|
:ruby
|
||
|
options = {
|
||
|
multipart: true,
|
||
|
class: 'form post ',
|
||
|
'hx-swap': params.require(:swap),
|
||
|
'hx-target': "##{params.require(:target)}"
|
||
|
}
|
||
|
|
||
|
if post.new?
|
||
|
url = options[:'hx-post'] = site_posts_path(site, locale: locale)
|
||
|
options[:class] += 'new'
|
||
|
else
|
||
|
url = options[:'hx-patch'] = site_post_path(site, post.id, locale: locale)
|
||
|
options[:method] = :patch
|
||
|
options[:class] += 'edit'
|
||
|
end
|
||
|
|
||
|
= form_tag url, **options do
|
||
|
-# Parámetros para HTMX
|
||
|
%input{ type: 'hidden', name: 'hide', value: params.require(:show) }
|
||
|
%input{ type: 'hidden', name: 'show', value: params.require(:hide) }
|
||
|
%input{ type: 'hidden', name: 'name', value: params.require(:name) }
|
||
|
%input{ type: 'hidden', name: 'base', value: params.require(:base) }
|
||
|
|
||
|
-# Botones de guardado
|
||
|
= render 'posts/submit', site: site, post: post
|
||
|
|
||
|
= hidden_field_tag "#{base}[layout]", post.layout.name
|
||
|
|
||
|
-# Dibuja cada atributo
|
||
|
= render 'posts/attributes', site: site, post: post, dir: dir, base: base, locale: locale
|
||
|
|
||
|
-# Botones de guardado
|
||
|
= render 'posts/submit', site: site, post: post
|