2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-03-27 11:37:30 +01:00
|
|
|
class Champs::ChampController < ApplicationController
|
|
|
|
before_action :authenticate_logged_user!
|
|
|
|
before_action :set_champ
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def find_champ
|
2024-03-28 12:42:29 +01:00
|
|
|
dossier = policy_scope(Dossier).includes(:champs, revision: [:types_de_champ]).find(params[:dossier_id])
|
|
|
|
type_de_champ = dossier.find_type_de_champ_by_stable_id(params[:stable_id])
|
2024-08-22 17:35:40 +02:00
|
|
|
if type_de_champ.repetition?
|
|
|
|
dossier.project_champ(type_de_champ, nil)
|
|
|
|
else
|
|
|
|
dossier.champ_for_update(type_de_champ, params_row_id, updated_by: current_user.email)
|
|
|
|
end
|
2024-03-27 11:37:30 +01:00
|
|
|
end
|
|
|
|
|
2024-04-15 15:06:05 +02:00
|
|
|
def params_row_id
|
|
|
|
params[:row_id]
|
|
|
|
end
|
|
|
|
|
2024-03-27 11:37:30 +01:00
|
|
|
def set_champ
|
|
|
|
@champ = find_champ
|
|
|
|
end
|
|
|
|
end
|