dossiers: add an actions menu
This commit is contained in:
parent
dd4eae7d62
commit
d03e340345
10 changed files with 72 additions and 12 deletions
1
app/assets/images/icons/new-folder.svg
Normal file
1
app/assets/images/icons/new-folder.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><g fill="none" fill-rule="evenodd"><path d="M11 6L9 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-6" stroke="#0069cc" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M0 0h24v24H0z"/></g><g transform="translate(8 -8)" fill="#0069cc"><rect ry="1" y="12" x="6" height="2" width="10"/><rect width="2" height="10" x="10" y="8" ry="1"/></g></svg>
|
After Width: | Height: | Size: 446 B |
|
@ -221,6 +221,21 @@
|
|||
background: $light-grey;
|
||||
}
|
||||
|
||||
&.danger {
|
||||
&:hover {
|
||||
background-color: $medium-red;
|
||||
|
||||
&,
|
||||
a {
|
||||
color: $white;
|
||||
}
|
||||
|
||||
.icon {
|
||||
filter: contrast(0) brightness(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
|
|
@ -79,8 +79,4 @@
|
|||
.follow-col {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.delete-col {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
background-image: image-url("icons/folder.svg");
|
||||
}
|
||||
|
||||
&.new-folder {
|
||||
background-image: image-url("icons/new-folder.svg");
|
||||
}
|
||||
|
||||
&.accept {
|
||||
background-image: image-url("icons/accept.svg");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
.user-dossier-actions {
|
||||
.dropdown-description {
|
||||
font-size: 14px;
|
||||
align-self: center;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
%span.icon.archive
|
||||
%span.icon.unarchive
|
||||
%span.icon.folder
|
||||
%span.icon.new-folder
|
||||
%span.icon.accept
|
||||
%span.icon.refuse
|
||||
%span.icon.without-continuation
|
||||
|
|
15
app/views/users/dossiers/_dossier_actions.html.haml
Normal file
15
app/views/users/dossiers/_dossier_actions.html.haml
Normal file
|
@ -0,0 +1,15 @@
|
|||
- has_delete_action = dossier.can_be_deleted_by_user?
|
||||
- has_actions = has_delete_action
|
||||
|
||||
- if has_actions
|
||||
%span.dropdown.user-dossier-actions
|
||||
%button.button.dropdown-button
|
||||
Actions
|
||||
.dropdown-content.fade-in-down
|
||||
%ul.dropdown-items
|
||||
- if has_delete_action
|
||||
%li.danger
|
||||
= link_to ask_deletion_dossier_path(dossier), method: :post, data: { disable: true, confirm: "En continuant, vous allez supprimer ce dossier ainsi que les informations qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" } do
|
||||
%span.icon.delete
|
||||
.dropdown-description
|
||||
Supprimer le dossier
|
|
@ -32,7 +32,7 @@
|
|||
%th
|
||||
%tbody
|
||||
- @dossiers.each do |dossier|
|
||||
%tr
|
||||
%tr{ data: { 'dossier-id': dossier.id } }
|
||||
%td.folder-col
|
||||
= link_to(url_for_dossier(dossier), class: 'cell-link') do
|
||||
%span.icon.folder
|
||||
|
@ -48,11 +48,8 @@
|
|||
%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.can_be_deleted_by_user?
|
||||
= 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 qu’il contient. Toute suppression entraine l’annulation de la démarche en cours.\n\nConfirmer la suppression ?" }) do
|
||||
%span.icon.delete
|
||||
Supprimer
|
||||
%td.action-col.action-col
|
||||
= render partial: 'dossier_actions', locals: { dossier: dossier }
|
||||
= paginate(@dossiers)
|
||||
|
||||
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
||||
|
|
|
@ -71,11 +71,15 @@ describe 'user access to the list of their dossiers' do
|
|||
|
||||
context 'when user clicks on delete button', js: true do
|
||||
scenario 'the dossier is deleted' do
|
||||
page.accept_alert('Confirmer la suppression ?') do
|
||||
find(:xpath, "//a[@href='#{ask_deletion_dossier_path(dossier_brouillon)}']").click
|
||||
within(:css, "tr[data-dossier-id=\"#{dossier_brouillon.id}\"]") do
|
||||
click_on 'Actions'
|
||||
page.accept_alert('Confirmer la suppression ?') do
|
||||
click_on 'Supprimer le dossier'
|
||||
end
|
||||
end
|
||||
|
||||
expect(page).to have_content('Votre dossier a bien été supprimé.')
|
||||
expect(page).not_to have_content(dossier_brouillon.procedure.libelle)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
21
spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb
Normal file
21
spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
describe 'users/dossiers/dossier_actions.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: true) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
||||
subject { render 'users/dossiers/dossier_actions.html.haml', dossier: dossier }
|
||||
|
||||
it { is_expected.to have_link('Supprimer le dossier', href: ask_deletion_dossier_path(dossier)) }
|
||||
|
||||
context 'when the dossier cannot be deleted' do
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
it { is_expected.not_to have_link('Supprimer le dossier') }
|
||||
end
|
||||
|
||||
context 'when there are no actions to display' do
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
it 'doesn’t render the menu at all' do
|
||||
expect(subject).not_to have_selector('.dropdown')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue