fix(patron): when rendering “patron” champs should have dossier

This commit is contained in:
Paul Chavard 2022-07-28 11:47:55 +02:00
parent 31d80d80bd
commit 782af3322a
3 changed files with 10 additions and 4 deletions

View file

@ -75,6 +75,12 @@ class RootController < ApplicationController
end
@dossier = Dossier.new(champs: all_champs)
all_champs.each do |champ|
champ.association(:dossier).target = @dossier
champ.champs.each do |champ|
champ.association(:dossier).target = @dossier
end
end
end
def suivi

View file

@ -28,7 +28,7 @@ module ChampHelper
def autosave_available?(champ)
# FIXME: enable autosave on champs private? once we figured out how to batch audit events
champ.dossier&.brouillon? && !champ.repetition?
champ.dossier.brouillon? && !champ.repetition?
end
def editable_champ_controller(champ)
@ -39,10 +39,10 @@ module ChampHelper
# This is a public champ it can have an autosave controller.
if champ.public?
# This is a champ on dossier in draft state. Activate autosave.
if champ.dossier&.brouillon?
if champ.dossier.brouillon?
controllers << 'autosave'
# This is a champ on a dossier in en_construction state. Enable conditions checker.
elsif champ.public? && champ.dossier&.en_construction?
elsif champ.public? && champ.dossier.en_construction?
controllers << 'check-conditions'
end
end

View file

@ -89,7 +89,7 @@ class Champ < ApplicationRecord
end
def sections
@sections ||= dossier&.sections_for(self)
@sections ||= dossier.sections_for(self)
end
def mandatory_blank_and_visible?