mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 17:39:06 +02:00
Show attachment preview on attachment page.
This commit is contained in:
parent
02b71eeab8
commit
d99365f906
1 changed files with 36 additions and 28 deletions
|
@ -11,43 +11,51 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for attachment in form.attachments %}
|
{% for attachment in form.attachments %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td class="row">
|
||||||
{{ form_widget(attachment) }}
|
<div class="col-9">
|
||||||
</td>
|
{{ form_widget(attachment) }}
|
||||||
<td>
|
</div>
|
||||||
{{ delete_btn }}
|
<div class="pl-0 col-3">
|
||||||
|
{{ delete_btn }}
|
||||||
|
|
||||||
{% set attach = attachment.vars.value %}
|
{% set attach = attachment.vars.value %}
|
||||||
|
|
||||||
{% if attachment_helper.fileExisting(attach) %}
|
{% if attachment_helper.fileExisting(attach) %}
|
||||||
{% if not attach.external %}
|
{% if not attach.external %}
|
||||||
<br><br>
|
<br><br>
|
||||||
<h6>
|
<h6>
|
||||||
<span class="badge badge-primary">
|
<span class="badge badge-primary">
|
||||||
<i class="fas fa-fw fa-file"></i> {{ attach.filename }}
|
<i class="fas fa-fw fa-file"></i> {{ attach.filename }}
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
<span class="badge badge-secondary">
|
<span class="badge badge-secondary">
|
||||||
<i class="fas fa-hdd fa-fw"></i> {{ attachment_helper.humanFileSize(attach) }}
|
<i class="fas fa-hdd fa-fw"></i> {{ attachment_helper.humanFileSize(attach) }}
|
||||||
</span>
|
</span>
|
||||||
</h6>
|
</h6>
|
||||||
{% else %}
|
{% else %}
|
||||||
<br><br>
|
<br><br>
|
||||||
<h6>
|
<h6>
|
||||||
<span class="badge badge-primary">
|
<span class="badge badge-primary">
|
||||||
<i class="fas fa-fw fa-globe"></i> {% trans %}attachment.external{% endtrans %}
|
<i class="fas fa-fw fa-globe"></i> {% trans %}attachment.external{% endtrans %}
|
||||||
</span>
|
</span>
|
||||||
</h6>
|
</h6>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% if attach.picture %}
|
||||||
<br><br>
|
<a href="{{ attach | entityURL('file_view') }}" target="_blank" data-no-ajax>
|
||||||
<h6>
|
<img class="img-fluid img-thumbnail" src="{{ attach | entityURL('file_view') }}" alt="{% trans %}attachment.preview.alt{% endtrans %}" />
|
||||||
|
</a>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ attach | entityURL('file_view') }}" target="_blank" data-no-ajax class="link-external">{% trans %}attachment.view{% endtrans %}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<br><br>
|
||||||
|
<h6>
|
||||||
<span class="badge badge-warning">
|
<span class="badge badge-warning">
|
||||||
<i class="fas fa-exclamation-circle fa-fw"></i> {% trans %}attachment.file_not_found{% endtrans %}
|
<i class="fas fa-exclamation-circle fa-fw"></i> {% trans %}attachment.file_not_found{% endtrans %}
|
||||||
</span>
|
</span>
|
||||||
</h6>
|
</h6>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -77,12 +85,12 @@
|
||||||
|
|
||||||
//Increase the index
|
//Increase the index
|
||||||
newForm = newForm.replace(/__name__/g, index);
|
newForm = newForm.replace(/__name__/g, index);
|
||||||
newForm = '<td>' + newForm + '</td>';
|
newForm = '<div class="col-9">' + newForm + '</div>';
|
||||||
$newFormRow = $('<tr></tr>').html(newForm);
|
$newFormRow = $('<tr></tr>').html("<td class='row'>" + newForm + "</td>");
|
||||||
|
|
||||||
//Add delete button
|
//Add delete button
|
||||||
$btn = '<td>' + '{{ delete_btn|e('js') }}' + '</td>';
|
$btn = '<div class="col-3">' + '{{ delete_btn|e('js') }}' + '</div>';
|
||||||
$newFormRow.append($btn);
|
$('td' ,$newFormRow).append($btn);
|
||||||
|
|
||||||
$holder.append($newFormRow);
|
$holder.append($newFormRow);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue