Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Group tags by date.
James Colec97fb07e8dbc
diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.phpindex b831727b81..fe021bb736 100644--- a/app/Support/Http/Controllers/RenderPartialViews.php+++ b/app/Support/Http/Controllers/RenderPartialViews.php@@ -24,6 +24,7 @@ declare(strict_types=1);namespace FireflyIII\Support\Http\Controllers;+use FireflyIII\Models\Tag;use Illuminate\Support\Facades\Log;use FireflyIII\Enums\AccountTypeEnum;use FireflyIII\Exceptions\FireflyException;@@ -416,8 +417,19 @@ trait RenderPartialViews$repository = app(TagRepositoryInterface::class);$tags = $repository->get();+ $grouped = [];+ /** @var Tag $tag */+ foreach($tags as $tag) {+ $year = (int) $tag->date?->year;+ $grouped[$year] ??= [+ 'tags' => [],+ 'year' => 0 === $year ? trans('firefly.no_date') : $year,+ ];+ $grouped[$year]['tags'][] = $tag;+ }+ ksort($grouped);try {- $result = view('reports.options.tag', ['tags' => $tags])->render();+ $result = view('reports.options.tag', ['tags' => $grouped])->render();} catch (Throwable $e) {Log::error(sprintf('Cannot render reports.options.tag: %s', $e->getMessage()));$result = 'Could not render view.';diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex b4973b4bdf..2aea7448d4 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -2480,6 +2480,7 @@ return ['balanceFor' => 'Balance for :name','no_tags' => '(no tags)','nothing_found' => '(nothing found)',+ 'no_date' => '(no date)',// page settings and wizard dialogsdiff --git a/resources/views/reports/options/tag.twig b/resources/views/reports/options/tag.twigindex bcaec1bf17..346a3db163 100644--- a/resources/views/reports/options/tag.twig+++ b/resources/views/reports/options/tag.twig@@ -2,9 +2,13 @@<label for="inputTags" class="col-sm-3 control-label">{{ 'select_tag'|_ }}</label><div class="col-sm-9"><select id="inputTags" name="tag[]" multiple="multiple" class="form-control">- {% for tag in tags %}- <option value="{{ tag.id }}" label="{{ tag.tag|e('html') }}">{{ tag.tag|e('html') }}</option>+ {% for year in tags %}+ <optgroup label="{{ year.year }}">+ {% for tag in year.tags %}+ <option value="{{ tag.id }}" label="{{ tag.tag|e('html') }}">{{ tag.tag|e('html') }}</option>+ {% endfor %}{% endfor %}+</select></div></div>