Action button for construction state

This commit is contained in:
Mathieu Magnin 2017-08-02 16:20:01 +02:00
parent 792b498a59
commit 059a0b961b
6 changed files with 125 additions and 8 deletions

View file

@ -0,0 +1,11 @@
$(document).on("click", "body", function () {
$(".button.dropdown").removeClass("open");
});
$(document).on("click", ".button.dropdown", function(event) {
event.stopPropagation();
var $target = $(event.target);
if($target.hasClass("button", "dropdown")){
$target.toggleClass("open");
}
});

View file

@ -61,6 +61,84 @@
vertical-align: middle;
margin-right: $default-spacer;
}
&.dropdown {
position: relative;
&::after {
content: "";
margin-left: $default-spacer;
font-weight: bold;
}
.dropdown-content {
display: none;
}
&.open {
.dropdown-content {
display: block;
}
}
}
}
.dropdown-content {
border: 1px solid $border-grey;
background: #FFFFFF;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
position: absolute;
right: 0;
top: 5 * $default-spacer;
cursor: default;
}
.dropdown-items {
li {
display: flex;
padding: 2 * $default-spacer;
color: $grey;
border-bottom: 1px solid $border-grey;
font-size: 12px;
min-width: 300px;
cursor: pointer;
&.selected {
cursor: default;
h4 {
color: $blue;
}
}
&.selected,
&:hover {
background: $light-grey;
}
&:last-child {
border-bottom: none;
}
a {
display: flex;
color: $grey;
}
i {
flex-shrink: 0;
}
div {
padding-left: $default-spacer;
}
}
h4 {
font-size: 14px;
color: $black;
margin-bottom: $default-spacer;
}
}
.link {

View file

@ -99,9 +99,9 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
dossier.received!
current_gestionnaire.follow(dossier)
flash.notice = 'Dossier considéré comme reçu.'
flash.notice = 'Dossier passé en instruction.'
redirect_to backoffice_dossier_path(id: dossier.id)
redirect_to_dossier(dossier)
end
def process_dossier
@ -187,6 +187,14 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
private
def redirect_to_dossier(dossier)
if URI(request.referer).path == dossier_path(dossier.procedure, dossier)
redirect_to dossier_path(dossier.procedure, dossier)
else
redirect_to backoffice_dossier_path(id: dossier.id)
end
end
def check_attestation_emailable(dossier)
if dossier&.attestation&.emailable? == false
human_size = number_to_human_size(dossier.attestation.pdf.size)

View file

@ -1,10 +1,13 @@
.backoffice-header
.container
%ul.breadcrumbs
%li
= link_to dossier.procedure.libelle, procedure_path(dossier.procedure)
%li
= "Dossier n° #{dossier.id}"
.flex.justify-between
%ul.breadcrumbs
%li
= link_to dossier.procedure.libelle, procedure_path(dossier.procedure)
%li
= "Dossier nº #{dossier.id}"
%div
= render partial: "state_button", locals: { dossier: dossier }
%ul.tabs
- notifications_summary = dossier.notifications_summary
%li{ class: current_page?(dossier_path(dossier.procedure, dossier)) ? 'active' : nil }

View file

@ -0,0 +1,17 @@
- if dossier.en_construction?
%span.button.primary.dropdown
= dossier.decorate.display_state
.dropdown-content.fade-in-down
%ul.dropdown-items
- if dossier.en_construction?
%li.selected
%i.edit
.description
%h4 En construction
Vous permettez à l'usager de modifier ses réponses au formulaire
%li
= link_to backoffice_dossier_receive_path(dossier), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do
%i.in-progress
.description
%h4 Passer en instruction
L'usager ne pourra plus modifier le formulaire

View file

@ -367,7 +367,7 @@ describe Backoffice::DossiersController, type: :controller do
expect(dossier.state).to eq('replied')
end
it { is_expected.to redirect_to backoffice_dossiers_path }
it { is_expected.to redirect_to backoffice_dossier_path(id: dossier_id) }
end
describe 'POST #archive' do