mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 01:31:42 +00:00
54 lines
1.4 KiB
Text
54 lines
1.4 KiB
Text
- unless post.errors.empty?
|
|
.alert.alert-danger
|
|
%h4= t('.errors.title')
|
|
%p= t('.errors.help')
|
|
|
|
%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
|
|
|
|
-# 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")
|
|
|
|
-# Comienza el formulario
|
|
= form_tag url, method: method, class: 'form post ' + extra_class, multipart: true do
|
|
|
|
-# Botones de guardado
|
|
= render 'posts/submit', site: site, post: post
|
|
|
|
= hidden_field_tag 'post[layout]', post.layout.name
|
|
|
|
-# Dibuja cada atributo
|
|
- post.attributes.each do |attribute|
|
|
- metadata = post[attribute]
|
|
- type = metadata.type
|
|
|
|
- cache metadata do
|
|
= render("posts/attributes/#{type}",
|
|
base: 'post', post: post, attribute: attribute,
|
|
metadata: metadata, site: site,
|
|
dir: dir, locale: @locale,
|
|
autofocus: (post.attributes.first == attribute))
|
|
|
|
-# Botones de guardado
|
|
= render 'posts/submit', site: site, post: post
|