5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 01:56:22 +00:00
panel/app/views/posts/attributes/_image.haml
2024-06-04 12:49:37 -03:00

51 lines
2.4 KiB
Text

.form-group{ data: { controller: 'file-preview' } }
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
- if metadata.static_file
= image_tag url_for(metadata.static_file),
alt: metadata.value['description'],
class: 'img-fluid',
data: { target: 'file-preview.preview' }
-# Mantener el valor si no enviamos ninguna imagen
= hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path']
-# 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'
- else
= image_tag '',
alt: metadata.value['description'],
class: 'img-fluid',
data: { target: 'file-preview.preview' }
.custom-file
= file_field(*field_name_for(base, attribute, :path),
**field_options(attribute,
metadata,
required: (metadata.required && !metadata.path?)),
class: "custom-file-input #{invalid(post, attribute)}",
accept: ActiveStorage.web_image_content_types.join(','),
data: { target: 'file-preview.input',
action: 'file-preview#update' })
= 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
.form-group
= label_tag "#{base}_#{attribute}_description",
post_label_t(attribute, :description, post: post, required: false)
= 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