refactor(tdc): tdc.columns should take procedure instead of procedure_id
This commit is contained in:
parent
3ce36222b4
commit
c0da8d1556
9 changed files with 18 additions and 18 deletions
|
@ -4,7 +4,7 @@ module AddressableColumnConcern
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
included do
|
included do
|
||||||
def columns(procedure_id:, displayable: true, prefix: nil)
|
def columns(procedure:, displayable: true, prefix: nil)
|
||||||
super.concat([
|
super.concat([
|
||||||
["code postal (5 chiffres)", '$.postal_code', :text],
|
["code postal (5 chiffres)", '$.postal_code', :text],
|
||||||
["commune", '$.city_name', :text],
|
["commune", '$.city_name', :text],
|
||||||
|
@ -12,7 +12,7 @@ module AddressableColumnConcern
|
||||||
["region", '$.region_name', :enum]
|
["region", '$.region_name', :enum]
|
||||||
].map do |(label, jsonpath, type)|
|
].map do |(label, jsonpath, type)|
|
||||||
Columns::JSONPathColumn.new(
|
Columns::JSONPathColumn.new(
|
||||||
procedure_id:,
|
procedure_id: procedure.id,
|
||||||
stable_id:,
|
stable_id:,
|
||||||
tdc_type: type_champ,
|
tdc_type: type_champ,
|
||||||
label: "#{libelle_with_prefix(prefix)} – #{label}",
|
label: "#{libelle_with_prefix(prefix)} – #{label}",
|
||||||
|
|
|
@ -154,7 +154,7 @@ module ColumnsConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def types_de_champ_columns
|
def types_de_champ_columns
|
||||||
all_revisions_types_de_champ.flat_map { _1.columns(procedure_id: id) }
|
all_revisions_types_de_champ.flat_map { _1.columns(procedure: self) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ class TypesDeChamp::CarteTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
|
|
||||||
def champ_blank?(champ) = champ.geo_areas.blank?
|
def champ_blank?(champ) = champ.geo_areas.blank?
|
||||||
|
|
||||||
def columns(procedure_id:, displayable: true, prefix: nil)
|
def columns(procedure:, displayable: true, prefix: nil)
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,10 +71,10 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
(has_secondary_options_for_primary?(champ) && secondary_value(champ).blank?)
|
(has_secondary_options_for_primary?(champ) && secondary_value(champ).blank?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def columns(procedure_id:, displayable: true, prefix: nil)
|
def columns(procedure:, displayable: true, prefix: nil)
|
||||||
[
|
[
|
||||||
Columns::LinkedDropDownColumn.new(
|
Columns::LinkedDropDownColumn.new(
|
||||||
procedure_id:,
|
procedure_id: procedure.id,
|
||||||
label: libelle_with_prefix(prefix),
|
label: libelle_with_prefix(prefix),
|
||||||
stable_id:,
|
stable_id:,
|
||||||
tdc_type: type_champ,
|
tdc_type: type_champ,
|
||||||
|
@ -83,7 +83,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
displayable:
|
displayable:
|
||||||
),
|
),
|
||||||
Columns::LinkedDropDownColumn.new(
|
Columns::LinkedDropDownColumn.new(
|
||||||
procedure_id:,
|
procedure_id: procedure.id,
|
||||||
stable_id:,
|
stable_id:,
|
||||||
tdc_type: type_champ,
|
tdc_type: type_champ,
|
||||||
label: "#{libelle_with_prefix(prefix)} (Primaire)",
|
label: "#{libelle_with_prefix(prefix)} (Primaire)",
|
||||||
|
@ -92,7 +92,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
displayable: false
|
displayable: false
|
||||||
),
|
),
|
||||||
Columns::LinkedDropDownColumn.new(
|
Columns::LinkedDropDownColumn.new(
|
||||||
procedure_id:,
|
procedure_id: procedure.id,
|
||||||
stable_id:,
|
stable_id:,
|
||||||
tdc_type: type_champ,
|
tdc_type: type_champ,
|
||||||
label: "#{libelle_with_prefix(prefix)} (Secondaire)",
|
label: "#{libelle_with_prefix(prefix)} (Secondaire)",
|
||||||
|
|
|
@ -25,10 +25,10 @@ class TypesDeChamp::PieceJustificativeTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
|
|
||||||
def champ_blank?(champ) = champ.piece_justificative_file.blank?
|
def champ_blank?(champ) = champ.piece_justificative_file.blank?
|
||||||
|
|
||||||
def columns(procedure_id:, displayable: true, prefix: nil)
|
def columns(procedure:, displayable: true, prefix: nil)
|
||||||
[
|
[
|
||||||
Columns::AttachedManyColumn.new(
|
Columns::AttachedManyColumn.new(
|
||||||
procedure_id:,
|
procedure_id: procedure.id,
|
||||||
stable_id:,
|
stable_id:,
|
||||||
tdc_type: type_champ,
|
tdc_type: type_champ,
|
||||||
label: libelle_with_prefix(prefix),
|
label: libelle_with_prefix(prefix),
|
||||||
|
|
|
@ -25,10 +25,10 @@ class TypesDeChamp::RepetitionTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
ActiveStorage::Filename.new(str.delete('[]*?')).sanitized
|
ActiveStorage::Filename.new(str.delete('[]*?')).sanitized
|
||||||
end
|
end
|
||||||
|
|
||||||
def columns(procedure_id:, displayable: nil, prefix: nil)
|
def columns(procedure:, displayable: nil, prefix: nil)
|
||||||
@type_de_champ.procedure
|
procedure
|
||||||
.all_revisions_types_de_champ(parent: @type_de_champ)
|
.all_revisions_types_de_champ(parent: @type_de_champ)
|
||||||
.flat_map { _1.columns(procedure_id:, displayable: false, prefix: libelle) }
|
.flat_map { _1.columns(procedure:, displayable: false, prefix: libelle) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def champ_blank?(champ) = champ.dossier.repetition_row_ids(@type_de_champ).blank?
|
def champ_blank?(champ) = champ.dossier.repetition_row_ids(@type_de_champ).blank?
|
||||||
|
|
|
@ -24,10 +24,10 @@ class TypesDeChamp::TitreIdentiteTypeDeChamp < TypesDeChamp::TypeDeChampBase
|
||||||
|
|
||||||
def champ_blank?(champ) = champ.piece_justificative_file.blank?
|
def champ_blank?(champ) = champ.piece_justificative_file.blank?
|
||||||
|
|
||||||
def columns(procedure_id:, displayable: nil, prefix: nil)
|
def columns(procedure:, displayable: nil, prefix: nil)
|
||||||
[
|
[
|
||||||
Columns::AttachedManyColumn.new(
|
Columns::AttachedManyColumn.new(
|
||||||
procedure_id:,
|
procedure_id: procedure.id,
|
||||||
stable_id:,
|
stable_id:,
|
||||||
tdc_type: type_champ,
|
tdc_type: type_champ,
|
||||||
label: libelle_with_prefix(prefix),
|
label: libelle_with_prefix(prefix),
|
||||||
|
|
|
@ -95,11 +95,11 @@ class TypesDeChamp::TypeDeChampBase
|
||||||
def champ_blank?(champ) = champ.value.blank?
|
def champ_blank?(champ) = champ.value.blank?
|
||||||
def champ_blank_or_invalid?(champ) = champ_blank?(champ)
|
def champ_blank_or_invalid?(champ) = champ_blank?(champ)
|
||||||
|
|
||||||
def columns(procedure_id:, displayable: true, prefix: nil)
|
def columns(procedure:, displayable: true, prefix: nil)
|
||||||
if fillable?
|
if fillable?
|
||||||
[
|
[
|
||||||
Columns::ChampColumn.new(
|
Columns::ChampColumn.new(
|
||||||
procedure_id:,
|
procedure_id: procedure.id,
|
||||||
stable_id:,
|
stable_id:,
|
||||||
tdc_type: type_champ,
|
tdc_type: type_champ,
|
||||||
label: libelle_with_prefix(prefix),
|
label: libelle_with_prefix(prefix),
|
||||||
|
|
|
@ -122,7 +122,7 @@ describe Columns::ChampColumn do
|
||||||
def expect_type_de_champ_values(type, assertion)
|
def expect_type_de_champ_values(type, assertion)
|
||||||
type_de_champ = types_de_champ.find { _1.type_champ == type }
|
type_de_champ = types_de_champ.find { _1.type_champ == type }
|
||||||
champ = dossier.send(:filled_champ, type_de_champ, nil)
|
champ = dossier.send(:filled_champ, type_de_champ, nil)
|
||||||
columns = type_de_champ.columns(procedure_id: procedure.id)
|
columns = type_de_champ.columns(procedure:)
|
||||||
expect(columns.map { _1.value(champ) }).to assertion
|
expect(columns.map { _1.value(champ) }).to assertion
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue