2019-08-13 19:09:23 +00:00
|
|
|
- unless post.errors.empty?
|
2023-03-28 21:52:42 +00:00
|
|
|
- title = t('.errors.title')
|
|
|
|
- help = t('.errors.help')
|
2023-03-29 15:05:55 +00:00
|
|
|
= render 'bootstrap/alert' do
|
2023-03-28 21:52:42 +00:00
|
|
|
%h4= title
|
|
|
|
%p= help
|
2018-02-02 22:20:31 +00:00
|
|
|
|
2020-06-28 00:42:32 +00:00
|
|
|
%ul
|
|
|
|
- post.errors.each do |attribute, errors|
|
|
|
|
- if errors.size > 1
|
|
|
|
%li
|
|
|
|
%strong= post_label_t attribute, post: post
|
|
|
|
%ul
|
|
|
|
- errors.each do |error|
|
|
|
|
%li= error
|
|
|
|
- else
|
|
|
|
%li
|
|
|
|
%strong= post_label_t attribute, post: post
|
|
|
|
= errors.first
|
|
|
|
|
2019-08-13 19:09:23 +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)
|
2019-08-13 19:09:23 +00:00
|
|
|
method = :post
|
2020-06-28 00:42:15 +00:00
|
|
|
extra_class = 'new'
|
2019-08-13 19:09:23 +00:00
|
|
|
else
|
2020-05-26 22:02:52 +00:00
|
|
|
url = site_post_path(site, post.id, locale: @locale)
|
2019-08-13 19:09:23 +00:00
|
|
|
method = :patch
|
2020-06-28 00:42:15 +00:00
|
|
|
extra_class = 'edit'
|
2019-08-13 19:09:23 +00:00
|
|
|
end
|
2018-12-14 15:12:17 +00:00
|
|
|
|
2020-05-23 19:34:45 +00:00
|
|
|
- dir = t("locales.#{@locale}.dir")
|
2024-06-19 21:19:07 +00:00
|
|
|
- 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
|
2020-05-23 19:34:45 +00:00
|
|
|
|
2019-08-13 19:09:23 +00:00
|
|
|
-# Comienza el formulario
|
2024-06-19 21:19:07 +00:00
|
|
|
= form_tag url, method: method, class: "form post #{extra_class}", multipart: true, data: data do
|
2019-08-13 19:09:23 +00:00
|
|
|
-# Botones de guardado
|
2024-06-19 21:19:07 +00:00
|
|
|
= render 'posts/submit', site: site, post: post, invalid: invalid_id, submitting: submitting_id
|
2019-08-13 19:09:23 +00:00
|
|
|
|
2020-04-06 22:21:14 +00:00
|
|
|
= hidden_field_tag 'post[layout]', post.layout.name
|
2019-11-15 16:35:27 +00:00
|
|
|
|
2019-08-13 19:09:23 +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
|
2019-08-13 19:09:23 +00:00
|
|
|
|
|
|
|
-# Botones de guardado
|
2024-06-19 21:19:07 +00:00
|
|
|
= 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)
|