5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 02:26:23 +00:00
panel/app/views/posts/_form.haml

48 lines
1.7 KiB
Text
Raw Permalink Normal View History

= render 'errors', post: post
2020-06-28 00:42:32 +00:00
-# TODO: habilitar form_for
:ruby
if post.new?
2020-05-26 22:02:52 +00:00
url = site_posts_path(site, locale: @locale)
method = :post
2020-06-28 00:42:15 +00:00
extra_class = 'new'
else
2020-05-26 22:02:52 +00:00
url = site_post_path(site, post.id, locale: @locale)
method = :patch
2020-06-28 00:42:15 +00:00
extra_class = 'edit'
end
2018-12-14 15:12:17 +00:00
- 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
2019-11-15 16:35:27 +00:00
-# Dibuja cada atributo
2024-04-17 21:09:55 +00:00
= 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
2024-05-24 16:10:55 +00:00
-# 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' } }