2019-09-24 18:28:35 +02:00
|
|
|
{% set delete_btn %}
|
|
|
|
<button type="button" class="btn btn-danger lot_btn_delete" onclick="delete_attachment_entry(this);">
|
|
|
|
<i class="fas fa-trash-alt fa-fw"></i>
|
|
|
|
{% trans %}attachment.delete{% endtrans %}
|
|
|
|
</button>
|
|
|
|
{% endset %}
|
|
|
|
|
|
|
|
{#{{ form_row(form.master_picture_attachment) }} #}
|
|
|
|
|
|
|
|
<table class="table table-striped table-sm" id="attachments_table" data-prototype="{% if form.attachments.vars.prototype is defined %}{{ form_widget(form.attachments.vars.prototype)|e('html_attr') }}{% endif %}">
|
|
|
|
<tbody>
|
|
|
|
{% for attachment in form.attachments %}
|
|
|
|
<tr>
|
2019-09-25 14:46:00 +02:00
|
|
|
<td class="row">
|
|
|
|
<div class="col-9">
|
|
|
|
{{ form_widget(attachment) }}
|
|
|
|
</div>
|
2022-07-24 18:08:21 +02:00
|
|
|
<div class="ps-0 col-3">
|
2019-09-25 14:46:00 +02:00
|
|
|
{{ delete_btn }}
|
2019-09-24 18:28:35 +02:00
|
|
|
|
2019-09-25 14:46:00 +02:00
|
|
|
{% set attach = attachment.vars.value %}
|
2019-10-13 13:34:26 +02:00
|
|
|
{# @var attach \App\Entity\Attachments\Attachment #}
|
|
|
|
|
2019-09-24 18:28:35 +02:00
|
|
|
|
2020-04-03 14:56:48 +02:00
|
|
|
{% if attachment_manager.fileExisting(attach) %}
|
2019-09-25 14:46:00 +02:00
|
|
|
{% if not attach.external %}
|
|
|
|
<br><br>
|
|
|
|
<h6>
|
2019-10-13 13:34:26 +02:00
|
|
|
<span class="badge badge-primary">
|
2019-11-10 18:23:03 +01:00
|
|
|
<i class="fas fa-fw {{ ext_to_fa_icon(attach.extension) }}"></i> {{ attach.filename }}
|
2019-10-13 13:34:26 +02:00
|
|
|
</span>
|
2019-09-25 14:46:00 +02:00
|
|
|
<br>
|
|
|
|
<span class="badge badge-secondary">
|
2020-04-03 14:56:48 +02:00
|
|
|
<i class="fas fa-hdd fa-fw"></i> {{ attachment_manager.humanFileSize(attach) }}
|
2019-10-13 13:34:26 +02:00
|
|
|
</span>
|
2019-09-25 14:46:00 +02:00
|
|
|
</h6>
|
|
|
|
{% else %}
|
|
|
|
<br><br>
|
|
|
|
<h6>
|
2019-09-24 18:28:35 +02:00
|
|
|
<span class="badge badge-primary">
|
|
|
|
<i class="fas fa-fw fa-globe"></i> {% trans %}attachment.external{% endtrans %}
|
|
|
|
</span>
|
2019-09-25 14:46:00 +02:00
|
|
|
</h6>
|
|
|
|
{% endif %}
|
2020-03-30 16:56:58 +02:00
|
|
|
{% if attach.secure and not is_granted('show_private', attach) %}
|
|
|
|
{# Leave blank #}
|
|
|
|
{% elseif attach.picture %}
|
2022-07-24 16:03:07 +02:00
|
|
|
<a href="{{ attach | entityURL('file_view') }}" target="_blank" rel="noopener" data-turbo="false">
|
2019-10-06 15:44:19 +02:00
|
|
|
<img class="img-fluid img-thumbnail thumbnail-sm" src="{{ attachment_thumbnail(attach, 'thumbnail_md') }}" alt="{% trans %}attachment.preview.alt{% endtrans %}" />
|
2019-09-25 14:46:00 +02:00
|
|
|
</a>
|
|
|
|
{% else %}
|
2022-07-24 16:03:07 +02:00
|
|
|
<a href="{{ attach | entityURL('file_view') }}" rel="noopener" target="_blank" data-turbo="false" class="link-external">{% trans %}attachment.view{% endtrans %}</a>
|
2019-09-25 14:46:00 +02:00
|
|
|
{% endif %}
|
|
|
|
{% else %}
|
|
|
|
<br><br>
|
|
|
|
<h6>
|
2019-09-24 18:28:35 +02:00
|
|
|
<span class="badge badge-warning">
|
|
|
|
<i class="fas fa-exclamation-circle fa-fw"></i> {% trans %}attachment.file_not_found{% endtrans %}
|
|
|
|
</span>
|
2019-09-25 14:46:00 +02:00
|
|
|
</h6>
|
|
|
|
{% endif %}
|
2019-10-13 13:34:26 +02:00
|
|
|
|
|
|
|
{% if attach.secure %}
|
|
|
|
<h6>
|
2020-03-30 17:09:31 +02:00
|
|
|
<span class="badge badge-success">
|
2019-10-13 13:34:26 +02:00
|
|
|
<i class="fas fa-fw fa-shield-alt"></i> {% trans %}attachment.secure{% endtrans %}
|
|
|
|
</span>
|
|
|
|
</h6>
|
|
|
|
{% endif %}
|
2019-09-25 14:46:00 +02:00
|
|
|
</div>
|
2019-09-24 18:28:35 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<button type="button" class="btn btn-success" onclick="create_attachment_entry(this)">
|
|
|
|
<i class="fas fa-plus-square fa-fw"></i>
|
|
|
|
{% trans %}attachment.create{% endtrans %}
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function delete_attachment_entry(btn) {
|
|
|
|
window.bootbox.confirm('{% trans %}part_lot.edit.delete.confirm{% endtrans %}', function (result) {
|
|
|
|
if(result) {
|
|
|
|
$(btn).parents("tr").remove();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_attachment_entry(btn) {
|
|
|
|
//Determine the table, so we can determine, how many entries there are already.
|
|
|
|
$holder = $("#attachments_table");
|
|
|
|
|
2020-03-30 15:49:04 +02:00
|
|
|
var index = $holder.children("tbody").children("tr").length;
|
2019-09-24 18:28:35 +02:00
|
|
|
var newForm = $holder.data("prototype");
|
|
|
|
|
|
|
|
//Increase the index
|
|
|
|
newForm = newForm.replace(/__name__/g, index);
|
2019-09-25 14:46:00 +02:00
|
|
|
newForm = '<div class="col-9">' + newForm + '</div>';
|
|
|
|
$newFormRow = $('<tr></tr>').html("<td class='row'>" + newForm + "</td>");
|
2019-09-24 18:28:35 +02:00
|
|
|
|
|
|
|
//Add delete button
|
2019-09-25 14:46:00 +02:00
|
|
|
$btn = '<div class="col-3">' + '{{ delete_btn|e('js') }}' + '</div>';
|
|
|
|
$('td' ,$newFormRow).append($btn);
|
2019-09-24 18:28:35 +02:00
|
|
|
|
|
|
|
$holder.append($newFormRow);
|
|
|
|
|
|
|
|
//Reinit the selectpickers
|
|
|
|
$(".file").fileinput();
|
|
|
|
|
2019-10-03 14:17:35 +02:00
|
|
|
//Reinit typeahead:
|
|
|
|
$(document).trigger('attachment:create');
|
2019-09-24 18:28:35 +02:00
|
|
|
}
|
|
|
|
</script>
|