diff --git a/app/assets/images/icons/new-folder.svg b/app/assets/images/icons/new-folder.svg new file mode 100644 index 000000000..3eeb85f44 --- /dev/null +++ b/app/assets/images/icons/new-folder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index 0f84aff98..16dc43c7b 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -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; } diff --git a/app/assets/stylesheets/new_design/dossiers_table.scss b/app/assets/stylesheets/new_design/dossiers_table.scss index 1f3468039..5dab7fa66 100644 --- a/app/assets/stylesheets/new_design/dossiers_table.scss +++ b/app/assets/stylesheets/new_design/dossiers_table.scss @@ -79,8 +79,4 @@ .follow-col { width: 200px; } - - .delete-col { - width: 150px; - } } diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss index d5623b221..359641530 100644 --- a/app/assets/stylesheets/new_design/icons.scss +++ b/app/assets/stylesheets/new_design/icons.scss @@ -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"); } diff --git a/app/assets/stylesheets/new_design/user_dossier_actions.scss b/app/assets/stylesheets/new_design/user_dossier_actions.scss new file mode 100644 index 000000000..d0d074729 --- /dev/null +++ b/app/assets/stylesheets/new_design/user_dossier_actions.scss @@ -0,0 +1,6 @@ +.user-dossier-actions { + .dropdown-description { + font-size: 14px; + align-self: center; + } +} diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 06e7e45b1..892a010a0 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -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 diff --git a/app/views/users/dossiers/_dossier_actions.html.haml b/app/views/users/dossiers/_dossier_actions.html.haml new file mode 100644 index 000000000..a2fbea919 --- /dev/null +++ b/app/views/users/dossiers/_dossier_actions.html.haml @@ -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 diff --git a/app/views/users/dossiers/index.html.haml b/app/views/users/dossiers/index.html.haml index 42fa8bb30..8d49cd044 100644 --- a/app/views/users/dossiers/index.html.haml +++ b/app/views/users/dossiers/index.html.haml @@ -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 diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb index ac0aeb80c..ee0cf27e9 100644 --- a/spec/features/users/list_dossiers_spec.rb +++ b/spec/features/users/list_dossiers_spec.rb @@ -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 diff --git a/spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb b/spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb new file mode 100644 index 000000000..cf632d474 --- /dev/null +++ b/spec/views/users/dossiers/_dossier_actions.html.haml_spec.rb @@ -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