5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 06:21:41 +00:00
panel/app/views/posts/attributes/_image.haml

39 lines
1.6 KiB
Text
Raw Normal View History

2019-08-23 18:29:07 +00:00
.form-group
- if metadata.uploaded?
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"
-# Mantener el valor si no enviamos ninguna imagen
= hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path']
.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"
.custom-file
= file_field(*field_name_for(base, attribute, :path),
2019-08-22 01:09:29 +00:00
**field_options(attribute, metadata),
2019-08-23 18:29:07 +00:00
class: "custom-file-input #{invalid(post, attribute)}",
accept: 'image/*', data: { preview: "#{attribute}-preview" })
= label_tag "#{base}_#{attribute}_path",
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
= label_tag "#{base}_#{attribute}_description",
post_label_t(attribute, :description, post: post)
= text_field(*field_name_for(base, attribute, :description),
value: metadata.value['description'],
dir: dir, lang: locale,
**field_options(attribute, metadata, required: false))
= render 'posts/attribute_feedback',
post: post, attribute: [attribute, :description], metadata: metadata