This commit is contained in:
James Cole
2025-10-27 10:00:16 +01:00
parent 9312ddbb7b
commit a4dff6d39f
7 changed files with 15 additions and 1 deletions

View File

@@ -268,7 +268,6 @@ class CreateController extends Controller
public function store(RuleFormRequest $request)
{
$data = $request->getRuleData();
$rule = $this->ruleRepos->store($data);
session()->flash('success_url', route('rules.select-transactions', [$rule->id]));
session()->flash('success', (string) trans('firefly.stored_new_rule', ['title' => $rule->title]));
@@ -283,6 +282,9 @@ class CreateController extends Controller
if ((int) $request->get('bill_id') > 0) {
return redirect($this->getPreviousUrl('bills.create.url'));
}
if(true === $data['run_after_form']) {
return redirect(route('rules.select-transactions', [$rule->id]));
}
$redirect = redirect($this->getPreviousUrl('rules.create.url'));

View File

@@ -205,6 +205,11 @@ class EditController extends Controller
session()->flash('success', (string) trans('firefly.updated_rule', ['title' => $rule->title]));
app('preferences')->mark();
$redirect = redirect($this->getPreviousUrl('rules.edit.url'));
if(true === $data['run_after_form']) {
return redirect(route('rules.select-transactions', [$rule->id]));
}
if (1 === (int) $request->get('return_to_edit')) {
session()->put('rules.edit.fromUpdate', true);

View File

@@ -54,6 +54,7 @@ class RuleFormRequest extends FormRequest
'description' => $this->stringWithNewlines('description'),
'stop_processing' => $this->boolean('stop_processing'),
'strict' => $this->boolean('strict'),
'run_after_form' => $this->boolean('run_after_form'),
'triggers' => $this->getRuleTriggerData(),
'actions' => $this->getRuleActionData(),
];
@@ -150,6 +151,7 @@ class RuleFormRequest extends FormRequest
'actions.*.type' => 'required|in:'.implode(',', $validActions),
'actions.*.value' => [sprintf('required_if:actions.*.type,%s|min:0|max:1024', $contextActions), new IsValidActionExpression(), 'ruleActionValue'],
'strict' => 'in:0,1',
'run_after_form' => 'in:0,1',
];
/** @var null|Rule $rule */

View File

@@ -825,6 +825,8 @@ return [
'apply_rule_group_selection' => 'Apply rule group ":title" to a selection of your transactions',
'apply_rule_group_selection_intro' => 'Rule groups like ":title" are normally only applied to new or updated transactions, but you can tell Firefly III to run all the rules in this group on a selection of your existing transactions. This can be useful when you have updated a group of rules and you need the changes to be applied to all of your other transactions.',
'applied_rule_group_selection' => 'Rule group ":title" has been applied to your selection.',
'rule_run_after_creation' => 'If you check this box, you get the opportunity to run the rule after it has been created.',
'rule_run_after_edit' => 'If you check this box, you get the opportunity to run the rule after it has been updated.',
// actions and triggers
'rule_trigger_store_journal' => 'When a transaction is created',

View File

@@ -66,6 +66,7 @@ return [
'opening_balance' => 'Opening balance',
'tag_mode' => 'Tag mode',
'virtual_balance' => 'Virtual balance',
'run_after_form' => 'Run this rule',

View File

@@ -132,6 +132,7 @@
<h3 class="box-title">{{ 'options'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.checkbox('run_after_form',1,null, {helpText: trans('firefly.rule_run_after_creation')}) }}
{{ ExpandedForm.optionsList('create','rule') }}
</div>
<div class="box-footer">

View File

@@ -118,6 +118,7 @@
<h3 class="box-title">{{ 'options'|_ }}</h3>
</div>
<div class="box-body">
{{ ExpandedForm.checkbox('run_after_form',1,null, {helpText: trans('firefly.rule_run_after_edit')}) }}
{{ ExpandedForm.optionsList('update','rule') }}
</div>
<div class="box-footer">