Skip to content

Firefly III: a personal finances manager

Improved tag view [skip ci]

James Coleddefb0debcaa
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php
index 673b2813d7..3ec7878858 100644
--- a/app/Http/Controllers/TagController.php
+++ b/app/Http/Controllers/TagController.php
@@ -178,9 +178,24 @@ class TagController extends Controller
$title = 'Tags';
$mainTitleIcon = 'fa-tags';
$helpHidden = $helpHiddenPref->data;
- $tags = Auth::user()->tags()->get();
- return view('tags.index', compact('title', 'mainTitleIcon', 'helpHidden', 'tags'));
+ // group years.
+ $types = ['nothing','balancingAct', 'advancePayment'];
+
+ // loop each types and get the tags, group them by year.
+ $collection = [];
+ foreach ($types as $type) {
+ $tags = Auth::user()->tags()->where('tagMode', $type)->orderBy('date','ASC')->get();
+ /** @var Tag $tag */
+ foreach ($tags as $tag) {
+ $year = is_null($tag->date) ? trans('firefly.no_year') : $tag->date->year;
+ $month = is_null($tag->date) ? trans('firefly.no_month') : $tag->date->formatLocalized($this->monthFormat);
+ $collection[$type][$year][$month][] = $tag;
+ }
+ }
+
+
+ return view('tags.index', compact('title', 'mainTitleIcon','types', 'helpHidden', 'collection'));
}
/**
@@ -193,7 +208,7 @@ class TagController extends Controller
$subTitle = $tag->tag;
$subTitleIcon = 'fa-tag';
- return view('tags.show', compact('tag', 'subTitle', 'subTitleIcon'));
+ return view('tags.show', compact('tag', 'subTitle','types', 'subTitleIcon'));
}
/**
diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php
index 9b9c54a95b..7c436b42d1 100644
--- a/resources/lang/en/firefly.php
+++ b/resources/lang/en/firefly.php
@@ -286,6 +286,11 @@ return [
'delete_tag' => 'Delete tag ":name"',
'new_tag' => 'Make new tag',
'edit_tag' => 'Edit tag ":tag"',
+ 'no_year' => 'No year set',
+ 'no_month' => 'No month set',
+ 'tag_title_nothing' => 'Default tags',
+ 'tag_title_balancingAct' => 'Balancing act tags',
+ 'tag_title_advancePayment' => 'Advance payment tags',
// reminders
'reminder_for_piggy' => 'Reminder for piggy bank ":name"',
diff --git a/resources/lang/nl/firefly.php b/resources/lang/nl/firefly.php
index 4a42b5ae8e..5b740824db 100644
--- a/resources/lang/nl/firefly.php
+++ b/resources/lang/nl/firefly.php
@@ -295,6 +295,11 @@ return [
'delete_tag' => 'Verwijder tag ":name"',
'new_tag' => 'Maak nieuwe tag',
'edit_tag' => 'Wijzig tag ":tag"',
+ 'no_year' => 'Zonder jaar',
+ 'no_maand' => 'Zonder jaar',
+ 'tag_title_nothing' => 'Standaard tags',
+ 'tag_title_balancingAct' => 'Balancing act tags',
+ 'tag_title_advancePayment' => 'Advance payment tags',
// reminders
'reminder_for_piggy' => 'Herinnering voor spaarpotje ":name"',
diff --git a/resources/twig/tags/index.twig b/resources/twig/tags/index.twig
index e9ce66c161..86b5feac8e 100644
--- a/resources/twig/tags/index.twig
+++ b/resources/twig/tags/index.twig
@@ -41,6 +41,49 @@
{% endif %}
</a>
</p>
+ </div>
+ </div>
+ </div>
+</div>
+<div class="row">
+ {% for type in types %}
+ <div class="col-lg-4">
+ <div class="panel panel-default">
+ <div class="panel-heading"><i class="fa fa-fw fa-tag"></i> {{ ('tag_title_'~type)|_ }}</div>
+ <div class="panel-body">
+ {% for year,months in collection[type] %}
+ <h4>{{ year }}</h4>
+
+ {% for month,tags in months %}
+ <h5>{{ month }}</h5>
+ <p style="line-height: 200%;">
+ {% for tag in tags %}
+ <span style="display: inline;"><a style="font-size:100%;font-weight:normal;" class="label label-success" href="{{route('tags.show',tag.id)}}">
+ {% if tag.tagMode == 'nothing' %}
+ <i class="fa fa-fw fa-tag"></i>
+ {% endif %}
+ {% if tag.tagMode == 'balancingAct' %}
+ <i class="fa fa-fw fa-refresh"></i>
+ {% endif %}
+ {% if tag.tagMode == 'advancePayment' %}
+ <i class="fa fa-fw fa-sort-numeric-desc"></i>
+ {% endif %}
+ {{tag.tag}}</a>
+ </span>
+ {% endfor %}
+ </p>
+ {% endfor %}
+ {% endfor %}
+
+
+ </div>
+ </div>
+ </div>
+ {% endfor %}
+
+</div>
+
+
<p>
<a href="{{route('tags.create')}}" title="New tag" class="btn btn-info"><i class="fa fa-fw fa-plus"></i> Create new tag</a>
</p>