refactor(routing): add id to option to help morph
This commit is contained in:
parent
e27e18fdaf
commit
9fe8f98a17
1 changed files with 8 additions and 3 deletions
|
@ -32,7 +32,10 @@ class Procedure::RoutingRulesComponent < ApplicationComponent
|
||||||
def value_tag(targeted_champ, value, row_index)
|
def value_tag(targeted_champ, value, row_index)
|
||||||
select_tag(
|
select_tag(
|
||||||
'value',
|
'value',
|
||||||
options_for_select(values_for_select(targeted_champ), selected: value.to_json),
|
options_for_select(
|
||||||
|
values_for_select(targeted_champ, row_index),
|
||||||
|
selected: value.to_json
|
||||||
|
),
|
||||||
id: input_id_for('value', row_index)
|
id: input_id_for('value', row_index)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -67,8 +70,10 @@ class Procedure::RoutingRulesComponent < ApplicationComponent
|
||||||
.map { |tdc| [tdc.first, constant(tdc.first).to_json] }
|
.map { |tdc| [tdc.first, constant(tdc.first).to_json] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def values_for_select(targeted_champ)
|
def values_for_select(targeted_champ, row_index)
|
||||||
empty_target_for_select + available_values_for_select(targeted_champ)
|
(empty_target_for_select + available_values_for_select(targeted_champ))
|
||||||
|
# add id to help morph render selected option
|
||||||
|
.map { |(libelle, json)| [libelle, json, { id: "#{row_index}-option-#{libelle}" }] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def input_id_for(name, row_index)
|
def input_id_for(name, row_index)
|
||||||
|
|
Loading…
Add table
Reference in a new issue