fix(dossier): instructeur actions should be buttons and not links
This commit is contained in:
parent
0b95a912c6
commit
207ce21327
6 changed files with 54 additions and 34 deletions
|
@ -7,7 +7,7 @@
|
|||
dossier_is_followed: current_instructeur&.follow?(dossier),
|
||||
close_to_expiration: dossier.close_to_expiration?,
|
||||
hidden_by_administration: dossier.hidden_by_administration?,
|
||||
post_method: {data: { turbo_method: :post }}}
|
||||
turbo: true }
|
||||
|
||||
%li.instruction-button
|
||||
= render partial: "instruction_button", locals: { dossier: dossier }
|
||||
|
|
|
@ -1,47 +1,49 @@
|
|||
- if hidden_by_administration
|
||||
%li
|
||||
= link_to restore_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "fr-btn fr-icon-refresh-line" do
|
||||
= button_to restore_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "fr-btn fr-icon-refresh-line" do
|
||||
= t('views.instructeurs.dossiers.restore')
|
||||
- elsif close_to_expiration || Dossier::TERMINE.include?(state)
|
||||
%li{ 'data-turbo': 'true' }
|
||||
%li
|
||||
- if close_to_expiration
|
||||
= link_to repasser_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), { class: 'fr-btn fr-btn--secondary fr-icon-edit-line' }.deep_merge!(post_method) do
|
||||
= button_to repasser_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: 'fr-btn fr-btn--secondary fr-icon-edit-line', form: { data: { turbo: turbo ? 'true' : 'false' } } do
|
||||
Repasser en instruction
|
||||
|
||||
= link_to(repousser_expiration_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: "fr-btn") do
|
||||
= button_to repousser_expiration_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: "fr-btn" do
|
||||
= t('instructeurs.dossiers.header.banner.button_delay_expiration')
|
||||
|
||||
- elsif archived
|
||||
= link_to( unarchive_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "fr-btn fr-icon-upload-2-line") do
|
||||
= button_to unarchive_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: "fr-btn fr-icon-upload-2-line" do
|
||||
Désarchiver le dossier
|
||||
|
||||
= link_to('', instructeur_dossier_path(procedure_id, dossier_id), method: :delete, class: 'fr-btn fr-btn--secondary fr-icon-delete-line icon-only danger', title: t('views.instructeurs.dossiers.delete_dossier'))
|
||||
= button_to instructeur_dossier_path(procedure_id, dossier_id), method: :delete, class: 'fr-btn fr-btn--secondary fr-icon-delete-line icon-only danger', title: t('views.instructeurs.dossiers.delete_dossier') do
|
||||
= ""
|
||||
|
||||
- else
|
||||
= link_to repasser_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), { class: 'fr-btn fr-btn--secondary fr-icon-edit-line' }.deep_merge!(post_method) do
|
||||
= button_to repasser_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: 'fr-btn fr-btn--secondary fr-icon-edit-line', form: { data: { turbo: turbo ? 'true' : 'false' } } do
|
||||
Repasser en instruction
|
||||
|
||||
= link_to( archive_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-icon-folder-2-line') do
|
||||
= button_to archive_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-icon-folder-2-line' do
|
||||
Archiver le dossier
|
||||
|
||||
= link_to('', instructeur_dossier_path(procedure_id, dossier_id), method: :delete, class: 'fr-btn fr-btn--secondary fr-icon-delete-line icon-only danger', title: t('views.instructeurs.dossiers.delete_dossier'))
|
||||
= button_to instructeur_dossier_path(procedure_id, dossier_id), method: :delete, class: 'fr-btn fr-btn--secondary fr-icon-delete-line icon-only danger', title: t('views.instructeurs.dossiers.delete_dossier') do
|
||||
= ""
|
||||
|
||||
- elsif Dossier::EN_CONSTRUCTION_OU_INSTRUCTION.include?(state)
|
||||
- if Dossier.states[:en_construction] == state
|
||||
%li{ 'data-turbo': 'true' }
|
||||
= link_to passer_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), { class: 'fr-btn fr-btn--secondary fr-icon-edit-line' }.deep_merge!(post_method) do
|
||||
%li{ 'data-turbo': turbo ? 'true' : 'false' }
|
||||
= button_to passer_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: 'fr-btn fr-btn--secondary fr-icon-edit-line' do
|
||||
Passer en instruction
|
||||
- elsif Dossier.states[:en_instruction] == state
|
||||
%li{ 'data-turbo': 'true' }
|
||||
= link_to repasser_en_construction_instructeur_dossier_path(procedure_id, dossier_id), { class: 'fr-btn fr-btn--secondary fr-icon-draft-line' }.deep_merge!(post_method) do
|
||||
%li{ 'data-turbo': turbo ? 'true' : 'false' }
|
||||
= button_to repasser_en_construction_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: 'fr-btn fr-btn--secondary fr-icon-draft-line' do
|
||||
Repasser en construction
|
||||
|
||||
|
||||
- if dossier_is_followed
|
||||
%li
|
||||
= link_to unfollow_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-btn--secondary fr-icon-star-fill' do
|
||||
= button_to unfollow_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-btn--secondary fr-icon-star-fill' do
|
||||
= t('views.instructeurs.dossiers.stop_follow')
|
||||
- else
|
||||
%li
|
||||
= link_to follow_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-icon-star-line' do
|
||||
= button_to follow_instructeur_dossier_path(procedure_id, dossier_id), method: :patch, class: 'fr-btn fr-icon-star-line' do
|
||||
= t('views.instructeurs.dossiers.follow_file')
|
||||
|
|
|
@ -174,14 +174,14 @@
|
|||
|
||||
%td.action-col.follow-col
|
||||
%ul.inline.fr-btns-group.fr-btns-group--sm.fr-btns-group--inline.fr-btns-group--icon-right
|
||||
= render partial: 'dossier_actions', locals: { procedure_id: @procedure.id,
|
||||
= render partial: 'instructeurs/procedures/dossier_actions', locals: { procedure_id: @procedure.id,
|
||||
dossier_id: p.dossier_id,
|
||||
state: p.state,
|
||||
archived: p.archived,
|
||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
|
||||
close_to_expiration: @statut == 'expirant',
|
||||
hidden_by_administration: @statut == 'supprimes_recemment',
|
||||
post_method: { method: :post } }
|
||||
turbo: false }
|
||||
%tfoot
|
||||
%tr
|
||||
%td.force-table-100{ colspan: @procedure_presentation.displayed_fields_for_headers.size + 2 }= paginate @filtered_sorted_paginated_ids
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
|
||||
close_to_expiration: nil,
|
||||
hidden_by_administration: nil,
|
||||
post_method: { method: :post } }
|
||||
turbo: false }
|
||||
|
||||
- else
|
||||
%td
|
||||
|
|
|
@ -61,7 +61,7 @@ describe 'Instructing a dossier:', js: true do
|
|||
end
|
||||
|
||||
expect(page).to have_text('Dossier traité avec succès.')
|
||||
expect(page).to have_link('Archiver le dossier')
|
||||
expect(page).to have_button('Archiver le dossier')
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
|
||||
|
@ -69,10 +69,10 @@ describe 'Instructing a dossier:', js: true do
|
|||
|
||||
click_on procedure.libelle
|
||||
click_on 'traité'
|
||||
expect(page).to have_link('Repasser en instruction')
|
||||
page.click_link('', title: 'Supprimer le dossier')
|
||||
expect(page).to have_button('Repasser en instruction')
|
||||
click_on 'Supprimer le dossier'
|
||||
click_on 'traité'
|
||||
expect(page).not_to have_link('Repasser en instruction')
|
||||
expect(page).not_to have_button('Repasser en instruction')
|
||||
end
|
||||
|
||||
scenario 'An instructeur can destroy a dossier from view' do
|
||||
|
@ -81,7 +81,7 @@ describe 'Instructing a dossier:', js: true do
|
|||
dossier.passer_en_instruction(instructeur: instructeur)
|
||||
dossier.accepter!(instructeur: instructeur)
|
||||
visit instructeur_dossier_path(procedure, dossier)
|
||||
page.click_link('', title: 'Supprimer le dossier')
|
||||
click_on 'Supprimer le dossier'
|
||||
end
|
||||
|
||||
scenario 'A instructeur can follow/unfollow a dossier' do
|
||||
|
|
|
@ -55,8 +55,12 @@ describe 'instructeurs/dossiers/show.html.haml', type: :view do
|
|||
context 'en_contruction' do
|
||||
let(:dossier) { create(:dossier, :en_construction) }
|
||||
it 'displays the correct actions' do
|
||||
expect(subject).to have_link('Passer en instruction', href: passer_en_instruction_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
expect(subject).to have_link('Suivre le dossier', href: follow_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
within("form[action=\"#{passer_en_instruction_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Passer en instruction')
|
||||
end
|
||||
within("form[action=\"#{follow_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Suivre le dossier')
|
||||
end
|
||||
expect(subject).to have_selector('.header-actions ul:first-child .fr-btn', count: 2)
|
||||
end
|
||||
end
|
||||
|
@ -70,10 +74,14 @@ describe 'instructeurs/dossiers/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
it 'displays the correct actions' do
|
||||
expect(subject).to have_link('Repasser en construction', href: repasser_en_construction_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
expect(subject).to have_link('Ne plus suivre', href: unfollow_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
within("form[action=\"#{repasser_en_construction_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Repasser en construction')
|
||||
end
|
||||
within("form[action=\"#{unfollow_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Ne plus suivre')
|
||||
end
|
||||
expect(subject).to have_button('Instruire le dossier')
|
||||
expect(subject).to have_selector('.header-actions ul:first-child > li a.fr-btn', count: 2)
|
||||
expect(subject).to have_selector('.header-actions ul:first-child > li .fr-btn', count: 15)
|
||||
expect(subject).to have_selector('.header-actions ul:first-child > li.instruction-button', count: 1)
|
||||
end
|
||||
end
|
||||
|
@ -82,8 +90,12 @@ describe 'instructeurs/dossiers/show.html.haml', type: :view do
|
|||
let(:dossier) { create(:dossier, :accepte) }
|
||||
|
||||
it 'displays the correct actions' do
|
||||
expect(subject).to have_link('Repasser en instruction', href: repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
expect(subject).to have_link('Archiver le dossier', href: archive_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
within("form[action=\"#{repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Repasser en instruction')
|
||||
end
|
||||
within("form[action=\"#{archive_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Archiver le dossier')
|
||||
end
|
||||
expect(subject).to have_selector('[title^="Supprimer le dossier"]')
|
||||
expect(subject).to have_selector('.header-actions ul:first-child .fr-btn', count: 3)
|
||||
end
|
||||
|
@ -98,7 +110,9 @@ describe 'instructeurs/dossiers/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
it 'displays the correct actions' do
|
||||
expect(subject).to have_link('Restaurer', href: restore_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
within("form[action=\"#{restore_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Restaurer')
|
||||
end
|
||||
expect(subject).to have_selector('.header-actions ul:first-child .fr-btn', count: 1)
|
||||
end
|
||||
end
|
||||
|
@ -109,7 +123,9 @@ describe 'instructeurs/dossiers/show.html.haml', type: :view do
|
|||
|
||||
it 'displays the correct actions' do
|
||||
expect(subject).to have_text('Conserver un mois de plus')
|
||||
expect(subject).to have_link('Repasser en instruction', href: repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
within("form[action=\"#{repasser_en_instruction_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Repasser en instruction')
|
||||
end
|
||||
expect(subject).to have_selector('.header-actions ul:first-child .fr-btn', count: 2)
|
||||
end
|
||||
end
|
||||
|
@ -118,7 +134,9 @@ describe 'instructeurs/dossiers/show.html.haml', type: :view do
|
|||
let(:dossier) { create(:dossier, :accepte, :archived) }
|
||||
|
||||
it 'displays the correct actions' do
|
||||
expect(subject).to have_link('Désarchiver le dossier', href: unarchive_instructeur_dossier_path(dossier.procedure, dossier))
|
||||
within("form[action=\"#{unarchive_instructeur_dossier_path(dossier.procedure, dossier)}\"]") do
|
||||
expect(subject).to have_button('Désarchiver le dossier')
|
||||
end
|
||||
expect(subject).to have_selector('[title^="Supprimer le dossier"]')
|
||||
expect(subject).to have_selector('.header-actions ul:first-child .fr-btn', count: 2)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue