<%# locals: (form:) %> <% action = form.object %> <% rule = action.rule %>
  • <%= form.hidden_field :_destroy, value: false, data: { rule__actions_target: "destroyField" } %>
    <%= form.select :action_type, rule.action_executors.map { |executor| [ executor.label, executor.key ] }, {}, data: { action: "rule--actions#handleActionTypeChange" } %>
    <%= 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. %> to <% 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 %>
    <%= 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 %> <%# The function type doesn't need an input, so no template is required.%>