use path instead of value_column in linked_drop_down
This commit is contained in:
parent
de8cad888e
commit
74e6834ce2
3 changed files with 13 additions and 10 deletions
|
@ -1,14 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Columns::LinkedDropDownColumn < Columns::ChampColumn
|
||||
def initialize(procedure_id:, label:, stable_id:, value_column:, displayable:, type: :text)
|
||||
attr_reader :path
|
||||
|
||||
def initialize(procedure_id:, label:, stable_id:, path:, displayable:, type: :text)
|
||||
@path = path
|
||||
|
||||
super(
|
||||
procedure_id:,
|
||||
label:,
|
||||
stable_id:,
|
||||
displayable:,
|
||||
type:,
|
||||
value_column:
|
||||
type:
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -21,7 +24,7 @@ class Columns::LinkedDropDownColumn < Columns::ChampColumn
|
|||
private
|
||||
|
||||
def column_id
|
||||
if value_column == :value
|
||||
if path == :value
|
||||
"type_de_champ/#{stable_id}"
|
||||
else
|
||||
"type_de_champ/#{stable_id}->#{path}"
|
||||
|
@ -29,10 +32,10 @@ class Columns::LinkedDropDownColumn < Columns::ChampColumn
|
|||
end
|
||||
|
||||
def typed_value(champ)
|
||||
return nil if default_column?
|
||||
return nil if path == :value
|
||||
|
||||
primary_value, secondary_value = unpack_values(champ.value)
|
||||
case value_column
|
||||
case path
|
||||
when :primary
|
||||
primary_value
|
||||
when :secondary
|
||||
|
|
|
@ -561,7 +561,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
elsif region?
|
||||
APIGeoService.regions.map { [_1[:name], _1[:code]] }
|
||||
elsif linked_drop_down_list?
|
||||
if column.value_column == :primary
|
||||
if column.path == :primary
|
||||
primary_options
|
||||
else
|
||||
secondary_options.values.flatten
|
||||
|
|
|
@ -78,7 +78,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
|||
label: libelle_with_prefix(prefix),
|
||||
stable_id: stable_id,
|
||||
type: :text,
|
||||
value_column: :value,
|
||||
path: :value,
|
||||
displayable:
|
||||
),
|
||||
Columns::LinkedDropDownColumn.new(
|
||||
|
@ -86,7 +86,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
|||
stable_id:,
|
||||
label: "#{libelle_with_prefix(prefix)} (Primaire)",
|
||||
type: :enum,
|
||||
value_column: :primary,
|
||||
path: :primary,
|
||||
displayable: false
|
||||
),
|
||||
Columns::LinkedDropDownColumn.new(
|
||||
|
@ -94,7 +94,7 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
|||
stable_id:,
|
||||
label: "#{libelle_with_prefix(prefix)} (Secondaire)",
|
||||
type: :enum,
|
||||
value_column: :secondary,
|
||||
path: :secondary,
|
||||
displayable: false
|
||||
)
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue