mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-09 07:25:19 +02:00
Add back explicit show_prefixes to ensure subconditions never have a prefix
This commit is contained in:
parent
1058d17b36
commit
11626b4d0f
3 changed files with 12 additions and 8 deletions
|
@ -32,7 +32,7 @@ export default class extends Controller {
|
|||
this.element.remove();
|
||||
}
|
||||
|
||||
// Update the prefixes of all siblings from the parent rules controller
|
||||
// Update the prefixes of all conditions from the parent rules controller
|
||||
if (rulesEl) {
|
||||
const rulesController = this.application.getControllerForElementAndIdentifier(rulesEl, "rules");
|
||||
if (rulesController && typeof rulesController.updateConditionPrefixes === "function") {
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
<%# locals: (form:) %>
|
||||
<%# locals: (form:, show_prefix: true) %>
|
||||
|
||||
<% condition = form.object %>
|
||||
<% rule = condition.rule %>
|
||||
|
||||
<li data-controller="rule--conditions" data-rule--conditions-condition-filters-value="<%= rule.condition_filters.to_json %>" class="flex items-center gap-3">
|
||||
|
||||
<%# Show prefix on conditions, except the first one %>
|
||||
<div class="pl-2" data-condition-prefix>
|
||||
<span class="font-medium uppercase text-xs">and</span>
|
||||
</div>
|
||||
<%# Conditionally render the prefix %>
|
||||
<%# Condition groups pass in show_prefix: false for subconditions since the ANY/ALL selector makes that clear %>
|
||||
<% if show_prefix %>
|
||||
<div class="pl-2" data-condition-prefix>
|
||||
<span class="font-medium uppercase text-xs">and</span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="grow flex gap-2 items-center h-full">
|
||||
<%= form.hidden_field :_destroy, value: false, data: { rule__conditions_target: "destroyField" } %>
|
||||
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
<%# Sub-condition template, used by Stimulus controller to add new sub-conditions dynamically %>
|
||||
<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| %>
|
||||
<%= render "rule/conditions/condition", form: scf %>
|
||||
<%= render "rule/conditions/condition", form: scf, show_prefix: false %>
|
||||
<% end %>
|
||||
</template>
|
||||
|
||||
<ul data-rule--conditions-target="subConditionsList" class="space-y-3">
|
||||
<%= form.fields_for :sub_conditions do |scf| %>
|
||||
<%= render "rule/conditions/condition", form: scf %>
|
||||
<%= render "rule/conditions/condition", form: scf, show_prefix: false %>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue