An admin should always have access to the service of it’s procedures
This commit is contained in:
parent
64abd8c712
commit
93ceb79dd1
3 changed files with 9 additions and 3 deletions
|
@ -81,13 +81,19 @@ module NewAdministrateur
|
||||||
end
|
end
|
||||||
|
|
||||||
def services
|
def services
|
||||||
current_administrateur.services
|
service_ids = current_administrateur.service_ids
|
||||||
|
service_ids << maybe_procedure&.service_id
|
||||||
|
Service.where(id: service_ids.compact.uniq)
|
||||||
end
|
end
|
||||||
|
|
||||||
def procedure_params
|
def procedure_params
|
||||||
params.require(:procedure).permit(:id, :service_id)
|
params.require(:procedure).permit(:id, :service_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def maybe_procedure
|
||||||
|
current_administrateur.procedures.find_by(id: params[:procedure_id])
|
||||||
|
end
|
||||||
|
|
||||||
def procedure
|
def procedure
|
||||||
current_administrateur.procedures.find(params[:procedure_id])
|
current_administrateur.procedures.find(params[:procedure_id])
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
.procedure-list-element{ class: ('active' if active == 'Description') }
|
.procedure-list-element{ class: ('active' if active == 'Description') }
|
||||||
Description
|
Description
|
||||||
|
|
||||||
%a#onglet-services{ href: current_administrateur.services.present? ? url_for(services_path(procedure_id: @procedure.id)) : url_for(new_service_path(procedure_id: @procedure.id)) }
|
%a#onglet-services{ href: (@procedure.service.present? || current_administrateur.services.present?) ? url_for(services_path(procedure_id: @procedure.id)) : url_for(new_service_path(procedure_id: @procedure.id)) }
|
||||||
.procedure-list-element
|
.procedure-list-element
|
||||||
Service
|
Service
|
||||||
- if @procedure.missing_steps.include?(:service)
|
- if @procedure.missing_steps.include?(:service)
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
= form_for @procedure, url: { controller: "new_administrateur/services", action: :add_to_procedure } , html: { class: 'form' } do |f|
|
= form_for @procedure, url: { controller: "new_administrateur/services", action: :add_to_procedure } , html: { class: 'form' } do |f|
|
||||||
= f.label :service_id, "La démarche #{@procedure.libelle} est affectée au service"
|
= f.label :service_id, "La démarche #{@procedure.libelle} est affectée au service"
|
||||||
= f.select :service_id,
|
= f.select :service_id,
|
||||||
current_administrateur.services.map { |s| [ s.nom, s.id ] },
|
@services.map { |s| [ s.nom, s.id ] },
|
||||||
{ prompt: 'choisir un service', selected: @procedure.service&.id },
|
{ prompt: 'choisir un service', selected: @procedure.service&.id },
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue