mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #3735
This commit is contained in:
@@ -23,9 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Http\Controllers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\Support\Search\OperatorQuerySearch;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use Throwable;
|
||||
@@ -48,21 +48,21 @@ trait RuleManagement
|
||||
$data = [
|
||||
'rule_group_id' => $ruleRepository->getFirstRuleGroup()->id,
|
||||
'stop_processing' => 0,
|
||||
'title' => (string)trans('firefly.default_rule_name'),
|
||||
'description' => (string)trans('firefly.default_rule_description'),
|
||||
'title' => (string) trans('firefly.default_rule_name'),
|
||||
'description' => (string) trans('firefly.default_rule_description'),
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => true,
|
||||
'active' => true,
|
||||
'triggers' => [
|
||||
[
|
||||
'type' => 'description_is',
|
||||
'value' => (string)trans('firefly.default_rule_trigger_description'),
|
||||
'value' => (string) trans('firefly.default_rule_trigger_description'),
|
||||
'stop_processing' => false,
|
||||
|
||||
],
|
||||
[
|
||||
'type' => 'from_account_is',
|
||||
'value' => (string)trans('firefly.default_rule_trigger_from_account'),
|
||||
'value' => (string) trans('firefly.default_rule_trigger_from_account'),
|
||||
'stop_processing' => false,
|
||||
|
||||
],
|
||||
@@ -71,12 +71,12 @@ trait RuleManagement
|
||||
'actions' => [
|
||||
[
|
||||
'type' => 'prepend_description',
|
||||
'value' => (string)trans('firefly.default_rule_action_prepend'),
|
||||
'value' => (string) trans('firefly.default_rule_action_prepend'),
|
||||
'stop_processing' => false,
|
||||
],
|
||||
[
|
||||
'type' => 'set_category',
|
||||
'value' => (string)trans('firefly.default_rule_action_set_category'),
|
||||
'value' => (string) trans('firefly.default_rule_action_set_category'),
|
||||
'stop_processing' => false,
|
||||
],
|
||||
],
|
||||
@@ -105,7 +105,7 @@ trait RuleManagement
|
||||
[
|
||||
'oldAction' => $oldAction['type'],
|
||||
'oldValue' => $oldAction['value'],
|
||||
'oldChecked' => 1 === (int)($oldAction['stop_processing'] ?? '0'),
|
||||
'oldChecked' => 1 === (int) ($oldAction['stop_processing'] ?? '0'),
|
||||
'count' => $index + 1,
|
||||
]
|
||||
)->render();
|
||||
@@ -128,19 +128,31 @@ trait RuleManagement
|
||||
*/
|
||||
protected function getPreviousTriggers(Request $request): array
|
||||
{
|
||||
$index = 0;
|
||||
$triggers = [];
|
||||
$oldInput = $request->old('triggers');
|
||||
// TODO duplicated code.
|
||||
$operators = config('firefly.search.operators');
|
||||
$triggers = [];
|
||||
foreach ($operators as $key => $operator) {
|
||||
if ('user_action' !== $key && false === $operator['alias']) {
|
||||
|
||||
$triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));
|
||||
}
|
||||
}
|
||||
asort($triggers);
|
||||
|
||||
$index = 0;
|
||||
$renderedEntries = [];
|
||||
$oldInput = $request->old('triggers');
|
||||
if (is_array($oldInput)) {
|
||||
foreach ($oldInput as $oldTrigger) {
|
||||
try {
|
||||
$triggers[] = view(
|
||||
$renderedEntries[] = view(
|
||||
'rules.partials.trigger',
|
||||
[
|
||||
'oldTrigger' => $oldTrigger['type'],
|
||||
'oldTrigger' => OperatorQuerySearch::getRootOperator($oldTrigger['type']),
|
||||
'oldValue' => $oldTrigger['value'],
|
||||
'oldChecked' => 1 === (int)($oldTrigger['stop_processing'] ?? '0'),
|
||||
'oldChecked' => 1 === (int) ($oldTrigger['stop_processing'] ?? '0'),
|
||||
'count' => $index + 1,
|
||||
'triggers' => $triggers,
|
||||
]
|
||||
)->render();
|
||||
} catch (Throwable $e) {
|
||||
@@ -151,7 +163,7 @@ trait RuleManagement
|
||||
}
|
||||
}
|
||||
|
||||
return $triggers;
|
||||
return $renderedEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,8 +175,8 @@ trait RuleManagement
|
||||
$repository = app(RuleGroupRepositoryInterface::class);
|
||||
if (0 === $repository->count()) {
|
||||
$data = [
|
||||
'title' => (string)trans('firefly.default_rule_group_name'),
|
||||
'description' => (string)trans('firefly.default_rule_group_description'),
|
||||
'title' => (string) trans('firefly.default_rule_group_name'),
|
||||
'description' => (string) trans('firefly.default_rule_group_description'),
|
||||
'active' => true,
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user