dossiers: displays an "Start an other dossier" item in action dropdown
This commit is contained in:
parent
d03e340345
commit
abeb58caa5
3 changed files with 26 additions and 1 deletions
|
@ -123,6 +123,10 @@ class Procedure < ApplicationRecord
|
|||
publiee_ou_archivee?
|
||||
end
|
||||
|
||||
def accepts_new_dossiers?
|
||||
!archivee?
|
||||
end
|
||||
|
||||
# This method is needed for transition. Eventually this will be the same as brouillon?.
|
||||
def brouillon_avec_lien?
|
||||
brouillon? && path.present?
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
- has_delete_action = dossier.can_be_deleted_by_user?
|
||||
- has_actions = has_delete_action
|
||||
- has_new_dossier_action = dossier.procedure.expects_multiple_submissions? && dossier.procedure.accepts_new_dossiers?
|
||||
|
||||
- has_actions = has_delete_action || has_new_dossier_action
|
||||
|
||||
- if has_actions
|
||||
%span.dropdown.user-dossier-actions
|
||||
|
@ -7,6 +9,13 @@
|
|||
Actions
|
||||
.dropdown-content.fade-in-down
|
||||
%ul.dropdown-items
|
||||
- if has_new_dossier_action
|
||||
%li
|
||||
= link_to procedure_lien(dossier.procedure) do
|
||||
%span.icon.new-folder
|
||||
.dropdown-description
|
||||
Commencer un autre dossier
|
||||
|
||||
- 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
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'users/dossiers/dossier_actions.html.haml', type: :view do
|
|||
|
||||
subject { render 'users/dossiers/dossier_actions.html.haml', dossier: dossier }
|
||||
|
||||
it { is_expected.to have_link('Commencer un autre dossier', href: commencer_url(path: procedure.path)) }
|
||||
it { is_expected.to have_link('Supprimer le dossier', href: ask_deletion_dossier_path(dossier)) }
|
||||
|
||||
context 'when the dossier cannot be deleted' do
|
||||
|
@ -11,7 +12,18 @@ describe 'users/dossiers/dossier_actions.html.haml', type: :view do
|
|||
it { is_expected.not_to have_link('Supprimer le dossier') }
|
||||
end
|
||||
|
||||
context 'when the procedure doesn’t expect multiple submissions' do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: false) }
|
||||
it { is_expected.not_to have_link('Commencer un autre dossier') }
|
||||
end
|
||||
|
||||
context 'when the procedure is closed' do
|
||||
let(:procedure) { create(:procedure, :archived, expects_multiple_submissions: true) }
|
||||
it { is_expected.not_to have_link('Commencer un autre dossier') }
|
||||
end
|
||||
|
||||
context 'when there are no actions to display' do
|
||||
let(:procedure) { create(:procedure, :published, expects_multiple_submissions: false) }
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
it 'doesn’t render the menu at all' do
|
||||
|
|
Loading…
Reference in a new issue