User can choose its gi

This commit is contained in:
simon lehericey 2019-09-24 06:31:08 +02:00
parent 6b8cefa551
commit b7434c3132
2 changed files with 12 additions and 4 deletions

View file

@ -282,13 +282,14 @@ module Users
end
# FIXME: require(:dossier) when all the champs are united
def champs_params
params.permit(dossier: {
def champs_and_groupe_instructeurs_params
params.permit(dossier: [
:groupe_instructeur_id,
champs_attributes: [
:id, :value, :primary_value, :secondary_value, :piece_justificative_file, value: [],
champs_attributes: [:id, :_destroy, :value, :primary_value, :secondary_value, :piece_justificative_file, value: []]
]
})
])
end
def dossier
@ -302,7 +303,7 @@ module Users
def update_dossier_and_compute_errors
errors = []
if champs_params[:dossier] && !@dossier.update(champs_params[:dossier])
if champs_and_groupe_instructeurs_params[:dossier] && !@dossier.update(champs_and_groupe_instructeurs_params[:dossier])
errors += @dossier.errors.full_messages
end

View file

@ -26,6 +26,13 @@
%hr
- if dossier.procedure.routee?
= f.label :groupe_instructeur_id, dossier.procedure.routing_criteria_name
= f.select :groupe_instructeur_id,
dossier.procedure.groupe_instructeurs.order(:label).map { |gi| [gi.label, gi.id] },
{},
required: true
= f.fields_for :champs, dossier.champs do |champ_form|
- champ = champ_form.object
= render partial: "shared/dossiers/editable_champs/editable_champ",