feat(dossier): add repetition champs to champs_for_condition
This commit is contained in:
parent
febffc2d64
commit
6ce7064ffd
3 changed files with 4 additions and 1 deletions
|
@ -237,7 +237,7 @@ class Champ < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def champs_for_condition
|
def champs_for_condition
|
||||||
private? ? dossier.champs_private : dossier.champs_public
|
dossier.champs.filter { _1.row.nil? || _1.row == row }
|
||||||
end
|
end
|
||||||
|
|
||||||
def html_id
|
def html_id
|
||||||
|
|
|
@ -78,6 +78,7 @@ class Dossier < ApplicationRecord
|
||||||
|
|
||||||
has_one_attached :justificatif_motivation
|
has_one_attached :justificatif_motivation
|
||||||
|
|
||||||
|
has_many :champs
|
||||||
has_many :champs_public, -> { root.public_ordered }, class_name: 'Champ', inverse_of: false, dependent: :destroy
|
has_many :champs_public, -> { root.public_ordered }, class_name: 'Champ', inverse_of: false, dependent: :destroy
|
||||||
has_many :champs_private, -> { root.private_ordered }, class_name: 'Champ', inverse_of: false, dependent: :destroy
|
has_many :champs_private, -> { root.private_ordered }, class_name: 'Champ', inverse_of: false, dependent: :destroy
|
||||||
has_many :commentaires, inverse_of: :dossier, dependent: :destroy
|
has_many :commentaires, inverse_of: :dossier, dependent: :destroy
|
||||||
|
|
|
@ -78,6 +78,7 @@ class DossierPreloader
|
||||||
def load_dossier(dossier, champs, children_by_parent = {})
|
def load_dossier(dossier, champs, children_by_parent = {})
|
||||||
champs_public, champs_private = champs.partition(&:public?)
|
champs_public, champs_private = champs.partition(&:public?)
|
||||||
|
|
||||||
|
dossier.association(:champs).target = []
|
||||||
load_champs(dossier, :champs_public, champs_public, dossier, children_by_parent)
|
load_champs(dossier, :champs_public, champs_public, dossier, children_by_parent)
|
||||||
load_champs(dossier, :champs_private, champs_private, dossier, children_by_parent)
|
load_champs(dossier, :champs_private, champs_private, dossier, children_by_parent)
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ class DossierPreloader
|
||||||
champ.association(:parent).target = parent
|
champ.association(:parent).target = parent
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
dossier.association(:champs).target += champs
|
||||||
|
|
||||||
parent.association(name).target = champs.sort_by do |champ|
|
parent.association(name).target = champs.sort_by do |champ|
|
||||||
[champ.row, positions[dossier.revision_id][champ.type_de_champ_id]]
|
[champ.row, positions[dossier.revision_id][champ.type_de_champ_id]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue