amelioration(usager.liste_des_dossier): ajout du bouton pour cloner un dossier
This commit is contained in:
parent
844004818a
commit
05dcf5e7cf
8 changed files with 57 additions and 4 deletions
|
@ -329,6 +329,15 @@ module Users
|
|||
redirect_to dossiers_path
|
||||
end
|
||||
|
||||
def clone
|
||||
cloned_dossier = @dossier.clone
|
||||
flash.notice = t('users.dossiers.cloned_success')
|
||||
redirect_to brouillon_dossier_path(cloned_dossier)
|
||||
rescue ActiveRecord::ActiveRecordError => e
|
||||
flash.alert = e.errors.full_messages
|
||||
redirect_to dossier_path(@dossier)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# if the status tab is filled, then this tab
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
%span.icon.archive
|
||||
.dropdown-description
|
||||
Archiver le dossier
|
||||
|
||||
%li.danger
|
||||
= link_to instructeur_dossier_path(procedure_id, dossier_id), method: :delete do
|
||||
%span.icon.delete
|
||||
|
|
|
@ -37,6 +37,11 @@
|
|||
%span.icon.new-folder
|
||||
.dropdown-description
|
||||
= t('views.users.dossiers.dossier_action.start_other_dossier')
|
||||
%li
|
||||
= link_to clone_dossier_path(dossier), method: :post do
|
||||
%span.icon.new-folder
|
||||
.dropdown-description
|
||||
= t('views.users.dossiers.dossier_action.clone')
|
||||
|
||||
- if has_delete_action
|
||||
%li.danger
|
||||
|
|
|
@ -249,7 +249,8 @@ en:
|
|||
actions: "Actions"
|
||||
dossier_action:
|
||||
edit_dossier: "Edit the file"
|
||||
start_other_dossier: "Start an other file"
|
||||
start_other_dossier: "Start an other empty file"
|
||||
clone: "Clone this file"
|
||||
delete_dossier: "Delete the file"
|
||||
transfer_dossier: "Transfer the file"
|
||||
edit_draft: "Edit the draft"
|
||||
|
@ -442,6 +443,7 @@ en:
|
|||
no_longer_editable: "Your file can no longer be edited"
|
||||
create_commentaire:
|
||||
message_send: "Your message has been sent to the instructor in charge of your file."
|
||||
cloned_success: "Your file has been duplicated. Please review it then you can submit it"
|
||||
ask_deletion:
|
||||
undergoingreview: "Your file is undergoing review. It is no longer possible to delete your file. To cancel the undergoingreview contact the adminitration via the mailbox."
|
||||
soft_deleted_dossier: "Your file has been successfully deleted from your interface"
|
||||
|
|
|
@ -245,7 +245,8 @@ fr:
|
|||
actions: "Actions"
|
||||
dossier_action:
|
||||
edit_dossier: "Modifier le dossier"
|
||||
start_other_dossier: "Commencer un autre dossier"
|
||||
start_other_dossier: "Commencer un autre dossier vide"
|
||||
clone: "Dupliquer ce dossier"
|
||||
delete_dossier: "Supprimer le dossier"
|
||||
transfer_dossier: "Transferer le dossier"
|
||||
edit_draft: "Modifier le brouillon"
|
||||
|
@ -450,9 +451,9 @@ fr:
|
|||
test_procedure: "Ce dossier est déposé sur une démarche en test. Toute modification de la démarche par l’administrateur (ajout d'un champ, publication de la démarche...) entraînera sa suppression."
|
||||
no_access: "Vous n’avez pas accès à ce dossier"
|
||||
no_longer_editable: "Votre dossier ne peut plus être modifié"
|
||||
|
||||
create_commentaire:
|
||||
message_send: "Votre message a bien été envoyé à l’instructeur en charge de votre dossier."
|
||||
cloned_success: "Votre dossier a bien été dupliqué. Vous pouvez maintenant le vérifier, l’adapter puis le déposer."
|
||||
ask_deletion:
|
||||
undergoingreview: "L’instruction de votre dossier a commencé, il n’est plus possible de supprimer votre dossier. Si vous souhaitez annuler l’instruction contactez votre administration par la messagerie de votre dossier."
|
||||
soft_deleted_dossier: "Votre dossier a bien été supprimé de votre interface"
|
||||
|
|
|
@ -275,6 +275,7 @@ Rails.application.routes.draw do
|
|||
member do
|
||||
get 'identite'
|
||||
patch 'update_identite'
|
||||
post 'clone'
|
||||
get 'siret'
|
||||
post 'siret', to: 'dossiers#update_siret'
|
||||
get 'etablissement'
|
||||
|
|
|
@ -1185,4 +1185,21 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#clone' do
|
||||
let(:procedure) { create(:procedure, :with_all_champs) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||
subject { post :clone, params: { id: dossier.id } }
|
||||
|
||||
context 'not signed in' do
|
||||
it { expect(subject).to redirect_to(new_user_session_path) }
|
||||
end
|
||||
|
||||
context 'signed with user dossier' do
|
||||
before { sign_in dossier.user }
|
||||
|
||||
it { expect(subject).to redirect_to(brouillon_dossier_path(Dossier.last)) }
|
||||
it { expect { subject }.to change { dossier.user.dossiers.count }.by(1) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,6 +80,25 @@ describe 'user access to the list of their dossiers', js: true do
|
|||
expect(page).not_to have_content(dossier_brouillon.procedure.libelle)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'clone' do
|
||||
it 'should have links to clone dossiers' do
|
||||
expect(page).to have_link(nil, href: clone_dossier_path(dossier_brouillon))
|
||||
expect(page).to have_link(nil, href: clone_dossier_path(dossier_en_construction))
|
||||
expect(page).to have_link(nil, href: clone_dossier_path(dossier_en_instruction))
|
||||
end
|
||||
|
||||
context 'when user clicks on clone button', js: true do
|
||||
scenario 'the dossier is deleted' do
|
||||
within(:css, "tr[data-dossier-id=\"#{dossier_brouillon.id}\"]") do
|
||||
click_on 'Actions'
|
||||
click_on 'Dupliquer ce dossier'
|
||||
end
|
||||
|
||||
expect(page).to have_content("Votre dossier a bien été dupliqué. Vous pouvez maintenant le vérifier, l’adapter puis le déposer.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "recherche" do
|
||||
|
|
Loading…
Reference in a new issue