Files
sure/app/views/rule/actions/_action.html.erb
Alessio Cappa ea0c70de8a fix: Fix layout UI issues for rule creation (#852)
* fix: Fix layout UI issues for rule creation

* Update app/views/rule/conditions/_condition.html.erb

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Alessio Cappa <104093777+alessiocappa@users.noreply.github.com>

* Update app/views/rule/actions/_action.html.erb

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Alessio Cappa <104093777+alessiocappa@users.noreply.github.com>

---------

Signed-off-by: Alessio Cappa <104093777+alessiocappa@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-01-31 18:22:54 +01:00

46 lines
2.0 KiB
Plaintext

<%# locals: (form:) %>
<% action = form.object %>
<% rule = action.rule %>
<li data-controller="rule--actions" data-rule--actions-action-executors-value="<%= rule.action_executors.to_json %>" class="flex items-center gap-3">
<%= form.hidden_field :_destroy, value: false, data: { rule__actions_target: "destroyField" } %>
<div class="grid grid-cols-1 gap-2 items-center h-full w-full">
<div class="grow">
<%= form.select :action_type, rule.action_executors.map { |executor| [ executor.label, executor.key ] }, {}, data: { action: "rule--actions#handleActionTypeChange" } %>
</div>
<%= tag.div class: class_names("min-w-1/2 flex items-center gap-2", { "hidden": action.executor.type == "function" }),
data: { rule__actions_target: "actionValue" } do %>
<%# Initial rendering based on the action executor type. %>
<%# Subsequent renders are injected by the Stimulus controller, which uses the templates from below. %>
<span class="font-medium text-primary uppercase text-xs">to</span>
<% if action.executor.type == "select" %>
<%= form.select :value, action.options || [], {} %>
<% elsif action.executor.type == "text" %>
<%= form.text_field :value, placeholder: t("rules.actions.value_placeholder") %>
<% end %>
<% end %>
</div>
<%= icon(
"trash-2",
size: "sm",
as_button: true,
data: { action: "rule--actions#remove", rule__actions_destroy_param: action.persisted? }) %>
<%# Templates for different input types - these will be cloned and used by the Stimulus controller %>
<template data-rule--actions-target="selectTemplate">
<span class="font-medium text-primary uppercase text-xs">to</span>
<%= form.select :value, [], {} %>
</template>
<template data-rule--actions-target="textTemplate">
<span class="font-medium text-primary uppercase text-xs">to</span>
<%= form.text_field :value, placeholder: t("rules.actions.value_placeholder") %>
</template>
<%# The function type doesn't need an input, so no template is required.%>
</li>