mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-20 13:49:39 +02:00
Fix subconditions and condition group form (#2256)
This commit is contained in:
parent
e569ad0a8c
commit
1b4577e21e
2 changed files with 4 additions and 4 deletions
|
@ -13,7 +13,7 @@ export default class extends Controller {
|
||||||
|
|
||||||
addSubCondition() {
|
addSubCondition() {
|
||||||
const html = this.subConditionTemplateTarget.innerHTML.replaceAll(
|
const html = this.subConditionTemplateTarget.innerHTML.replaceAll(
|
||||||
"IDX_PLACEHOLDER",
|
"IDX_CHILD_PLACEHOLDER",
|
||||||
this.#uniqueKey(),
|
this.#uniqueKey(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -110,6 +110,6 @@ export default class extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
#uniqueKey() {
|
#uniqueKey() {
|
||||||
return Math.random().toString(36).substring(2, 15);
|
return Date.now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,13 @@
|
||||||
|
|
||||||
<%# Sub-condition template, used by Stimulus controller to add new sub-conditions dynamically %>
|
<%# Sub-condition template, used by Stimulus controller to add new sub-conditions dynamically %>
|
||||||
<template data-rule--conditions-target="subConditionTemplate">
|
<template data-rule--conditions-target="subConditionTemplate">
|
||||||
<%= form.fields_for :sub_conditions, Rule::Condition.new(parent: condition, condition_type: rule.condition_filters.first.key), child_index: "IDX_PLACEHOLDER" do |scf| %>
|
<%= form.fields_for :sub_conditions, Rule::Condition.new(parent: condition, condition_type: rule.condition_filters.first.key), child_index: "IDX_CHILD_PLACEHOLDER" do |scf| %>
|
||||||
<%= render "rule/conditions/condition", form: scf, show_prefix: false %>
|
<%= render "rule/conditions/condition", form: scf, show_prefix: false %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<ul data-rule--conditions-target="subConditionsList" class="space-y-3">
|
<ul data-rule--conditions-target="subConditionsList" class="space-y-3">
|
||||||
<%= form.fields_for :sub_conditions do |scf| %>
|
<%= form.fields_for :sub_conditions, condition.sub_conditions.select(&:persisted?) do |scf| %>
|
||||||
<%= render "rule/conditions/condition", form: scf, show_prefix: false %>
|
<%= render "rule/conditions/condition", form: scf, show_prefix: false %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue