This commit is contained in:
James Cole
2023-07-29 06:52:21 +02:00
parent 1a1b0ee27d
commit fe4e00dc5c
5 changed files with 24 additions and 15 deletions

View File

@@ -49,6 +49,12 @@ trait CollectorProperties
private array $postFilters; private array $postFilters;
private HasMany $query; private HasMany $query;
private array $stringFields; 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;
} }

View File

@@ -64,8 +64,8 @@ trait MetaCollection
// join bill table // join bill table
$this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id'); $this->query->leftJoin('bills', 'bills.id', '=', 'transaction_journals.bill_id');
// add fields // add fields
$this->fields[] = 'bills.id as bill_id'; $this->fields[] = 'bills.id as bill_id';
$this->fields[] = 'bills.name as bill_name'; $this->fields[] = 'bills.name as bill_name';
$this->hasBillInformation = true; $this->hasBillInformation = true;
} }
@@ -104,8 +104,8 @@ trait MetaCollection
// join cat table // join cat table
$this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id'); $this->query->leftJoin('budgets', 'budget_transaction_journal.budget_id', '=', 'budgets.id');
// add fields // add fields
$this->fields[] = 'budgets.id as budget_id'; $this->fields[] = 'budgets.id as budget_id';
$this->fields[] = 'budgets.name as budget_name'; $this->fields[] = 'budgets.name as budget_name';
$this->hasBudgetInformation = true; $this->hasBudgetInformation = true;
} }
@@ -157,8 +157,8 @@ trait MetaCollection
// join cat table // join cat table
$this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id'); $this->query->leftJoin('categories', 'category_transaction_journal.category_id', '=', 'categories.id');
// add fields // add fields
$this->fields[] = 'categories.id as category_id'; $this->fields[] = 'categories.id as category_id';
$this->fields[] = 'categories.name as category_name'; $this->fields[] = 'categories.name as category_name';
$this->hasCatInformation = true; $this->hasCatInformation = true;
} }
@@ -603,7 +603,7 @@ trait MetaCollection
} }
); );
// add fields // add fields
$this->fields[] = 'notes.text as notes'; $this->fields[] = 'notes.text as notes';
$this->hasNotesInformation = true; $this->hasNotesInformation = true;
} }
@@ -896,7 +896,8 @@ trait MetaCollection
public function setTags(Collection $tags): GroupCollectorInterface public function setTags(Collection $tags): GroupCollectorInterface
{ {
$this->withTagInformation(); $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; return $this;
} }
@@ -913,8 +914,8 @@ trait MetaCollection
$this->withTagInformation(); $this->withTagInformation();
// this method adds a "postFilter" to the collector. // this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray(); $list = $tags->pluck('tag')->toArray();
$filter = function (int $index, array $object) use ($list): bool { $filter = function (int $index, array $object) use ($list): bool {
foreach ($object['transactions'] as $transaction) { foreach ($object['transactions'] as $transaction) {
foreach ($transaction['tags'] as $tag) { foreach ($transaction['tags'] as $tag) {
if (in_array($tag['name'], $list, true)) { if (in_array($tag['name'], $list, true)) {

View File

@@ -65,6 +65,7 @@ class GroupCollector implements GroupCollectorInterface
public function __construct() public function __construct()
{ {
$this->postFilters = []; $this->postFilters = [];
$this->tags = [];
$this->user = null; $this->user = null;
$this->limit = null; $this->limit = null;
$this->page = null; $this->page = null;

View File

@@ -64,9 +64,9 @@ class RuleForm
* @param null $value * @param null $value
* @param array|null $options * @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 = $options ?? [];
$options['class'] = 'form-control'; $options['class'] = 'form-control';
@@ -85,6 +85,6 @@ class RuleForm
} }
} }
return Form::select($name, $array, $value, $options); return $this->select($name, $array, $value, $options);
} }
} }

View File

@@ -127,6 +127,7 @@ return [
'start_date' => 'Start of range', 'start_date' => 'Start of range',
'end_date' => 'End of range', 'end_date' => 'End of range',
'enddate' => 'End date', 'enddate' => 'End date',
'move_rules_before_delete' => 'Rule group',
'start' => 'Start of range', 'start' => 'Start of range',
'end' => 'End of range', 'end' => 'End of range',
'delete_account' => 'Delete account ":name"', 'delete_account' => 'Delete account ":name"',