dossier: add an button to delete a brouillon

This commit is contained in:
Pierre de La Morinerie 2018-07-24 15:43:28 +00:00
parent 768537fedc
commit 0f1811dd4e
5 changed files with 38 additions and 1 deletions

View file

@ -45,6 +45,18 @@
}
}
&.danger {
color: $black;
border-color: $border-grey;
background-color: #FFFFFF;
&:hover {
color: #FFFFFF;
border-color: $medium-red;
background-color: $medium-red;
}
}
&.accepted {
color: #FFFFFF;
border-color: $green;

View file

@ -288,6 +288,9 @@
.button {
margin-bottom: 0;
}
.button.danger {
float:left;
}
}
.inline-champ {

View file

@ -49,6 +49,7 @@
= link_to ".button.secondary", "#", class: "button secondary"
= link_to ".button.danger", "#", class: "button danger"
= link_to "#", class: "button" do
%span.icon.follow

View file

@ -62,9 +62,16 @@
= hidden_field_tag 'submit_action', 'draft'
- if dossier.brouillon?
- if current_user.owns?(dossier)
= link_to ask_deletion_dossier_path(dossier),
method: :post,
class: 'button danger',
data: { confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations quil contient. Toute suppression entraine lannulation de la démarche en cours.\n\nConfirmer la suppression ?" } do
Supprimer le brouillon
= f.button 'Enregistrer le brouillon',
formnovalidate: true,
class: 'button send',
class: 'button send secondary',
data: { action: 'draft', disable_with: 'Envoi...' }
- if current_user.owns?(dossier) && dossier.can_transition_to_en_construction?

View file

@ -112,6 +112,20 @@ feature 'The user' do
expect(page).to have_current_path(merci_dossier_path(user_dossier))
end
scenario 'delete a draft', js: true do
log_in(user.email, password, simple_procedure)
fill_individual
page.accept_alert('Confirmer la suppression ?') do
click_on 'Supprimer le brouillon'
end
expect(page).to have_current_path(dossiers_path)
expect(page).to have_text('Votre dossier a bien été supprimé')
expect(page).not_to have_text(user_dossier.procedure.libelle)
expect(user_dossier.reload.hidden_at).to be_present
end
private
def log_in(email, password, procedure)