dossier: make the upload label a real label

This commit is contained in:
Pierre de La Morinerie 2020-03-24 17:05:36 +00:00
parent 1de3674e36
commit f895570b00
4 changed files with 11 additions and 12 deletions

View file

@ -16,6 +16,10 @@ class Champs::PieceJustificativeChamp < Champ
"image/jpeg" "image/jpeg"
] ]
def main_value_name
:piece_justificative_file
end
def search_terms def search_terms
# We dont know how to search inside documents yet # We dont know how to search inside documents yet
end end
@ -51,8 +55,4 @@ class Champs::PieceJustificativeChamp < Champ
piece_justificative_file.service_url piece_justificative_file.service_url
end end
end end
def html_label?
false
end
end end

View file

@ -1,3 +1,3 @@
<%= render_flash(timeout: 5000, sticky: true) %> <%= render_flash(timeout: 5000, sticky: true) %>
<%= remove_element("#attachment_#{@attachment_id}") %> <%= remove_element(".attachment-actions-#{@attachment_id}") %>
<%= show_element("#attachment_file_#{@attachment_id}") %> <%= show_element(".attachment-input-#{@attachment_id}") %>

View file

@ -13,17 +13,16 @@
= link_to('le modèle suivant', url_for(template), target: '_blank', rel: 'noopener') = link_to('le modèle suivant', url_for(template), target: '_blank', rel: 'noopener')
- if persisted - if persisted
.attachment-actions{ id: "attachment_#{attachment_id}" } .attachment-actions{ class: "attachment-actions-#{attachment_id}" }
.attachment-action .attachment-action
= render partial: "shared/attachment/show", locals: { attachment: attachment, user_can_upload: true } = render partial: "shared/attachment/show", locals: { attachment: attachment, user_can_upload: true }
- if user_can_destroy - if user_can_destroy
.attachment-action .attachment-action
= link_to 'Supprimer', attachment_url(attachment.id, { signed_id: attachment.blob.signed_id }), remote: true, method: :delete, class: 'button small danger' = link_to 'Supprimer', attachment_url(attachment.id, { signed_id: attachment.blob.signed_id }), remote: true, method: :delete, class: 'button small danger'
.attachment-action .attachment-action
= button_tag 'Remplacer', type: 'button', class: 'button small', data: { 'toggle-target': "#attachment_file_#{attachment_id}" } = button_tag 'Remplacer', type: 'button', class: 'button small', data: { 'toggle-target': ".attachment-input-#{attachment_id}" }
= form.file_field attached_file.name, = form.file_field attached_file.name,
id: "attachment_file_#{attachment_id}", class: "attachment-input attachment-input-#{attachment_id} #{'hidden' if persisted}",
class: "attachment-input #{'hidden' if persisted}",
accept: accept, accept: accept,
direct_upload: true direct_upload: true

View file

@ -167,7 +167,7 @@ feature 'The user' do
fill_individual fill_individual
# Add an attachment # Add an attachment
find('.editable-champ-piece_justificative input[type=file]').attach_file(Rails.root + 'spec/fixtures/files/file.pdf') find_field('Pièce justificative').attach_file(Rails.root + 'spec/fixtures/files/file.pdf')
click_on 'Enregistrer le brouillon' click_on 'Enregistrer le brouillon'
expect(page).to have_content('Votre brouillon a bien été sauvegardé') expect(page).to have_content('Votre brouillon a bien été sauvegardé')
expect(page).to have_text('file.pdf') expect(page).to have_text('file.pdf')
@ -182,7 +182,7 @@ feature 'The user' do
# Replace the attachment # Replace the attachment
within('.attachment') { click_on 'Remplacer' } within('.attachment') { click_on 'Remplacer' }
find('.editable-champ-piece_justificative input[type=file]').attach_file(Rails.root + 'spec/fixtures/files/RIB.pdf') find_field('Pièce justificative').attach_file(Rails.root + 'spec/fixtures/files/RIB.pdf')
click_on 'Enregistrer le brouillon' click_on 'Enregistrer le brouillon'
expect(page).to have_no_text('file.pdf') expect(page).to have_no_text('file.pdf')
expect(page).to have_text('RIB.pdf') expect(page).to have_text('RIB.pdf')