diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index 3b15ca91f9..af99d30a9c 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -339,7 +339,11 @@ class RuleController extends Controller */ public function testTriggers() { // Create a list of triggers - $triggers = $this->getTriggerList(); + $triggers = $this->getValidTriggerList(); + + if(count($triggers) == 0) { + return Response::json(['html' => '', 'warning' => trans('firefly.warning_no_valid_triggers') ]); + } // We start searching for transactions. For performance reasons, there are limits // to the search: a maximum number of results and a maximum number of transactions @@ -370,10 +374,11 @@ class RuleController extends Controller } /** - * Returns a list of triggers as provided in the URL + * Returns a list of triggers as provided in the URL. + * Only returns triggers that will not match any transaction * @return array */ - protected function getTriggerList() { + protected function getValidTriggerList() { $triggers = []; $order = 1; $data = [ @@ -395,8 +400,10 @@ class RuleController extends Controller $ruleTrigger->trigger_value = $value; // Store in list - $triggers[] = $ruleTrigger; - $order++; + if( !$ruleTrigger->matchesAnything() ) { + $triggers[] = $ruleTrigger; + $order++; + } } return $triggers; diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index ab85aa5a6a..e9ed71aa0c 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -129,6 +129,7 @@ return [ 'test_rule_triggers' => 'See matching transactions', 'warning_transaction_subset' => 'For performance reasons this list is limited to :max_num_transactions and may only show a subset of matching transactions', 'warning_no_matching_transactions' => 'No matching transactions found. Please note that for performance reasons, only the last :num_transactions transactions have been checked.', + 'warning_no_valid_triggers' => 'No valid triggers provided.', // actions and triggers 'rule_trigger_user_action' => 'User action is ":trigger_value"', diff --git a/resources/lang/nl_NL/firefly.php b/resources/lang/nl_NL/firefly.php index b263512635..9288305e27 100644 --- a/resources/lang/nl_NL/firefly.php +++ b/resources/lang/nl_NL/firefly.php @@ -128,6 +128,7 @@ return [ 'test_rule_triggers' => 'Transacties die voldoen aan triggers', 'warning_transaction_subset' => 'In verband met de snelheid, worden in deze lijst maximaal :max_num_transactions transacties weergegeven. Het kan daarom zijn dat transacties ontbreken in deze lijst.', 'warning_no_matching_transactions' => 'Er zijn geen transacties gevonden die voldoen aan de triggers in de laatste :num_transactions transacties.', + 'warning_no_valid_triggers' => 'Geen geldige triggers opgegeven.', // actions and triggers 'rule_trigger_user_action' => 'Gebruikersactie is ":trigger_value"',