Admin can add new Accompagnateur directly on the procedure
This commit is contained in:
parent
4d1cb9ecfe
commit
92fc5af61c
5 changed files with 27 additions and 1 deletions
|
@ -19,6 +19,7 @@ class Admin::AccompagnateursController < AdminController
|
|||
partial: "admin/accompagnateurs/list_not_assign",
|
||||
array: true
|
||||
|
||||
@gestionnaire ||= Gestionnaire.new
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -13,6 +13,7 @@ class Admin::GestionnairesController < AdminController
|
|||
|
||||
def create
|
||||
@gestionnaire = Gestionnaire.find_by_email(params[:gestionnaire][:email])
|
||||
procedure_id = params[:procedure_id]
|
||||
|
||||
if @gestionnaire.nil?
|
||||
new_gestionnaire!
|
||||
|
@ -20,6 +21,7 @@ class Admin::GestionnairesController < AdminController
|
|||
assign_gestionnaire!
|
||||
end
|
||||
|
||||
return redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure_id) unless procedure_id.nil?
|
||||
redirect_to admin_gestionnaires_path
|
||||
end
|
||||
|
||||
|
|
|
@ -11,6 +11,19 @@
|
|||
%h3.text-info Disponibles
|
||||
= smart_listing_render :accompagnateurs_not_assign
|
||||
|
||||
%br
|
||||
%h3 Ajouter un accompagnateur
|
||||
#procedure_new.section.section-label
|
||||
= form_for @gestionnaire, url: {controller: 'admin/gestionnaires', action: :create} do |f|
|
||||
.row
|
||||
.col-md-5.col-lg-5
|
||||
= hidden_field_tag :procedure_id, params[:procedure_id]
|
||||
=render partial: 'admin/gestionnaires/informations', locals: {f: f}
|
||||
.col-md-2.col-lg-2
|
||||
%br
|
||||
%br
|
||||
=f.submit 'Valider', class: 'btn btn-info', style: 'float:left'
|
||||
|
||||
.col-md-6.col-lg-6
|
||||
%h3.text-success Affectés
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ describe Admin::GestionnairesController, type: :controller do
|
|||
|
||||
describe 'POST #create' do
|
||||
let(:email) { 'test@plop.com' }
|
||||
subject { post :create, gestionnaire: {email: email} }
|
||||
let(:procedure_id) { nil }
|
||||
subject { post :create, gestionnaire: {email: email}, procedure_id: procedure_id }
|
||||
|
||||
context 'When email is valid' do
|
||||
before do
|
||||
|
@ -28,6 +29,14 @@ describe Admin::GestionnairesController, type: :controller do
|
|||
it { expect(response.status).to eq(302) }
|
||||
it { expect(response).to redirect_to admin_gestionnaires_path }
|
||||
|
||||
context 'when procedure_id params is not null' do
|
||||
let(:procedure) { create :procedure }
|
||||
let(:procedure_id) { procedure.id }
|
||||
|
||||
it { expect(response.status).to eq(302) }
|
||||
it { expect(response).to redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure_id) }
|
||||
end
|
||||
|
||||
describe 'Gestionnaire attributs in database' do
|
||||
it { expect(gestionnaire.email).to eq(email) }
|
||||
end
|
||||
|
|
|
@ -9,6 +9,7 @@ describe 'admin/accompagnateurs/show.html.haml', type: :view do
|
|||
|
||||
before do
|
||||
assign(:procedure, procedure)
|
||||
assign(:gestionnaire, Gestionnaire.new)
|
||||
|
||||
assign(:accompagnateurs_assign, (smart_listing_create :accompagnateurs_assign,
|
||||
assign_gestionnaires,
|
||||
|
|
Loading…
Reference in a new issue