From 10b15061b82f42aa3e905758024a8763b0348f83 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 31 Dec 2025 10:46:26 +0100 Subject: [PATCH] Fix action value rendering for text-type executors in rule form (#527) * Initial plan * Fix transaction name rule rendering and add tests Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> * Remove redundant integration tests for set_transaction_name The functionality is already covered by existing unit tests in test/models/rule/action_test.rb. The core fix for this PR is the view rendering logic, not the action functionality. Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> * Localize placeholder text for rule action value input Replace hardcoded "Enter a value" placeholder with localized t() lookup at lines 22 and 41 in app/views/rule/actions/_action.html.erb. Add corresponding translation key to config/locales/views/rules/en.yml under rules.actions.value_placeholder. Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> --- app/views/rule/actions/_action.html.erb | 13 ++++++++----- config/locales/views/rules/en.yml | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/views/rule/actions/_action.html.erb b/app/views/rule/actions/_action.html.erb index 0f3ebeac3..56fee76d3 100644 --- a/app/views/rule/actions/_action.html.erb +++ b/app/views/rule/actions/_action.html.erb @@ -11,13 +11,16 @@ <%= 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"), + <%= 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 rule.action_executors.first from the rule form. %> - <%# This is currently always SetTransactionCategory from transaction_resource.rb, which is a select type. %> + <%# Initial rendering based on the action executor type. %> <%# Subsequent renders are injected by the Stimulus controller, which uses the templates from below. %> to - <%= form.select :value, action.options || [], {} %> + <% 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 %> @@ -35,7 +38,7 @@ <%# The function type doesn't need an input, so no template is required.%> diff --git a/config/locales/views/rules/en.yml b/config/locales/views/rules/en.yml index c571eb0f6..2d258c411 100644 --- a/config/locales/views/rules/en.yml +++ b/config/locales/views/rules/en.yml @@ -2,6 +2,8 @@ en: rules: no_action: No Action + actions: + value_placeholder: Enter a value recent_runs: title: Recent Runs description: View the execution history of your rules including success/failure status and transaction counts.