[Fix #2423] Allow Usager to delete brouillon from dossiers#index

This commit is contained in:
Mathieu Magnin 2019-01-16 15:34:38 +01:00
parent 83bba82c76
commit b1efe57403
8 changed files with 44 additions and 6 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M6 18.857C6 20.037 6.749 21 7.667 21h8.666C17.25 21 18 20.037 18 18.857V6H6v12.857zM4 6h16M9 11v5m3-5v5m3-5v5M8.5 4.889c0-.858.696-1.89 1.556-1.89h3.888c.86 0 1.556 1.032 1.556 1.89" stroke="#4393F3" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/><path d="M0 0h24v24H0z"/></g></svg>

After

Width:  |  Height:  |  Size: 427 B

View file

@ -60,6 +60,10 @@
color: #FFFFFF;
border-color: $medium-red;
background-color: $medium-red;
> .icon {
filter: brightness(100);
}
}
}

View file

@ -70,10 +70,17 @@
width: 110px;
}
.follow-col {
width: 200px;
.action-col {
text-align: right;
padding-left: $default-spacer;
padding-right: $default-spacer;
}
.follow-col {
width: 200px;
}
.delete-col {
width: 150px;
}
}

View file

@ -105,4 +105,8 @@
&.meh {
background-image: image-url("icons/meh-regular.svg");
}
&.delete {
background-image: image-url("icons/trash.svg");
}
}

View file

@ -77,7 +77,7 @@
= render partial: "header_field", locals: { field: { "label" => "Statut", "table" => "self", "column" => "state" }, classname: "status-col" }
%th.follow-col
%th.action-col.follow-col
%span.dropdown
%button.button.dropdown-button
Personnaliser
@ -112,7 +112,7 @@
%td.status-col
= link_to(gestionnaire_dossier_path(@procedure, dossier), class: 'cell-link') do
= render partial: 'shared/dossiers/status_badge', locals: { dossier: dossier }
%td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) }
%td.action-col.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) }
= paginate @dossiers
- else
%h2.empty-text Aucun dossier

View file

@ -14,7 +14,7 @@
%th Démarche
%th Demandeur
%th.status-col Statut
%th.follow-col
%th.action-col.follow-col
%tbody
- @dossiers.each do |dossier|
/ # FIXME: here we have a n+1, we fire a request
@ -31,6 +31,6 @@
%td.status-col
= link_to(dossier_linked_path(current_gestionnaire, dossier), class: 'cell-link') do
= render partial: 'shared/dossiers/status_badge', locals: { dossier: dossier }
%td.follow-col= render partial: 'new_gestionnaire/procedures/dossier_actions', locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) }
%td.action-col.follow-col= render partial: 'new_gestionnaire/procedures/dossier_actions', locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) }
- else
%h2 Aucun dossier correspondant à votre recherche n'a été trouvé

View file

@ -31,6 +31,7 @@
%th Démarche
%th.status-col Statut
%th.updated-at-col Mis à jour
%th
%tbody
- @dossiers.each do |dossier|
%tr
@ -49,6 +50,11 @@
%td.updated-at-col
= link_to(url_for_dossier(dossier), class: 'cell-link') do
= dossier.updated_at.strftime("%d/%m/%Y")
%td.action-col.delete-col
- if dossier.brouillon?
= link_to(ask_deletion_dossier_path(dossier), method: :post, class: 'button danger', data: { disable: true, 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
%span.icon.delete
Supprimer
= paginate(@dossiers)
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago

View file

@ -5,6 +5,7 @@ describe 'user access to the list of his dossier' do
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
let!(:dossier2) { create(:dossier, :with_entreprise) }
let!(:dossier_brouillon) { create(:dossier, :with_entreprise, user: user) }
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
let(:dossiers_per_page) { 25 }
@ -43,6 +44,21 @@ describe 'user access to the list of his dossier' do
expect(page).to have_content(dossier_archived.procedure.libelle)
end
it 'should have link to only delete brouillon' do
expect(page).to have_link(nil, href: ask_deletion_dossier_path(dossier_brouillon))
expect(page).not_to have_link(nil, href: ask_deletion_dossier_path(dossier1))
end
context 'when user clicks on delete brouillon list', js: true do
before do
find(:xpath, "//a[@href='#{ask_deletion_dossier_path(dossier_brouillon)}']").click
page.driver.browser.switch_to.alert.accept
end
scenario 'dossier is deleted' do
expect(page).not_to have_link("Supprimer", href: dossier_brouillon.procedure.libelle)
end
end
context 'when user clicks on a projet in list', js: true do
before do
page.click_on(dossier1.procedure.libelle)