Merge pull request #4189 from betagouv/fix-dossier-actions-refresh

Rend le bouton "Archiver" visible dès la validation du dossier
This commit is contained in:
Nicolas Bouilleaud 2019-08-13 15:14:30 +02:00 committed by GitHub
commit 754f10e4b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 35 deletions

View file

@ -19,7 +19,7 @@
margin-bottom: 2 * $default-padding; margin-bottom: 2 * $default-padding;
} }
.mixed-buttons-bar { .header-actions {
flex-shrink: 0; flex-shrink: 0;
.button { .button {

View file

@ -9,30 +9,8 @@
= dossier.procedure.libelle.truncate_words(10) = dossier.procedure.libelle.truncate_words(10)
%li %li
= "Dossier nº #{dossier.id}" = "Dossier nº #{dossier.id}"
.mixed-buttons-bar .header-actions
%span.dropdown.print-menu-opener = render partial: 'instructeurs/dossiers/header_actions', locals: { dossier: dossier }
%button.button.dropdown-button.icon-only
%span.icon.printer
%ul.print-menu.dropdown-content
%li
= link_to "Tout le dossier", print_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
%li
= link_to "Uniquement cet onglet", "#", onclick: "window.print()", class: "menu-item menu-link"
- if Flipflop.download_as_zip_enabled? && !PiecesJustificativesService.liste_pieces_justificatives(dossier).empty?
%span.dropdown.print-menu-opener
%button.button.dropdown-button.icon-only
%span.icon.attachment
%ul.print-menu.dropdown-content
%li
- if PiecesJustificativesService.pieces_justificatives_total_size(dossier) < Dossier::TAILLE_MAX_ZIP
= link_to "Télécharger toutes les pièces jointes", telecharger_pjs_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
- else
%p.menu-item Le téléchargement des pièces jointes est désactivé pour les dossiers de plus de #{number_to_human_size Dossier::TAILLE_MAX_ZIP}.
= render partial: "instructeurs/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_instructeur&.follow?(dossier) }
%span.state-button
= render partial: "state_button", locals: { dossier: dossier }
%ul.tabs %ul.tabs
- notifications_summary = current_instructeur.notifications_for_dossier(dossier) - notifications_summary = current_instructeur.notifications_for_dossier(dossier)

View file

@ -0,0 +1,24 @@
%span.dropdown.print-menu-opener
%button.button.dropdown-button.icon-only
%span.icon.printer
%ul.print-menu.dropdown-content
%li
= link_to "Tout le dossier", print_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
%li
= link_to "Uniquement cet onglet", "#", onclick: "window.print()", class: "menu-item menu-link"
- if Flipflop.download_as_zip_enabled? && !PiecesJustificativesService.liste_pieces_justificatives(dossier).empty?
%span.dropdown.print-menu-opener
%button.button.dropdown-button.icon-only
%span.icon.attachment
%ul.print-menu.dropdown-content
%li
- if PiecesJustificativesService.pieces_justificatives_total_size(dossier) < Dossier::TAILLE_MAX_ZIP
= link_to "Télécharger toutes les pièces jointes", telecharger_pjs_instructeur_dossier_path(dossier.procedure, dossier), target: "_blank", rel: "noopener", class: "menu-item menu-link"
- else
%p.menu-item Le téléchargement des pièces jointes est désactivé pour les dossiers de plus de #{number_to_human_size Dossier::TAILLE_MAX_ZIP}.
= render partial: "instructeurs/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_instructeur&.follow?(dossier) }
%span.state-button
= render partial: "state_button", locals: { dossier: dossier }

View file

@ -1,5 +1,5 @@
<%= render_flash %> <%= render_flash %>
<%= render_to_element('.state-button', partial: "state_button", locals: { dossier: dossier }) %> <%= render_to_element('.header-actions', partial: 'header_actions', locals: { dossier: dossier }) %>
<% attachment = dossier.justificatif_motivation.attachment %> <% attachment = dossier.justificatif_motivation.attachment %>
<% if attachment && attachment.virus_scanner.pending? %> <% if attachment && attachment.virus_scanner.pending? %>

View file

@ -117,7 +117,7 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) } it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
it { expect(instructeur.follow?(dossier)).to be true } it { expect(instructeur.follow?(dossier)).to be true }
it { expect(response).to have_http_status(:ok) } it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.state-button') } it { expect(response.body).to include('.header-actions') }
context 'when the dossier has already been put en_instruction' do context 'when the dossier has already been put en_instruction' do
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) } let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
@ -141,7 +141,7 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) } it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) }
it { expect(response).to have_http_status(:ok) } it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.state-button') } it { expect(response.body).to include('.header-actions') }
context 'when the dossier has already been put en_construction' do context 'when the dossier has already been put en_construction' do
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) } let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
@ -166,7 +166,7 @@ describe Instructeurs::DossiersController, type: :controller do
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) } it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_instruction)) }
it { expect(response).to have_http_status(:ok) } it { expect(response).to have_http_status(:ok) }
it { expect(response.body).to include('.state-button') } it { expect(response.body).to include('.header-actions') }
context 'when the dossier has already been put en_instruction' do context 'when the dossier has already been put en_instruction' do
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) } let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
@ -239,7 +239,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached expect(dossier.justificatif_motivation).to be_attached
end end
it { expect(subject.body).to include('.state-button') } it { expect(subject.body).to include('.header-actions') }
end end
end end
@ -267,7 +267,7 @@ describe Instructeurs::DossiersController, type: :controller do
subject subject
end end
it { expect(subject.body).to include('.state-button') } it { expect(subject.body).to include('.header-actions') }
end end
context 'with attachment' do context 'with attachment' do
@ -281,7 +281,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached expect(dossier.justificatif_motivation).to be_attached
end end
it { expect(subject.body).to include('.state-button') } it { expect(subject.body).to include('.header-actions') }
end end
end end
@ -322,14 +322,14 @@ describe Instructeurs::DossiersController, type: :controller do
end end
it 'The instructeur is sent back to the dossier page' do it 'The instructeur is sent back to the dossier page' do
expect(subject.body).to include('.state-button') expect(subject.body).to include('.header-actions')
end end
context 'and the dossier has already an attestation' do context 'and the dossier has already an attestation' do
it 'should not crash' do it 'should not crash' do
dossier.attestation = Attestation.new dossier.attestation = Attestation.new
dossier.save dossier.save
expect(subject.body).to include('.state-button') expect(subject.body).to include('.header-actions')
end end
end end
end end
@ -372,7 +372,7 @@ describe Instructeurs::DossiersController, type: :controller do
expect(dossier.justificatif_motivation).to be_attached expect(dossier.justificatif_motivation).to be_attached
end end
it { expect(subject.body).to include('.state-button') } it { expect(subject.body).to include('.header-actions') }
end end
end end

View file

@ -67,6 +67,7 @@ feature 'The instructeur part' do
end end
expect(page).to have_text('Dossier traité avec succès.') expect(page).to have_text('Dossier traité avec succès.')
expect(page).to have_link('Archiver le dossier')
dossier.reload dossier.reload
expect(dossier.state).to eq(Dossier.states.fetch(:accepte)) expect(dossier.state).to eq(Dossier.states.fetch(:accepte))