mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Updated transaction view.
This commit is contained in:
parent
d3c34ca155
commit
af4a188480
@ -24,8 +24,11 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Support\Twig;
|
||||
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Transaction as TransactionModel;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use Lang;
|
||||
use Steam;
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFilter;
|
||||
@ -38,6 +41,41 @@ use Twig_SimpleFunction;
|
||||
*/
|
||||
class Transaction extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
* @return Twig_SimpleFunction
|
||||
*/
|
||||
public function attachmentIndicator(): Twig_SimpleFunction
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'attachmentIndicator', function (int $journalId) {
|
||||
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('attachments_journal');
|
||||
$cache->addProperty($journalId);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$count = Attachment::whereNull('deleted_at')
|
||||
->where('attachable_type', 'FireflyIII\Models\TransactionJournal')
|
||||
->where('attachable_id', $journalId)
|
||||
->count();
|
||||
if ($count > 0) {
|
||||
$res = sprintf('<i class="fa fa-paperclip" title="%s"></i>', Lang::choice('firefly.nr_of_attachments', $count, ['count' => $count]));
|
||||
$cache->store($res);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
$res = '';
|
||||
$cache->store($res);
|
||||
|
||||
return $res;
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -63,6 +101,7 @@ class Transaction extends Twig_Extension
|
||||
$this->transactionCategories(),
|
||||
$this->transactionIdCategories(),
|
||||
$this->splitJournalIndicator(),
|
||||
$this->attachmentIndicator(),
|
||||
];
|
||||
|
||||
return $functions;
|
||||
@ -85,12 +124,25 @@ class Transaction extends Twig_Extension
|
||||
{
|
||||
return new Twig_SimpleFunction(
|
||||
'splitJournalIndicator', function (int $journalId) {
|
||||
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty('is_split_journal');
|
||||
$cache->addProperty($journalId);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
|
||||
if ($count > 2) {
|
||||
return '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
|
||||
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
|
||||
$cache->store($res);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
return '';
|
||||
$res = '';
|
||||
$cache->store($res);
|
||||
|
||||
return $res;
|
||||
|
||||
|
||||
}, ['is_safe' => ['html']]
|
||||
|
@ -10,17 +10,17 @@
|
||||
<th class="hidden-xs hidden-sm">{{ trans('list.date') }}</th>
|
||||
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.from') }}</th>
|
||||
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.to') }}</th>
|
||||
<!-- Hide budgets? -->
|
||||
{# Hide budgets? #}
|
||||
{% if not hideBudgets %}
|
||||
<th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
|
||||
{% endif %}
|
||||
|
||||
<!-- Hide categories? -->
|
||||
{# Hide categories? #}
|
||||
{% if not hideCategories %}
|
||||
<th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
|
||||
{% endif %}
|
||||
|
||||
<!-- Hide bills? -->
|
||||
{# Hide bills? #}
|
||||
{% if not hideBills %}
|
||||
<th class="hidden-xs"><i class="fa fa-fw fa-calendar-o" title="{{ trans('list.bill') }}"></i></th>
|
||||
{% endif %}
|
||||
@ -29,6 +29,7 @@
|
||||
<tbody>
|
||||
{% for transaction in journals %}
|
||||
<tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}">
|
||||
{# input buttons #}
|
||||
<td class="hidden-xs">
|
||||
<div class="select_single" style="display:none;">
|
||||
<input name="select_all_single[]" class="select_all_single" value="{{ transaction.journal_id }}" type="checkbox"/>
|
||||
@ -40,9 +41,12 @@
|
||||
class="fa fa-fw fa-trash-o"></i></a></div>
|
||||
</td>
|
||||
|
||||
{# icon #}
|
||||
<td class="hidden-xs">
|
||||
{{ transaction|typeIconTransaction }}
|
||||
</td>
|
||||
|
||||
{# description #}
|
||||
<td>
|
||||
<a href="{{ route('transactions.show',transaction.journal_id) }}">
|
||||
|
||||
@ -52,13 +56,11 @@
|
||||
{{ transaction.description }}
|
||||
{% endif %}
|
||||
</a>
|
||||
{# is a split journal #}
|
||||
{{ splitJournalIndicator(transaction.journal_id) }}
|
||||
{% set countAtt = transaction.transactionJournal.attachments.count %}
|
||||
{% if countAtt > 0 %}
|
||||
<i class="fa fa-paperclip"
|
||||
title="{{ Lang.choice('firefly.nr_of_attachments', countAtt, {count: countAtt}) }}"></i>
|
||||
{% endif %}
|
||||
|
||||
{# count attachments #}
|
||||
{{ attachmentIndicator(transaction.journal_id) }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<span style="margin-right:5px;">
|
||||
|
Loading…
Reference in New Issue
Block a user