From 11626b4d0ff333121cacce9a2ee59d80bf18ac14 Mon Sep 17 00:00:00 2001 From: hatz Date: Sat, 10 May 2025 12:59:46 -0500 Subject: [PATCH] Add back explicit show_prefixes to ensure subconditions never have a prefix --- .../controllers/rule/conditions_controller.js | 2 +- app/views/rule/conditions/_condition.html.erb | 14 +++++++++----- .../rule/conditions/_condition_group.html.erb | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/javascript/controllers/rule/conditions_controller.js b/app/javascript/controllers/rule/conditions_controller.js index c4717a5c..e2e08240 100644 --- a/app/javascript/controllers/rule/conditions_controller.js +++ b/app/javascript/controllers/rule/conditions_controller.js @@ -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") { diff --git a/app/views/rule/conditions/_condition.html.erb b/app/views/rule/conditions/_condition.html.erb index 5eae0fe7..60c38eab 100644 --- a/app/views/rule/conditions/_condition.html.erb +++ b/app/views/rule/conditions/_condition.html.erb @@ -1,14 +1,18 @@ -<%# locals: (form:) %> +<%# locals: (form:, show_prefix: true) %> <% condition = form.object %> <% rule = condition.rule %>
  • - <%# Show prefix on conditions, except the first one %> -
    - and -
    + <%# Conditionally render the prefix %> + <%# Condition groups pass in show_prefix: false for subconditions since the ANY/ALL selector makes that clear %> + <% if show_prefix %> +
    + and +
    + <% end %> +
    <%= form.hidden_field :_destroy, value: false, data: { rule__conditions_target: "destroyField" } %> diff --git a/app/views/rule/conditions/_condition_group.html.erb b/app/views/rule/conditions/_condition_group.html.erb index d691dacf..e04a09f7 100644 --- a/app/views/rule/conditions/_condition_group.html.erb +++ b/app/views/rule/conditions/_condition_group.html.erb @@ -29,13 +29,13 @@ <%# Sub-condition template, used by Stimulus controller to add new sub-conditions dynamically %>
      <%= form.fields_for :sub_conditions do |scf| %> - <%= render "rule/conditions/condition", form: scf %> + <%= render "rule/conditions/condition", form: scf, show_prefix: false %> <% end %>