Improve attachment list.

This commit is contained in:
James Cole
2018-04-28 06:53:37 +02:00
parent d03de52735
commit 7b39828980
2 changed files with 21 additions and 17 deletions

View File

@@ -152,7 +152,7 @@ class AttachmentController extends Controller
*/ */
public function index() public function index()
{ {
$set = $this->repository->get(); $set = $this->repository->get()->reverse();
$set = $set->each( $set = $set->each(
function (Attachment $attachment) { function (Attachment $attachment) {
$attachment->file_exists = $this->repository->exists($attachment); $attachment->file_exists = $this->repository->exists($attachment);

View File

@@ -10,45 +10,47 @@
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title"> <h3 class="box-title">
List of all attachments {{ 'list_all_attachments'|_ }}
</h3> </h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body no-padding">
<table class="table table-striped"> <table class="table table-striped sortable">
<thead> <thead>
<tr> <tr>
<th colspan="2">File name</th> <th data-defaultsign="_19" colspan="2">{{ trans('list.file_name') }}</th>
<th>Size of file</th> <th data-defaultsign="_19">{{ trans('list.file_size') }}</th>
<th>Type of file</th> <th data-defaultsign="az">{{ trans('list.file_type') }}</th>
<th>Attached to</th> <th data-defaultsign="az">{{ trans('list.attached_to') }}</th>
<th>Exists?</th> <th data-defaultsign="_19">{{ trans('list.file_exists') }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for att in set %} {% for att in set %}
<tr> <tr>
<td> <td data-value="{{ att.id }}">
<div class="btn-group btn-group-xs"> <div class="btn-group btn-group-xs">
<a href="{{ route('attachments.edit', att.id) }}" class="btn btn-default"><i class="fa fa-pencil"></i></a> <a href="{{ route('attachments.edit', att.id) }}" class="btn btn-default"><i class="fa fa-pencil"></i></a>
<a href="{{ route('attachments.delete', att.id) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a> <a href="{{ route('attachments.delete', att.id) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a>
<a href="{{ route('attachments.download', att.id) }}" class="btn btn-default"><i class="fa fa-download"></i></a> <a href="{{ route('attachments.download', att.id) }}" class="btn btn-default"><i class="fa fa-download"></i></a>
</div> </div>
</td> </td>
<td> <td data-value="{{ att.filename }}">
<a href="{{ route('attachments.view', att.id) }}" title="{{ att.filename }}"> <a href="{{ route('attachments.view', att.id) }}" title="{{ att.filename }}">
{{ att.filename }} {{ att.filename }}
</a> </a>
</td> </td>
<td>{{ att.size|filesize }}</td> <td data-value="{{ att.size }}">{{ att.size|filesize }}</td>
<td>{{ att.mime }}</td> <td data-value="{{ att.mime }}">{{ att.mime }}</td>
<td> <td data-value="{{ att.attachable_type }}_{{ att.attachable_id }}">
{% if att.attachable_type == 'FireflyIII\\Models\\TransactionJournal' %} {% if att.attachable_type == 'FireflyIII\\Models\\TransactionJournal' %}
<a href="{{ route('transactions.show', [att.attachable_id]) }}"> <a href="{{ route('transactions.show', [att.attachable_id]) }}">
{{ att.attachable.description }} {{ att.attachable.description }}
</a> </a>
{% else %}
{{ att.attachable_type }}
{% endif %} {% endif %}
</td> </td>
<td> <td data-value="{% if att.file_exists %}1{% else %}0{% endif %}">
{% if att.file_exists %} {% if att.file_exists %}
<i class="fa fa-check text-success"></i> <i class="fa fa-check text-success"></i>
{% else %} {% else %}
@@ -64,9 +66,11 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block scripts %}
<script type="text/javascript" src="js/lib/bootstrap-sortable.js?v={{ FF_VERSION }}"></script>
{% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="css/bootstrap-sortable.css?v={{ FF_VERSION }}" type="text/css" media="all"/>
{% endblock %} {% endblock %}
{% block scripts %}
{% endblock %}