diff --git a/app/Helpers/Collector/Extensions/CollectorProperties.php b/app/Helpers/Collector/Extensions/CollectorProperties.php index 4735c40275..e89974c29e 100644 --- a/app/Helpers/Collector/Extensions/CollectorProperties.php +++ b/app/Helpers/Collector/Extensions/CollectorProperties.php @@ -49,6 +49,12 @@ trait CollectorProperties private array $postFilters; private HasMany $query; private array $stringFields; - private int $total; - private ?User $user; + /* + * This array is used to collect ALL tags the user may search for (using 'setTags'). + * This way the user can call 'setTags' multiple times and get a joined result. + * + */ + private array $tags; + private int $total; + private ?User $user; } diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php index 8671d21b16..a8217a4b0a 100644 --- a/app/Helpers/Collector/Extensions/MetaCollection.php +++ b/app/Helpers/Collector/Extensions/MetaCollection.php @@ -64,8 +64,8 @@ trait MetaCollection // join bill table $this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id'); // add fields - $this->fields[] = 'bills.id as bill_id'; - $this->fields[] = 'bills.name as bill_name'; + $this->fields[] = 'bills.id as bill_id'; + $this->fields[] = 'bills.name as bill_name'; $this->hasBillInformation = true; } @@ -104,8 +104,8 @@ trait MetaCollection // join cat table $this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id'); // add fields - $this->fields[] = 'budgets.id as budget_id'; - $this->fields[] = 'budgets.name as budget_name'; + $this->fields[] = 'budgets.id as budget_id'; + $this->fields[] = 'budgets.name as budget_name'; $this->hasBudgetInformation = true; } @@ -157,8 +157,8 @@ trait MetaCollection // join cat table $this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id'); // add fields - $this->fields[] = 'categories.id as category_id'; - $this->fields[] = 'categories.name as category_name'; + $this->fields[] = 'categories.id as category_id'; + $this->fields[] = 'categories.name as category_name'; $this->hasCatInformation = true; } @@ -603,7 +603,7 @@ trait MetaCollection } ); // add fields - $this->fields[] = 'notes.text as notes'; + $this->fields[] = 'notes.text as notes'; $this->hasNotesInformation = true; } @@ -896,7 +896,8 @@ trait MetaCollection public function setTags(Collection $tags): GroupCollectorInterface { $this->withTagInformation(); - $this->query->whereIn('tag_transaction_journal.tag_id', $tags->pluck('id')->toArray()); + $this->tags = array_merge($this->tags, $tags->pluck('id')->toArray()); + $this->query->whereIn('tag_transaction_journal.tag_id', $this->tags); return $this; } @@ -913,8 +914,8 @@ trait MetaCollection $this->withTagInformation(); // this method adds a "postFilter" to the collector. - $list = $tags->pluck('tag')->toArray(); - $filter = function (int $index, array $object) use ($list): bool { + $list = $tags->pluck('tag')->toArray(); + $filter = function (int $index, array $object) use ($list): bool { foreach ($object['transactions'] as $transaction) { foreach ($transaction['tags'] as $tag) { if (in_array($tag['name'], $list, true)) { diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php index e6753daa01..032f60453d 100644 --- a/app/Helpers/Collector/GroupCollector.php +++ b/app/Helpers/Collector/GroupCollector.php @@ -65,6 +65,7 @@ class GroupCollector implements GroupCollectorInterface public function __construct() { $this->postFilters = []; + $this->tags = []; $this->user = null; $this->limit = null; $this->page = null; diff --git a/app/Support/Form/RuleForm.php b/app/Support/Form/RuleForm.php index eec7f7e3f7..577f34dc6b 100644 --- a/app/Support/Form/RuleForm.php +++ b/app/Support/Form/RuleForm.php @@ -64,9 +64,9 @@ class RuleForm * @param null $value * @param array|null $options * - * @return HtmlString + * @return string */ - public function ruleGroupListWithEmpty(string $name, $value = null, array $options = null): HtmlString + public function ruleGroupListWithEmpty(string $name, $value = null, array $options = null): string { $options = $options ?? []; $options['class'] = 'form-control'; @@ -85,6 +85,6 @@ class RuleForm } } - return Form::select($name, $array, $value, $options); + return $this->select($name, $array, $value, $options); } } diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php index 829e4fb88a..aba89c31b7 100644 --- a/resources/lang/en_US/form.php +++ b/resources/lang/en_US/form.php @@ -127,6 +127,7 @@ return [ 'start_date' => 'Start of range', 'end_date' => 'End of range', 'enddate' => 'End date', + 'move_rules_before_delete' => 'Rule group', 'start' => 'Start of range', 'end' => 'End of range', 'delete_account' => 'Delete account ":name"',