refactor(dossier): champs_* -> project_champs_*
This commit is contained in:
parent
8fdf5cbe80
commit
ecbf985147
5 changed files with 5 additions and 12 deletions
|
@ -10,7 +10,6 @@ class Dossiers::ErrorsFullMessagesComponent < ApplicationComponent
|
|||
def dedup_and_partitioned_errors
|
||||
@dossier.errors.to_enum # ActiveModel::Errors.to_a is an alias to full_messages, we don't want that
|
||||
.to_a # but enum.to_a gives back an array
|
||||
.uniq { |error| [error.inner_error.base] } # dedup cumulated errors from dossier.champs, dossier.champs_public, dossier.champs_private which run the validator one time per association
|
||||
.map { |error| to_error_descriptor(error) }
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class DossierDashboard < Administrate::BaseDashboard
|
|||
en_construction_at: Field::DateTime,
|
||||
en_instruction_at: Field::DateTime,
|
||||
processed_at: Field::DateTime,
|
||||
champs_public: ChampCollectionField,
|
||||
project_champs_public: ChampCollectionField,
|
||||
groupe_instructeur: Field::BelongsTo
|
||||
}.freeze
|
||||
|
||||
|
@ -47,7 +47,7 @@ class DossierDashboard < Administrate::BaseDashboard
|
|||
:state,
|
||||
:procedure,
|
||||
:groupe_instructeur,
|
||||
:champs_public,
|
||||
:project_champs_public,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
:hidden_by_user_at,
|
||||
|
|
|
@ -49,8 +49,6 @@ class Dossier < ApplicationRecord
|
|||
# We have to remove champs in a particular order - champs with a reference to a parent have to be
|
||||
# removed first, otherwise we get a foreign key constraint error.
|
||||
has_many :champs_to_destroy, -> { order(:parent_id) }, class_name: 'Champ', inverse_of: false, dependent: :destroy
|
||||
has_many :champs_public, -> { root.public_only }, class_name: 'Champ', inverse_of: false
|
||||
has_many :champs_private, -> { root.private_only }, class_name: 'Champ', inverse_of: false
|
||||
|
||||
has_many :commentaires, inverse_of: :dossier, dependent: :destroy
|
||||
has_many :preloaded_commentaires, -> { includes(:dossier_correction, piece_jointe_attachments: :blob) }, class_name: 'Commentaire', inverse_of: :dossier
|
||||
|
@ -142,8 +140,6 @@ class Dossier < ApplicationRecord
|
|||
after_destroy_commit :log_destroy
|
||||
|
||||
accepts_nested_attributes_for :champs
|
||||
accepts_nested_attributes_for :champs_public
|
||||
accepts_nested_attributes_for :champs_private
|
||||
accepts_nested_attributes_for :individual
|
||||
|
||||
include AASM
|
||||
|
|
|
@ -39,7 +39,7 @@ class DossierPreloader
|
|||
|
||||
def revisions(pj_template: false)
|
||||
@revisions ||= ProcedureRevision.where(id: @dossiers.pluck(:revision_id).uniq)
|
||||
.includes(types_de_champ: pj_template ? { piece_justificative_template_attachment: :blob } : [])
|
||||
.includes(types_de_champ_public: [], types_de_champ_private: [], types_de_champ: pj_template ? { piece_justificative_template_attachment: :blob } : [])
|
||||
.index_by(&:id)
|
||||
end
|
||||
|
||||
|
@ -80,8 +80,6 @@ class DossierPreloader
|
|||
dossier.association(:revision).target = revision
|
||||
end
|
||||
dossier.association(:champs).target = champs
|
||||
dossier.association(:champs_public).target = dossier.project_champs_public
|
||||
dossier.association(:champs_private).target = dossier.project_champs_private
|
||||
|
||||
# remove once parent_id is deprecated
|
||||
champs_by_parent_id = champs.group_by(&:parent_id)
|
||||
|
|
|
@ -7,11 +7,11 @@ module Maintenance
|
|||
end
|
||||
|
||||
def process(cloned_dossier)
|
||||
cloned_dossier.champs_private
|
||||
cloned_dossier.project_champs_private
|
||||
.filter { checkable_pj?(_1, cloned_dossier) }
|
||||
.map do |cloned_champ|
|
||||
parent_champ = cloned_dossier.parent_dossier
|
||||
.champs_private
|
||||
.project_champs_private
|
||||
.find { _1.stable_id == cloned_champ.stable_id }
|
||||
|
||||
next if !parent_champ
|
||||
|
|
Loading…
Reference in a new issue