5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-25 05:16:22 +00:00
panel/app/views/posts/_form.haml

47 lines
1.7 KiB
Text

= render 'errors', post: post
-# TODO: habilitar form_for
:ruby
if post.new?
url = site_posts_path(site, locale: @locale)
method = :post
extra_class = 'new'
else
url = site_post_path(site, post.id, locale: @locale)
method = :patch
extra_class = 'edit'
end
- dir = t("locales.#{@locale}.dir")
- submitting_id = random_id
- invalid_id = random_id
- data = {}
- data[:controller] = 'unsaved-changes form-validation'
- data[:action] = 'unsaved-changes#submit form-validation#submit beforeunload@window->unsaved-changes#unsaved turbolinks:before-visit@window->unsaved-changes#unsavedTurbolinks'
- data[:'unsaved-changes-confirm-value'] = t('.confirm')
- data[:'form-validation-submitting-id-value'] = submitting_id
- data[:'form-validation-invalid-id-value'] = invalid_id
-# Comienza el formulario
= form_tag url, method: method, class: "form post #{extra_class}", multipart: true, data: data do
-# Botones de guardado
= render 'posts/submit', site: site, post: post, invalid: invalid_id, submitting: submitting_id
= hidden_field_tag 'post[layout]', post.layout.name
-# Dibuja cada atributo
= render 'posts/attributes', site: site, post: post, dir: dir, base: 'post', locale: @locale
-# Botones de guardado
= render 'posts/submit', site: site, post: post, invalid: invalid_id, submitting: submitting_id
-# Formularios usados por los modales
= yield(:post_form)
-#
Acumulador de formularios dinámicos, se van cargando a medida que se
necesitan en lugar de recursivamente.
Nunca se eliminan los modales una vez que se cargan para poder tener
historial de cambios.
%div{ data: { controller: 'htmx', action: 'htmx:getUrl@window->htmx#beforeend' } }