commit
6f1196e643
12 changed files with 138 additions and 11 deletions
|
@ -11,6 +11,7 @@
|
|||
background-color: #FFFFFF;
|
||||
color: $black;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
-webkit-appearance: none;
|
||||
|
||||
&:hover {
|
||||
|
@ -44,6 +45,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
&.danger {
|
||||
color: $black;
|
||||
border-color: $border-grey;
|
||||
background-color: #FFFFFF;
|
||||
|
||||
&:hover {
|
||||
color: #FFFFFF;
|
||||
border-color: $medium-red;
|
||||
background-color: $medium-red;
|
||||
}
|
||||
}
|
||||
|
||||
&.accepted {
|
||||
color: #FFFFFF;
|
||||
border-color: $green;
|
||||
|
|
|
@ -281,13 +281,44 @@
|
|||
}
|
||||
|
||||
.send-wrapper {
|
||||
text-align: right;
|
||||
margin-top: 2 * $default-padding;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
margin-top: $default-padding;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
|
||||
.button {
|
||||
margin-top: $default-padding;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
// Wide layout: align buttons on a single row
|
||||
@media (min-width: 550px) {
|
||||
flex-direction: row;
|
||||
|
||||
.button:not(:first-of-type) {
|
||||
margin-left: $default-spacer;
|
||||
}
|
||||
|
||||
.button.danger {
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
|
||||
// Narrow layout: stack buttons vertically
|
||||
@media (max-width: 550px) {
|
||||
flex-direction: column-reverse;
|
||||
align-items: center;
|
||||
|
||||
.button,
|
||||
.button.danger {
|
||||
width: 100%;
|
||||
max-width: 350px;
|
||||
line-height: 30px;
|
||||
margin-left: none;
|
||||
margin-right: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.inline-champ {
|
||||
|
|
|
@ -17,6 +17,7 @@ module NewAdministrateur
|
|||
redirect_to services_path(procedure_id: params[:procedure_id]),
|
||||
notice: "#{new_service.nom} créé"
|
||||
else
|
||||
@procedure = procedure
|
||||
flash[:alert] = new_service.errors.full_messages
|
||||
render :new
|
||||
end
|
||||
|
@ -34,6 +35,7 @@ module NewAdministrateur
|
|||
redirect_to services_path(procedure_id: params[:procedure_id]),
|
||||
notice: "#{@service.nom} modifié"
|
||||
else
|
||||
@procedure = procedure
|
||||
flash[:alert] = @service.errors.full_messages
|
||||
render :edit
|
||||
end
|
||||
|
|
|
@ -276,8 +276,12 @@ class Dossier < ApplicationRecord
|
|||
now = Time.now
|
||||
deleted_dossier = DeletedDossier.create!(dossier_id: id, procedure: procedure, state: state, deleted_at: now)
|
||||
update(hidden_at: now)
|
||||
|
||||
administration_emails = followers_gestionnaires.present? ? followers_gestionnaires.pluck(:email) : [procedure.administrateur.email]
|
||||
administration_emails.each do |email|
|
||||
DossierMailer.notify_deletion_to_administration(deleted_dossier, email).deliver_later
|
||||
end
|
||||
DossierMailer.notify_deletion_to_user(deleted_dossier, user.email).deliver_later
|
||||
DossierMailer.notify_deletion_to_administration(deleted_dossier, procedure.administrateur.email).deliver_later
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
- if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier))
|
||||
%a#maj_carte.action{ href: "/users/dossiers/#{@facade.dossier.id}/carte" }
|
||||
.col-lg-2.col-md-2.col-sm-2.col-xs-2.action
|
||||
= 'ÉDITER'
|
||||
= 'MODIFIER'
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
- if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier))
|
||||
= link_to modifier_dossier_path(@facade.dossier), class: 'action', id: 'maj_infos' do
|
||||
#edit-dossier.col-lg-2.col-md-2.col-sm-2.col-xs-2.action
|
||||
= "ÉDITER"
|
||||
= "MODIFIER"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
Bonne journée,
|
||||
|
||||
%p
|
||||
L'équipe demarches-simplifiees.fr (anciennement Téléprocédures Simplifiées)
|
||||
L'équipe demarches-simplifiees.fr
|
||||
|
||||
%p
|
||||
—
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
= link_to ".button.secondary", "#", class: "button secondary"
|
||||
|
||||
= link_to ".button.accepted", "#", class: "button accepted"
|
||||
= link_to ".button.danger", "#", class: "button danger"
|
||||
|
||||
= link_to "#", class: "button" do
|
||||
%span.icon.follow
|
||||
|
@ -58,6 +58,13 @@
|
|||
= link_to "#", class: "button icon-only" do
|
||||
%span.icon.follow
|
||||
|
||||
%p
|
||||
= link_to ".button.accepted", "#", class: "button accepted"
|
||||
|
||||
= link_to ".button.refused", "#", class: "button refused"
|
||||
|
||||
= link_to ".button.without-continuation", "#", class: "button without-continuation"
|
||||
|
||||
%p
|
||||
= link_to ".button.large", "#", class: "button large"
|
||||
|
||||
|
|
|
@ -62,9 +62,16 @@
|
|||
= hidden_field_tag 'submit_action', 'draft'
|
||||
|
||||
- if dossier.brouillon?
|
||||
- if current_user.owns?(dossier)
|
||||
= link_to ask_deletion_dossier_path(dossier),
|
||||
method: :post,
|
||||
class: 'button danger',
|
||||
data: { 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
|
||||
Supprimer le brouillon
|
||||
|
||||
= f.button 'Enregistrer le brouillon',
|
||||
formnovalidate: true,
|
||||
class: 'button send',
|
||||
class: 'button send secondary',
|
||||
data: { action: 'draft', disable_with: 'Envoi...' }
|
||||
|
||||
- if current_user.owns?(dossier) && dossier.can_transition_to_en_construction?
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
describe NewAdministrateur::ServicesController, type: :controller do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:procedure) { create(:procedure, administrateur: admin) }
|
||||
|
||||
describe '#create' do
|
||||
before do
|
||||
|
@ -38,7 +39,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when submitting an invalid service' do
|
||||
let(:params) { { service: { nom: 'super service' } } }
|
||||
let(:params) { { service: { nom: 'super service' }, procedure_id: procedure.id } }
|
||||
|
||||
it { expect(flash.alert).not_to be_nil }
|
||||
it { expect(response).to render_template(:new) }
|
||||
|
@ -54,7 +55,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
|||
params = {
|
||||
id: service.id,
|
||||
service: service_params,
|
||||
procedure_id: 12
|
||||
procedure_id: procedure.id
|
||||
}
|
||||
patch :update, params: params
|
||||
end
|
||||
|
@ -64,7 +65,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
|
|||
it { expect(flash.notice).to eq('nom modifié') }
|
||||
it { expect(Service.last.nom).to eq('nom') }
|
||||
it { expect(Service.last.type_organisme).to eq('region') }
|
||||
it { expect(response).to redirect_to(services_path(procedure_id: 12)) }
|
||||
it { expect(response).to redirect_to(services_path(procedure_id: procedure.id)) }
|
||||
end
|
||||
|
||||
context 'when updating a service with invalid data' do
|
||||
|
|
|
@ -112,6 +112,20 @@ feature 'The user' do
|
|||
expect(page).to have_current_path(merci_dossier_path(user_dossier))
|
||||
end
|
||||
|
||||
scenario 'delete a draft', js: true do
|
||||
log_in(user.email, password, simple_procedure)
|
||||
fill_individual
|
||||
|
||||
page.accept_alert('Confirmer la suppression ?') do
|
||||
click_on 'Supprimer le brouillon'
|
||||
end
|
||||
|
||||
expect(page).to have_current_path(dossiers_path)
|
||||
expect(page).to have_text('Votre dossier a bien été supprimé')
|
||||
expect(page).not_to have_text(user_dossier.procedure.libelle)
|
||||
expect(user_dossier.reload.hidden_at).to be_present
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log_in(email, password, procedure)
|
||||
|
|
|
@ -806,6 +806,54 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#delete_and_keep_track" do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:deleted_dossier) { DeletedDossier.find_by!(dossier_id: dossier.id) }
|
||||
|
||||
before do
|
||||
allow(DossierMailer).to receive(:notify_deletion_to_user).and_return(double(deliver_later: nil))
|
||||
allow(DossierMailer).to receive(:notify_deletion_to_administration).and_return(double(deliver_later: nil))
|
||||
end
|
||||
|
||||
subject! { dossier.delete_and_keep_track }
|
||||
|
||||
it 'hides the dossier' do
|
||||
expect(dossier.hidden_at).to be_present
|
||||
end
|
||||
|
||||
it 'creates a DeletedDossier record' do
|
||||
expect(deleted_dossier.dossier_id).to eq dossier.id
|
||||
expect(deleted_dossier.procedure).to eq dossier.procedure
|
||||
expect(deleted_dossier.state).to eq dossier.state
|
||||
expect(deleted_dossier.deleted_at).to be_present
|
||||
end
|
||||
|
||||
it 'notifies the user' do
|
||||
expect(DossierMailer).to have_received(:notify_deletion_to_user).with(deleted_dossier, dossier.user.email)
|
||||
end
|
||||
|
||||
context 'where gestionnaires are following the dossier' do
|
||||
let(:dossier) { create(:dossier, :followed) }
|
||||
let!(:non_following_gestionnaire) do
|
||||
non_following_gestionnaire = create(:gestionnaire)
|
||||
non_following_gestionnaire.procedures << dossier.procedure
|
||||
non_following_gestionnaire
|
||||
end
|
||||
|
||||
it 'notifies the following gestionnaires' do
|
||||
expect(DossierMailer).to have_received(:notify_deletion_to_administration).once
|
||||
expect(DossierMailer).to have_received(:notify_deletion_to_administration).with(deleted_dossier, dossier.followers_gestionnaires.first.email)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there are no following gestionnaires' do
|
||||
it 'notifies the procedure administrateur' do
|
||||
expect(DossierMailer).to have_received(:notify_deletion_to_administration).once
|
||||
expect(DossierMailer).to have_received(:notify_deletion_to_administration).with(deleted_dossier, dossier.procedure.administrateur.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'webhook' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue