fix(ineligibilite_rules): cache bust champs.visible after checking for ineligibilite rules
Update app/models/dossier.rb Co-authored-by: Paul Chavard <github@paul.chavard.net>
This commit is contained in:
parent
8cbf4753ff
commit
9adb1bcf49
2 changed files with 16 additions and 3 deletions
|
@ -302,9 +302,10 @@ module Users
|
|||
def update
|
||||
@dossier = dossier.en_construction? ? dossier.find_editing_fork(dossier.user) : dossier
|
||||
@dossier = dossier_with_champs(pj_template: false)
|
||||
@can_passer_en_construction_was = @dossier.can_passer_en_construction?
|
||||
update_dossier_and_compute_errors
|
||||
@can_passer_en_construction_is = @dossier.can_passer_en_construction?
|
||||
@can_passer_en_construction_was, @can_passer_en_construction_is = @dossier.track_can_passer_en_construction do
|
||||
update_dossier_and_compute_errors
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.turbo_stream do
|
||||
@to_show, @to_hide, @to_update = champs_to_turbo_update(champs_public_attributes_params, dossier.champs.filter(&:public?))
|
||||
|
|
|
@ -1148,6 +1148,18 @@ class Dossier < ApplicationRecord
|
|||
procedure.accuse_lecture? && termine?
|
||||
end
|
||||
|
||||
def track_can_passer_en_construction
|
||||
if !revision.ineligibilite_enabled
|
||||
yield
|
||||
[true, true] # without eligibilite rules, we never reach dossier.champs.visible?, don't cache anything
|
||||
else
|
||||
from = can_passer_en_construction? # with eligibilite rules, self.champ[x].visible is cached by passing thru conditions checks
|
||||
yield
|
||||
champs.map(&:reset_visible) # we must reset self.champs[x].visible?, because an update occurred and we should re-evaluate champs[x] visibility
|
||||
[from, can_passer_en_construction?]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_missing_traitemets
|
||||
|
|
Loading…
Reference in a new issue