Make bill views use transformer object.

This commit is contained in:
James Cole
2018-02-06 18:12:09 +01:00
parent 2f4f37778c
commit 2816a4a325
3 changed files with 39 additions and 41 deletions

View File

@@ -26,7 +26,6 @@
<div style="padding:8px;"> <div style="padding:8px;">
<a class="btn btn-success" href="{{ route('bills.create') }}"><i class="fa fa-plus fa-fw"></i> {{ 'create_new_bill'|_ }}</a> <a class="btn btn-success" href="{{ route('bills.create') }}"><i class="fa fa-plus fa-fw"></i> {{ 'create_new_bill'|_ }}</a>
</div> </div>
<bills-index></bills-index> <bills-index></bills-index>
<p><hr /></p> <p><hr /></p>
{% include 'list/bills' %} {% include 'list/bills' %}

View File

@@ -10,14 +10,14 @@
<div class="col-lg-6 col-sm-12 col-md-12"> <div class="col-lg-6 col-sm-12 col-md-12">
<div class="box" id="billInfo"> <div class="box" id="billInfo">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">{{ bill.name }}</h3> <h3 class="box-title">{{ object.name }}</h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i></button> <button class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i></button>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li><a href="{{ route('bills.edit',bill.id) }}"><i class="fa fa-fw fa-pencil"></i> {{ 'edit'|_ }}</a></li> <li><a href="{{ route('bills.edit',object.id) }}"><i class="fa fa-fw fa-pencil"></i> {{ 'edit'|_ }}</a></li>
<li><a href="{{ route('bills.delete',bill.id) }}"><i class="fa fa-fw fa-trash-o"></i> {{ 'delete'|_ }}</a></li> <li><a href="{{ route('bills.delete',object.id) }}"><i class="fa fa-fw fa-trash-o"></i> {{ 'delete'|_ }}</a></li>
</ul> </ul>
</div> </div>
</div> </div>
@@ -28,18 +28,18 @@
<tr> <tr>
<td colspan="2"> <td colspan="2">
{{ 'matching_on'|_ }} {{ 'matching_on'|_ }}
{% for word in bill.match|split(',') %} {% for word in object.match %}
<span class="label label-info">{{ word }}</span> <span class="label label-info">{{ word }}</span>
{% endfor %} {% endfor %}
{{ trans('firefly.between_amounts', {low: bill.amount_min|formatAmount, high: bill.amount_max|formatAmount })|raw }} {{ trans('firefly.between_amounts', {low: object.amount_min|formatAmount, high: object.amount_max|formatAmount })|raw }}
{{ 'repeats'|_ }} {{ 'repeats'|_ }}
{{ trans('firefly.repeat_freq_' ~bill.repeat_freq) }}. {{ trans('firefly.repeat_freq_' ~object.repeat_freq) }}.
</td> </td>
</tr> </tr>
<tr> <tr>
<td>{{ 'bill_is_active'|_ }}</td> <td>{{ 'bill_is_active'|_ }}</td>
<td> <td>
{% if bill.active %} {% if object.active %}
<i class="fa fa-check fa-fw" title="{{ 'active'|_ }}"></i> {{ 'yes'|_ }} <i class="fa fa-check fa-fw" title="{{ 'active'|_ }}"></i> {{ 'yes'|_ }}
{% else %} {% else %}
<i class="fa fa-times fa-fw" title="{{ 'inactive'|_ }}"></i> {{ 'no'|_ }} <i class="fa fa-times fa-fw" title="{{ 'inactive'|_ }}"></i> {{ 'no'|_ }}
@@ -49,21 +49,20 @@
<tr> <tr>
<td>{{ 'bill_will_automatch'|_ }}</td> <td>{{ 'bill_will_automatch'|_ }}</td>
<td> <td>
{% if bill.automatch %} {% if object.automatch %}
<i class="fa fa-check fa-fw" title="{{ 'auto_match_on'|_ }}"></i> {{ 'yes'|_ }} <i class="fa fa-check fa-fw" title="{{ 'auto_match_on'|_ }}"></i> {{ 'yes'|_ }}
{% else %} {% else %}
<i class="fa fa-times fa-fw" title="{{ 'auto_match_off'|_ }}"></i> {{ 'no'|_ }} <i class="fa fa-times fa-fw" title="{{ 'auto_match_off'|_ }}"></i> {{ 'no'|_ }}
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
<tr> <tr>
<td>{{ 'next_expected_match'|_ }}</td> <td>{{ 'next_expected_match'|_ }}</td>
<td> <td>
{% if bill.nextExpectedMatch %} {% if object.next_expected_match|length > 0 %}
{{ bill.nextExpectedMatch.formatLocalized(monthAndDayFormat) }} {{ formatDate(object.next_expected_match, monthAndDayFormat) }}
{% else %} {% else %}
<em>{{ 'unknown'|_ }}</em> {{ 'unknown'|_ }}
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
@@ -85,21 +84,21 @@
<h3 class="box-title">{{ 'more'|_ }}</h3> <h3 class="box-title">{{ 'more'|_ }}</h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body no-padding">
{% if bill.notes.count == 1 %} {% if object.notes|length > 0 %}
<table class="table"> <table class="table">
<tr> <tr>
<td>{{ trans('list.notes') }}</td> <td>{{ trans('list.notes') }}</td>
<td class="markdown">{{ bill.notes.first.text|markdown }}</td> <td class="markdown">{{ object.notes|markdown }}</td>
</tr> </tr>
</table> </table>
{% endif %} {% endif %}
</div> </div>
<div class="box-footer"> <div class="box-footer">
<a href="{{ route('bills.rescan',bill.id) }}" class="btn btn-default">{{ 'rescan_old'|_ }}</a> <a href="{{ route('bills.rescan',object.id) }}" class="btn btn-default">{{ 'rescan_old'|_ }}</a>
</div> </div>
</div> </div>
{% if bill.attachments|length > 0 %} {% if object.attachments_count > 0 %}
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">{{ 'attachments'|_ }}</h3> <h3 class="box-title">{{ 'attachments'|_ }}</h3>
@@ -171,7 +170,7 @@
{% block scripts %} {% block scripts %}
<script type="text/javascript"> <script type="text/javascript">
var billUri = '{{ route('chart.bill.single', [bill.id]) }}'; var billUri = '{{ route('chart.bill.single', [object.id]) }}';
</script> </script>
<script type="text/javascript" src="js/lib/Chart.bundle.min.js?v={{ FF_VERSION }}"></script> <script type="text/javascript" src="js/lib/Chart.bundle.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="js/ff/charts.defaults.js?v={{ FF_VERSION }}"></script> <script type="text/javascript" src="js/ff/charts.defaults.js?v={{ FF_VERSION }}"></script>

View File

@@ -1,5 +1,5 @@
<div style="padding-left:8px;"> <div style="padding-left:8px;">
{{ bills.render|raw }} {{ paginator.render|raw }}
</div> </div>
<table class="table table-hover sortable"> <table class="table table-hover sortable">
<thead> <thead>
@@ -26,13 +26,13 @@
<td data-value="{{ entry.name }}"> <td data-value="{{ entry.name }}">
<a href="{{ route('bills.show',entry.id) }}" title="{{ entry.name }}">{{ entry.name }}</a> <a href="{{ route('bills.show',entry.id) }}" title="{{ entry.name }}">{{ entry.name }}</a>
{# count attachments #} {# count attachments #}
{% if entry.attachments.count > 0 %} {% if entry.attachments_count > 0 %}
<i class="fa fa-paperclip"></i> <i class="fa fa-paperclip"></i>
{% endif %} {% endif %}
</td> </td>
<td class="hidden-sm hidden-md hidden-xs" data-value="{{ entry.match }}"> <td class="hidden-sm hidden-md hidden-xs" data-value="{{ entry.match|join(',') }}">
{% for match in entry.match|split(',') %} {% for match in entry.match %}
<span class="label label-info">{{ match }}</span> <span class="label label-info">{{ match }}</span>
{% endfor %} {% endfor %}
</td> </td>
@@ -49,44 +49,44 @@
{# {#
paidDates = 0 (bill not paid in period) paidDates = 0 (bill not paid in period)
payDates = 0 (bill not expected to be paid in this period) pay_dates = 0 (bill not expected to be paid in this period)
bill is active. bill is active.
#} #}
{% if entry.paidDates.count() == 0 and entry.payDates.count() == 0 and entry.active %} {% if entry.paid_dates|length == 0 and entry.pay_dates|length == 0 and entry.active %}
<td class="paid_in_period text-muted" data-value="0001-00-00 00-00-00"> <td class="paid_in_period text-muted" data-value="0001-00-00 00-00-00">
{{ trans('components.not_expected_period') }} {{ trans('components.not_expected_period') }}
</td> </td>
<td class="expected_in_period hidden-sm hidden-xs" data-value="{{ entry.nextExpectedMatch.format('Y-m-d H-i-s') }}"> <td class="expected_in_period hidden-sm hidden-xs" data-value="{{ entry.next_expected_match }}">
{{ entry.nextExpectedMatch.formatLocalized(monthAndDayFormat) }} {{ formatDate(entry.next_expected_match, monthAndDayFormat) }}
</td> </td>
{% endif %} {% endif %}
{# {#
paidDates = 0 (bill not paid in period) paid_dates = 0 (bill not paid in period)
payDates > 0 (bill IS expected to be paid in this period) pay_dates > 0 (bill IS expected to be paid in this period)
bill is active bill is active
#} #}
{% if entry.paidDates.count() == 0 and entry.payDates.count() > 0 and entry.active %} {% if entry.paid_dates|length == 0 and entry.pay_dates|length > 0 and entry.active %}
<td class="paid_in_period text-danger" data-value="0002-00-00 00-00-00"> <td class="paid_in_period text-danger" data-value="0002-00-00 00-00-00">
{{ trans('components.not_or_not_yet') }} {{ trans('components.not_or_not_yet') }}
</td> </td>
<td class="expected_in_period hidden-sm hidden-xs" data-value="{{ entry.nextExpectedMatch.format('Y-m-d H-i-s') }}"> <td class="expected_in_period hidden-sm hidden-xs" data-value="{{ entry.next_expected_match }}">
{{ entry.nextExpectedMatch.formatLocalized(monthAndDayFormat) }} {{ formatDate(entry.next_expected_match, monthAndDayFormat) }}
</td> </td>
{% endif %} {% endif %}
{# {#
paidDates >= 0 (bill is paid X times). paid_dates >= 0 (bill is paid X times).
Don't care about payDates. Don't care about pay_dates.
#} #}
{% if entry.paidDates.count() > 0 and entry.active %} {% if entry.paid_dates|length > 0 and entry.active %}
<td class="paid_in_period text-success" data-value="{{ entry.paidDates.first.format('Y-m-d H-i-s') }}"> <td class="paid_in_period text-success" data-value="{{ entry.paid_dates[0] }}">
{% for date in entry.paidDates %} {% for date in entry.paid_dates %}
{{ date.formatLocalized(monthAndDayFormat) }}<br/> {{ formatDate(date, monthAndDayFormat) }}<br />
{% endfor %} {% endfor %}
</td> </td>
<td class="expected_in_period hidden-sm hidden-xs" data-value="{{ entry.nextExpectedMatch.format('Y-m-d H-i-s') }}"> <td class="expected_in_period hidden-sm hidden-xs" data-value="{{ entry.next_expected_match }}">
{{ entry.nextExpectedMatch.formatLocalized(monthAndDayFormat) }} {{ formatDate(entry.next_expected_match, monthAndDayFormat) }}
</td> </td>
{% endif %} {% endif %}
{# bill is not active #} {# bill is not active #}
@@ -124,5 +124,5 @@
</tbody> </tbody>
</table> </table>
<div style="padding-left:8px;"> <div style="padding-left:8px;">
{{ bills.render|raw }} {{ paginator.render|raw }}
</div> </div>