-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9425 from demarches-simplifiees/9356-service-gi
ETQ Usager, je veux voir dans mon dossier les informations de contact de mon groupe instructeur
- Loading branch information
Showing
20 changed files
with
429 additions
and
5 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
app/controllers/instructeurs/contact_informations_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module Instructeurs | ||
class ContactInformationsController < InstructeurController | ||
def new | ||
assign_procedure_and_groupe_instructeur | ||
@contact_information = @groupe_instructeur.build_contact_information | ||
end | ||
|
||
def create | ||
assign_procedure_and_groupe_instructeur | ||
@contact_information = @groupe_instructeur.build_contact_information(contact_information_params) | ||
if @contact_information.save | ||
redirect_to_groupe_instructeur("Les informations de contact ont bien été ajoutées") | ||
else | ||
flash[:alert] = @contact_information.errors.full_messages | ||
render :new | ||
end | ||
end | ||
|
||
def edit | ||
assign_procedure_and_groupe_instructeur | ||
@contact_information = @groupe_instructeur.contact_information | ||
end | ||
|
||
def update | ||
assign_procedure_and_groupe_instructeur | ||
@contact_information = @groupe_instructeur.contact_information | ||
if @contact_information.update(contact_information_params) | ||
redirect_to_groupe_instructeur("Les informations de contact ont bien été modifiées") | ||
else | ||
flash[:alert] = @contact_information.errors.full_messages | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
assign_procedure_and_groupe_instructeur | ||
@groupe_instructeur.contact_information.destroy | ||
redirect_to_groupe_instructeur("Les informations de contact ont bien été supprimées") | ||
end | ||
|
||
private | ||
|
||
def redirect_to_groupe_instructeur(notice) | ||
if params[:from_admin] == "true" | ||
redirect_to admin_procedure_groupe_instructeur_path(@procedure, @groupe_instructeur), notice: notice | ||
else | ||
redirect_to instructeur_groupe_path(@procedure, @groupe_instructeur), notice: notice | ||
end | ||
end | ||
|
||
def assign_procedure_and_groupe_instructeur | ||
@procedure = current_instructeur.procedures.find params[:procedure_id] | ||
@groupe_instructeur = current_instructeur.groupe_instructeurs.find params[:groupe_id] | ||
end | ||
|
||
def contact_information_params | ||
params.require(:contact_information).permit(:nom, :email, :telephone, :horaires, :adresse) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class ContactInformation < ApplicationRecord | ||
belongs_to :groupe_instructeur | ||
|
||
validates :nom, presence: { message: 'doit être renseigné' }, allow_nil: false | ||
validates :nom, uniqueness: { scope: :groupe_instructeur, message: 'existe déjà' } | ||
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, presence: { message: 'doit être renseigné' }, allow_nil: false | ||
validates :telephone, phone: { possible: true, allow_blank: false } | ||
validates :horaires, presence: { message: 'doivent être renseignés' }, allow_nil: false | ||
validates :adresse, presence: { message: 'doit être renseignée' }, allow_nil: false | ||
validates :groupe_instructeur, presence: { message: 'doit être renseigné' }, allow_nil: false | ||
|
||
def telephone_url | ||
if telephone.present? | ||
"tel:#{telephone.gsub(/[[:blank:]]/, '')}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/views/administrateurs/groupe_instructeurs/_contact_information.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.card.mt-2 | ||
.card-title Informations de contact | ||
- service = groupe_instructeur.contact_information | ||
- if service.nil? | ||
= "Le groupe #{groupe_instructeur.label} n'a pas d'informations de contact. Les informations de contact affichées à l'usager seront celles du service de la procédure" | ||
%p.mt-3 | ||
- if groupe_instructeur.instructeurs.include?(current_administrateur.user.instructeur) | ||
= link_to "+ Ajouter des informations de contact", new_instructeur_groupe_contact_information_path(procedure_id: procedure.id, groupe_id: groupe_instructeur.id, from_admin: true), class: "fr-btn" | ||
- else | ||
Si vous souhaitez créer un service pour ce groupe, vous devez faire partie du groupe instructeur | ||
- else | ||
%p.mt-3 | ||
- if groupe_instructeur.instructeurs.include?(current_administrateur.user.instructeur) | ||
= link_to "Modifier les informations de contact", edit_instructeur_groupe_contact_information_path(procedure_id: procedure.id, groupe_id: groupe_instructeur.id, from_admin: true), class: "fr-btn" | ||
- else | ||
Si vous souhaitez modifier ce service, vous devez faire partie du groupe instructeur | ||
%p.mt-3= service.nom | ||
= render SimpleFormatComponent.new(service.adresse, class_names_map: {paragraph: 'fr-footer__content-desc'}) | ||
= service.email | ||
- if service.telephone.present? | ||
%p= service.telephone | ||
- if service.horaires.present? | ||
%p= service.horaires |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/views/instructeurs/contact_informations/_form.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
= form_with url: instructeur_groupe_contact_information_path, model: @contact_information, local: true do |f| | ||
= hidden_field_tag :from_admin, params[:from_admin] | ||
|
||
= render Dsfr::CalloutComponent.new(title: "Informations de contact") do |c| | ||
- c.body do | ||
Votre démarche est hébergée par #{APPLICATION_NAME} – mais nous ne pouvons pas assurer le support des démarches. Et malgré la dématérialisation, les usagers se posent parfois des questions légitimes sur le processus administratif. | ||
%br | ||
%br | ||
%strong Il est donc indispensable que les usagers puissent vous contacter | ||
par le moyen de leur choix s’ils ont des questions sur votre démarche. | ||
%br | ||
%br | ||
Ces informations de contact seront visibles par les utilisateurs de la démarche, affichées dans le menu « Aide », ainsi qu’en pied de page lors du dépôt d’un dossier. | ||
%br | ||
%br | ||
⚠️ En cas d’informations invalides, #{APPLICATION_NAME} se réserve le droit de suspendre la publication de la démarche. | ||
|
||
= render Dsfr::InputComponent.new(form: f, attribute: :nom, input_type: :text_field) do |c| | ||
- c.with_hint do | ||
Indiquez le nom à utiliser pour contacter le groupe instructeur | ||
(Exemple: Secrétariat de la Mairie) | ||
|
||
= render Dsfr::InputComponent.new(form: f, attribute: :email, input_type: :email_field) | ||
= render Dsfr::InputComponent.new(form: f, attribute: :telephone, input_type: :telephone_field) | ||
= render Dsfr::InputComponent.new(form: f, attribute: :horaires, input_type: :text_area) | ||
= render Dsfr::InputComponent.new(form: f, attribute: :adresse, input_type: :text_area) | ||
|
||
- if procedure_id.present? | ||
= hidden_field_tag :procedure_id, procedure_id | ||
|
||
.sticky-action-footer | ||
= f.submit "Enregistrer", class: "fr-btn fr-mr-2w" | ||
= link_to "Annuler", instructeur_groupe_path(@groupe_instructeur, procedure_id: procedure_id), class: "fr-btn fr-btn--secondary" | ||
- if [ "edit", "update"].include? params[:action] | ||
= link_to 'Supprimer', | ||
instructeur_groupe_contact_information_path(procedure_id: @procedure.id, groupe_id: @groupe_instructeur.id), | ||
method: :delete, | ||
data: { confirm: "Confirmez vous la suppression de ces informations de contact ?" }, | ||
class: 'fr-btn fr-btn--secondary' |
10 changes: 10 additions & 0 deletions
10
app/views/instructeurs/contact_informations/edit.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
= render partial: 'administrateurs/breadcrumbs', | ||
locals: { steps: [[@procedure.libelle.truncate_words(10), instructeur_procedure_path(@procedure)], | ||
['Groupes d’instructeurs', instructeur_groupes_path(@procedure)], | ||
[@groupe_instructeur.label, instructeur_groupe_path(@groupe_instructeur, procedure_id: @procedure.id) ], | ||
['Service']]} | ||
.container | ||
%h1 Modifier les informations de contact | ||
|
||
= render partial: 'form', | ||
locals: { contact_information: @contact_information, procedure_id: @procedure.id } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
= render partial: 'administrateurs/breadcrumbs', | ||
locals: { steps: [[@procedure.libelle.truncate_words(10), instructeur_procedure_path(@procedure)], | ||
['Groupes d’instructeurs', instructeur_groupes_path(@procedure)], | ||
[@groupe_instructeur.label, instructeur_groupe_path(@groupe_instructeur, procedure_id: @procedure.id) ], | ||
['Service']]} | ||
.container | ||
%h1 Informations de contact | ||
|
||
= render partial: 'form', | ||
locals: { contact_information: @contact_information, procedure_id: @procedure.id } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class CreateContactInformations < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :contact_informations do |t| | ||
t.belongs_to :groupe_instructeur, null: false, foreign_key: true | ||
t.text :adresse, null: false | ||
t.string :email, null: false | ||
t.text :horaires, null: false | ||
t.string :nom, null: false | ||
t.string :telephone, null: false | ||
|
||
t.timestamps | ||
end | ||
add_index :contact_informations, [:groupe_instructeur_id, :nom], unique: true, name: 'index_contact_informations_on_gi_and_nom' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.