2024-03-25 18:33:10 +00:00
|
|
|
.form-group{ data: { controller: 'file-preview' } }
|
2024-05-03 17:06:32 +00:00
|
|
|
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
|
2021-02-23 22:16:58 +00:00
|
|
|
- if metadata.static_file
|
2020-05-26 19:39:10 +00:00
|
|
|
- case metadata.static_file.blob.content_type
|
2024-06-04 15:49:37 +00:00
|
|
|
- when %r{\Avideo/}
|
|
|
|
= video_tag url_for(metadata.static_file),
|
|
|
|
controls: true, class: 'img-fluid',
|
|
|
|
data: { target: 'file-preview.preview' }
|
|
|
|
- when %r{\Aaudio/}
|
|
|
|
= audio_tag url_for(metadata.static_file),
|
|
|
|
controls: true, class: 'img-fluid',
|
|
|
|
data: { target: 'file-preview.preview' }
|
|
|
|
- when 'application/pdf'
|
|
|
|
%iframe{ src: url_for(metadata.static_file) }
|
|
|
|
- else
|
|
|
|
= link_to t('posts.attribute_ro.file.download'),
|
|
|
|
url_for(metadata.static_file)
|
2022-07-25 19:01:08 +00:00
|
|
|
-# Mantener el valor si no enviamos ninguna imagen
|
|
|
|
= hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path']
|
|
|
|
-# Los archivos requeridos solo se pueden reemplazar
|
|
|
|
- unless metadata.required
|
|
|
|
.custom-control.custom-switch
|
2024-06-04 15:49:37 +00:00
|
|
|
= check_box_tag "#{base}[#{attribute}][path]",
|
|
|
|
'',
|
|
|
|
false,
|
|
|
|
id: "#{base}_#{attribute}_destroy",
|
|
|
|
class: 'custom-control-input'
|
|
|
|
= label_tag "#{base}_#{attribute}_destroy",
|
|
|
|
t('posts.attributes.file.destroy'),
|
|
|
|
class: 'custom-control-label'
|
2020-05-26 19:39:10 +00:00
|
|
|
|
2019-11-07 16:08:14 +00:00
|
|
|
.custom-file
|
2020-11-27 22:32:16 +00:00
|
|
|
= file_field(*field_name_for(base, attribute, :path),
|
2024-06-04 15:49:37 +00:00
|
|
|
**field_options(attribute,
|
|
|
|
metadata,
|
|
|
|
required: (metadata.required && !metadata.path?)),
|
|
|
|
class: "custom-file-input #{invalid(post, attribute)}",
|
|
|
|
data: { target: 'file-preview.input',
|
|
|
|
action: 'file-preview#update' })
|
2020-11-27 22:32:16 +00:00
|
|
|
= label_tag "#{base}_#{attribute}_path",
|
2024-06-04 15:49:37 +00:00
|
|
|
post_label_t(attribute, :path, post: post),
|
|
|
|
class: 'custom-file-label'
|
2019-11-07 16:08:14 +00:00
|
|
|
= render 'posts/attribute_feedback',
|
2024-06-04 15:49:37 +00:00
|
|
|
post: post, attribute: [attribute, :path], metadata: metadata
|
2019-11-07 16:08:14 +00:00
|
|
|
|
|
|
|
.form-group
|
2020-11-27 22:32:16 +00:00
|
|
|
= label_tag "#{base}_#{attribute}_description",
|
2024-06-04 15:49:37 +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),
|
2024-06-04 15:49:37 +00:00
|
|
|
value: metadata.value['description'],
|
|
|
|
dir: dir, lang: locale,
|
|
|
|
**field_options(attribute, metadata, required: false))
|
2019-11-07 16:08:14 +00:00
|
|
|
= render 'posts/attribute_feedback',
|
2024-06-04 15:49:37 +00:00
|
|
|
post: post, attribute: [attribute, :description], metadata: metadata
|