Improved tag view [skip ci]

This commit is contained in:
James Cole 2015-06-18 18:05:06 +02:00
parent 92d8dde90d
commit ddefb0debc
4 changed files with 71 additions and 3 deletions

View File

@ -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'));
}
/**

View File

@ -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"',

View File

@ -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"',

View File

@ -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>