From 79552b496b4772785f7048520d40c4ddeaf49b52 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Thu, 16 Mar 2023 10:46:10 +0100 Subject: [PATCH] add 3rd view for expert - form to ask avis to another expert --- app/controllers/experts/avis_controller.rb | 6 +++++- app/views/experts/avis/_header.html.haml | 2 +- app/views/experts/avis/_sidemenu.html.haml | 9 +++++---- app/views/experts/avis/avis_new.html.haml | 11 +++++++++++ app/views/experts/avis/instruction.html.haml | 6 ------ config/routes.rb | 1 + 6 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 app/views/experts/avis/avis_new.html.haml diff --git a/app/controllers/experts/avis_controller.rb b/app/controllers/experts/avis_controller.rb index 117af4c94..2476eeeb4 100644 --- a/app/controllers/experts/avis_controller.rb +++ b/app/controllers/experts/avis_controller.rb @@ -6,7 +6,7 @@ module Experts before_action :authenticate_expert!, except: [:sign_up, :update_expert] before_action :check_if_avis_revoked, except: [:index, :procedure] before_action :redirect_if_no_sign_up_needed, only: [:sign_up, :update_expert] - before_action :set_avis_and_dossier, only: [:show, :instruction, :avis_list, :messagerie, :create_commentaire, :delete_commentaire, :update, :telecharger_pjs] + before_action :set_avis_and_dossier, only: [:show, :instruction, :avis_list, :avis_new, :messagerie, :create_commentaire, :delete_commentaire, :update, :telecharger_pjs] A_DONNER_STATUS = 'a-donner' DONNES_STATUS = 'donnes' @@ -59,6 +59,10 @@ module Experts def avis_list end + def avis_new + @new_avis = Avis.new + end + def create_avis @procedure = Procedure.find(params[:procedure_id]) @new_avis = create_avis_from_params(avis.dossier, current_expert, avis.confidentiel) diff --git a/app/views/experts/avis/_header.html.haml b/app/views/experts/avis/_header.html.haml index defdbb19e..fe88e32b2 100644 --- a/app/views/experts/avis/_header.html.haml +++ b/app/views/experts/avis/_header.html.haml @@ -18,5 +18,5 @@ %nav.tabs %ul = dynamic_tab_item('Demande', expert_avis_path(avis.procedure, avis)) - = dynamic_tab_item('Avis', [instruction_expert_avis_path(avis.procedure, avis), avis_list_expert_avis_path(avis.procedure, avis)], notification: avis.answer.blank?) + = dynamic_tab_item('Avis', [instruction_expert_avis_path(avis.procedure, avis), avis_list_expert_avis_path(avis.procedure, avis), avis_new_expert_avis_path(avis.procedure, avis)], notification: avis.answer.blank?) = dynamic_tab_item('Messagerie', messagerie_expert_avis_path(avis.procedure, avis)) diff --git a/app/views/experts/avis/_sidemenu.html.haml b/app/views/experts/avis/_sidemenu.html.haml index 2ca62d024..bb71ac11e 100644 --- a/app/views/experts/avis/_sidemenu.html.haml +++ b/app/views/experts/avis/_sidemenu.html.haml @@ -7,11 +7,12 @@ %li{class: "fr-sidemenu__item fr-sidemenu__item#{current_page ? '--active' : ''}"} %a.fr-sidemenu__link{'aria-current': current_page ? 'page' : nil, href: instruction_expert_avis_path(@avis.procedure, @avis), target: "_self"} Donner votre avis - - current_page = current_page?(avis_list_expert_avis_path(@avis.procedure, @avis)) - if @dossier.avis_for_expert(current_expert).present? + - current_page = current_page?(avis_list_expert_avis_path(@avis.procedure, @avis)) %li{class: "fr-sidemenu__item fr-sidemenu__item#{current_page ? '--active' : ''}"} %a.fr-sidemenu__link{'aria-current': current_page ? 'page' : nil,href: avis_list_expert_avis_path(@avis.procedure, @avis), target: "_self"} Voir les avis - -# - if !@dossier.termine? - -# %li.fr-sidemenu__item - -# %a.fr-sidemenu__link{href: "#", target: "_self"} Demander un nouvel avis + - if !@dossier.termine? + - current_page = current_page?(avis_new_expert_avis_path(@avis.procedure, @avis)) + %li{class: "fr-sidemenu__item fr-sidemenu__item#{current_page ? '--active' : ''}"} + %a.fr-sidemenu__link{'aria-current': current_page ? 'page' : nil,href: avis_new_expert_avis_path(@avis.procedure, @avis), target: "_self"} Demander un nouvel avis diff --git a/app/views/experts/avis/avis_new.html.haml b/app/views/experts/avis/avis_new.html.haml new file mode 100644 index 000000000..d5e29041c --- /dev/null +++ b/app/views/experts/avis/avis_new.html.haml @@ -0,0 +1,11 @@ +- content_for(:title, "Avis · Dossier nº #{@dossier.id} (#{@dossier.owner_name})") + += render partial: 'header', locals: { avis: @avis, dossier: @dossier } + +.container + .fr-grid-row + .fr-col.fr-col-12.fr-col-md-3 + = render partial: 'sidemenu' + .fr-col + - if !@dossier.termine? + = render partial: "experts/avis/shared/form", locals: { url: avis_expert_avis_path(@avis.procedure, @avis), linked_dossiers: @dossier.linked_dossiers_for(current_expert), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis } diff --git a/app/views/experts/avis/instruction.html.haml b/app/views/experts/avis/instruction.html.haml index 6fbe1251d..465d8441b 100644 --- a/app/views/experts/avis/instruction.html.haml +++ b/app/views/experts/avis/instruction.html.haml @@ -53,9 +53,3 @@ Cet avis est partagé avec les autres experts .send-wrapper = f.submit 'Envoyer votre avis', class: 'fr-btn' - - -# - if !@dossier.termine? - -# = render partial: "experts/avis/shared/form", locals: { url: avis_expert_avis_path(@avis.procedure, @avis), linked_dossiers: @dossier.linked_dossiers_for(current_expert), must_be_confidentiel: @avis.confidentiel?, avis: @new_avis } - - -# - if @dossier.avis_for_expert(current_expert).present? - -# = render partial: 'experts/avis/shared/list', locals: { avis: @dossier.avis_for_expert(current_expert), avis_seen_at: nil } diff --git a/config/routes.rb b/config/routes.rb index bc176c289..0dbed9948 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -356,6 +356,7 @@ Rails.application.routes.draw do member do get 'instruction' get 'avis_list' + get 'avis_new' get 'messagerie' post 'commentaire' => 'avis#create_commentaire' post 'avis' => 'avis#create_avis'