creation of attachment_upload_helpers and integration in the code
This commit is contained in:
parent
5df3838173
commit
b8a49e9012
6 changed files with 27 additions and 28 deletions
19
app/helpers/attachment_upload_helper.rb
Normal file
19
app/helpers/attachment_upload_helper.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
module AttachmentUploadHelper
|
||||||
|
def image_upload_and_render(form, file, direct_upload = nil)
|
||||||
|
render 'shared/attachment/edit', {
|
||||||
|
form: form,
|
||||||
|
attached_file: file,
|
||||||
|
accept: 'image/png, image/jpg, image/jpeg',
|
||||||
|
user_can_destroy: true,
|
||||||
|
direct_upload: direct_upload
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def text_upload_and_render(form, file)
|
||||||
|
render 'shared/attachment/edit', {
|
||||||
|
form: form,
|
||||||
|
attached_file: file,
|
||||||
|
user_can_destroy: true
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
|
@ -17,10 +17,7 @@
|
||||||
|
|
||||||
= form_for @avis, url: instructeur_avis_path(@avis.procedure, @avis), html: { class: 'form' } do |f|
|
= form_for @avis, url: instructeur_avis_path(@avis.procedure, @avis), html: { class: 'form' } do |f|
|
||||||
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
|
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
|
||||||
= render 'shared/attachment/edit',
|
= text_upload_and_render f, @avis.piece_justificative_file
|
||||||
{ form: f,
|
|
||||||
attached_file: @avis.piece_justificative_file,
|
|
||||||
user_can_destroy: true }
|
|
||||||
|
|
||||||
.flex.justify-between.align-baseline
|
.flex.justify-between.align-baseline
|
||||||
%p.confidentiel.flex
|
%p.confidentiel.flex
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
= f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
|
= f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
|
||||||
%p.tab-title Ajouter une pièce jointe
|
%p.tab-title Ajouter une pièce jointe
|
||||||
.form-group
|
.form-group
|
||||||
= render 'shared/attachment/edit',
|
= text_upload_and_render f, avis.introduction_file
|
||||||
{ form: f,
|
|
||||||
attached_file: avis.introduction_file,
|
|
||||||
user_can_destroy: true }
|
|
||||||
|
|
||||||
- if linked_dossiers.present?
|
- if linked_dossiers.present?
|
||||||
= f.check_box :invite_linked_dossiers, {}, true, false
|
= f.check_box :invite_linked_dossiers, {}, true, false
|
||||||
|
|
|
@ -14,11 +14,7 @@
|
||||||
= f.text_area :description, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control'
|
= f.text_area :description, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control'
|
||||||
|
|
||||||
%h3.header-subsection Logo de la démarche
|
%h3.header-subsection Logo de la démarche
|
||||||
= render 'shared/attachment/edit',
|
= image_upload_and_render f, @procedure.logo
|
||||||
{ form: f,
|
|
||||||
attached_file: @procedure.logo,
|
|
||||||
accept: 'image/png, image/jpg, image/jpeg',
|
|
||||||
user_can_destroy: true }
|
|
||||||
|
|
||||||
- if !@procedure.locked?
|
- if !@procedure.locked?
|
||||||
%h3.header-subsection Conservation des données
|
%h3.header-subsection Conservation des données
|
||||||
|
@ -59,10 +55,7 @@
|
||||||
= f.text_field :cadre_juridique, class: 'form-control', placeholder: 'https://www.legifrance.gouv.fr/'
|
= f.text_field :cadre_juridique, class: 'form-control', placeholder: 'https://www.legifrance.gouv.fr/'
|
||||||
|
|
||||||
= f.label :deliberation, 'Importer le texte'
|
= f.label :deliberation, 'Importer le texte'
|
||||||
= render 'shared/attachment/edit',
|
= text_upload_and_render f, @procedure.deliberation
|
||||||
{ form: f,
|
|
||||||
attached_file: @procedure.deliberation,
|
|
||||||
user_can_destroy: true }
|
|
||||||
|
|
||||||
%h3.header-subsection Notice explicative de la démarche
|
%h3.header-subsection Notice explicative de la démarche
|
||||||
|
|
||||||
|
@ -73,10 +66,7 @@
|
||||||
%p.notice
|
%p.notice
|
||||||
Formats acceptés : .doc, .odt, .pdf, .ppt, .pptx
|
Formats acceptés : .doc, .odt, .pdf, .ppt, .pptx
|
||||||
- notice = @procedure.notice
|
- notice = @procedure.notice
|
||||||
= render 'shared/attachment/edit',
|
= text_upload_and_render f, @procedure.notice
|
||||||
{ form: f,
|
|
||||||
attached_file: @procedure.notice,
|
|
||||||
user_can_destroy: true }
|
|
||||||
|
|
||||||
- if !@procedure.locked?
|
- if !@procedure.locked?
|
||||||
%h3.header-subsection À qui s’adresse ma démarche ?
|
%h3.header-subsection À qui s’adresse ma démarche ?
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
- persisted = attachment && attachment.persisted?
|
- persisted = attachment && attachment.persisted?
|
||||||
- accept = defined?(accept) ? accept : nil
|
- accept = defined?(accept) ? accept : nil
|
||||||
- user_can_destroy = defined?(user_can_destroy) ? user_can_destroy : false
|
- user_can_destroy = defined?(user_can_destroy) ? user_can_destroy : false
|
||||||
|
- direct_upload = direct_upload != nil ? false : true
|
||||||
|
|
||||||
.attachment
|
.attachment
|
||||||
- if defined?(template) && template.attached?
|
- if defined?(template) && template.attached?
|
||||||
|
@ -34,5 +35,5 @@
|
||||||
= form.file_field attached_file.name,
|
= form.file_field attached_file.name,
|
||||||
class: "attachment-input attachment-input-#{attachment_id} #{'hidden' if persisted}",
|
class: "attachment-input attachment-input-#{attachment_id} #{'hidden' if persisted}",
|
||||||
accept: accept,
|
accept: accept,
|
||||||
direct_upload: true,
|
direct_upload: direct_upload,
|
||||||
data: { 'auto-attach-url': auto_attach_url(form, form.object) }
|
data: { 'auto-attach-url': auto_attach_url(form, form.object) }
|
||||||
|
|
|
@ -5,12 +5,7 @@ describe 'shared/attachment/_update.html.haml', type: :view do
|
||||||
|
|
||||||
subject do
|
subject do
|
||||||
form_for(champ.dossier) do |form|
|
form_for(champ.dossier) do |form|
|
||||||
render 'shared/attachment/edit', {
|
view.image_upload_and_render form, attached_file
|
||||||
form: form,
|
|
||||||
attached_file: attached_file,
|
|
||||||
accept: 'image/png',
|
|
||||||
user_can_destroy: user_can_destroy
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue