2019-08-23 18:29:07 +00:00
|
|
|
.form-group
|
2024-05-03 17:06:32 +00:00
|
|
|
|
|
|
|
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
|
2022-07-25 19:01:08 +00:00
|
|
|
- if metadata.static_file
|
2019-08-22 01:09:29 +00:00
|
|
|
= image_tag url_for(metadata.static_file),
|
|
|
|
alt: metadata.value['description'],
|
|
|
|
class: 'img-fluid',
|
|
|
|
id: "#{attribute}-preview"
|
|
|
|
|
2020-09-01 21:33:10 +00:00
|
|
|
-# Mantener el valor si no enviamos ninguna imagen
|
2020-11-27 22:32:16 +00:00
|
|
|
= hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path']
|
2021-02-24 19:31:57 +00:00
|
|
|
-# Las imágenes requeridas solo se pueden reemplazar
|
|
|
|
- unless metadata.required
|
|
|
|
.custom-control.custom-switch
|
|
|
|
= check_box_tag "#{base}[#{attribute}][path]", '', false, id: "#{base}_#{attribute}_destroy", class: 'custom-control-input'
|
|
|
|
= label_tag "#{base}_#{attribute}_destroy", t('posts.attributes.image.destroy'), class: 'custom-control-label'
|
2020-11-20 00:23:23 +00:00
|
|
|
- else
|
|
|
|
= image_tag '',
|
|
|
|
alt: metadata.value['description'],
|
|
|
|
class: 'img-fluid',
|
|
|
|
id: "#{attribute}-preview"
|
2019-08-13 19:09:23 +00:00
|
|
|
|
|
|
|
.custom-file
|
2020-11-27 22:32:16 +00:00
|
|
|
= file_field(*field_name_for(base, attribute, :path),
|
2021-02-24 19:31:57 +00:00
|
|
|
**field_options(attribute, metadata, required: (metadata.required && !metadata.path?)),
|
2019-08-23 18:29:07 +00:00
|
|
|
class: "custom-file-input #{invalid(post, attribute)}",
|
2023-04-10 21:21:33 +00:00
|
|
|
accept: ActiveStorage.web_image_content_types.join(','), data: { preview: "#{attribute}-preview" })
|
2020-11-27 22:32:16 +00:00
|
|
|
= label_tag "#{base}_#{attribute}_path",
|
2019-08-13 19:09:23 +00:00
|
|
|
post_label_t(attribute, :path, post: post), class: 'custom-file-label'
|
|
|
|
= render 'posts/attribute_feedback',
|
|
|
|
post: post, attribute: [attribute, :path], metadata: metadata
|
|
|
|
|
2019-08-23 18:29:07 +00:00
|
|
|
.form-group
|
2020-11-27 22:32:16 +00:00
|
|
|
= label_tag "#{base}_#{attribute}_description",
|
2021-02-24 19:31:57 +00:00
|
|
|
post_label_t(attribute, :description, post: post, required: false)
|
2020-11-27 22:32:16 +00:00
|
|
|
= text_field(*field_name_for(base, attribute, :description),
|
2019-08-13 19:09:23 +00:00
|
|
|
value: metadata.value['description'],
|
2020-05-23 19:34:45 +00:00
|
|
|
dir: dir, lang: locale,
|
2021-02-11 14:49:15 +00:00
|
|
|
**field_options(attribute, metadata, required: false))
|
2019-08-13 19:09:23 +00:00
|
|
|
= render 'posts/attribute_feedback',
|
|
|
|
post: post, attribute: [attribute, :description], metadata: metadata
|