WIP: Implement document handling

This commit is contained in:
Björn Fromme
2023-10-12 10:41:31 +02:00
parent 3e7ca7e166
commit 46915955b0
18 changed files with 529 additions and 49 deletions
@@ -1,3 +1,15 @@
{% macro collectionRow(form) %}
<div {{ stimulus_target('form-collection', 'field') }}>
<div class="flex items-center space-x-4">
{{ form_widget(form) }}
<button type="button" {{ stimulus_action('form-collection', 'removeItem') }}>
{{ icon('delete', 'w-4 h-4 mt-2 pointer-events-none') }}
</button>
</div>
{{ form_errors(form) }}
</div>
{% endmacro %}
{{ form_start(form) }}
<div class="flex flex-col space-y-4 pb-8">
<div class="grid lg:grid-cols-5 gap-x-8 gap-y-4">
@@ -25,6 +37,22 @@
</div>
<div class="grid lg:grid-cols-2 gap-x-8 gap-y-4">
{{ form_row(form.remarks) }}
<div {{ stimulus_controller('form-collection', { 'prototype': _self.collectionRow(form.documents.vars.prototype)|json_encode }) }}>
<h4 class="font-bold pb-2">
Dokumente
</h4>
<div {{ stimulus_target('form-collection', 'fields')}} class="flex flex-col space-y-4 mb-4">
{% do form.documents.setRendered %}
{%- for document in form.documents -%}{{- _self.collectionRow(document) -}}{%- endfor -%}
</div>
<div class="flex justify-end">
<button type="button"
{{ stimulus_action('form-collection', 'addItem') }}
title="Dokument hinzufügen">
{{ icon('plus', 'w-4 h-4 pointer-events-none') }}
</button>
</div>
</div>
</div>
</div>
<div class="flex items-center space-x-2">
+79 -9
View File
@@ -6,16 +6,86 @@
<h1 class="text-2xl font-bold pb-8">
Dokumentenübersicht
</h1>
<div class="data-table-wrapper">
<div class="data-table-wrapper__inner">
<table class="data-table">
<thead>
<div class="data-table-wrapper">
<div class="data-table-wrapper__inner">
<table class="data-table">
<thead>
<tr>
<th>
{{ knp_pagination_sortable(pagination, 'Dateiname', 'upload.originalFilename') }}
</th>
<th>
Dateigröße
</th>
<th>
Upload am
</th>
<th>
Upload von
</th>
<th></th>
</tr>
</thead>
<tbody>
{% for document in pagination %}
<tr>
<td>
{{ document.originalFilename }}
</td>
<td>
{{ document.size|file_size }}
</td>
<td>
{{ document.createdAt|date('d.m.Y') }}
</td>
<td>
{{ document.createdBy }}
</td>
<td>
<div class="flex items-center space-x-2 justify-end">
<button type="button"
class="text-red-500"
{{ stimulus_controller('modal-button', [], [], {'confirmation-modal': '#confirmation-modal'}) }}
{{ stimulus_action('modal-button', 'confirmation', null, {
'title': 'Bist du sicher?',
'content': 'Möchtest du das Dokument wirklich löschen?',
'target-url': path('app_admin_document_delete', { 'uuid': document.uuid })
}) }}>
{{ icon('delete') }}
</button>
<button type="button"
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
{{ stimulus_action('modal-button', 'ajax', null, {
'title': 'Dokument ersetzen',
'url': path('app_admin_document_replace', { 'uuid': document.uuid })
}) }}>
{{ icon('refresh') }}
</button>
<a href="{{ path('app_common_download', { 'uuid': document.uuid }) }}"
title="Download">
{{ icon('download') }}
</a>
</div>
</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
{% else %}
<tr>
<td colspan="7">
Keine Daten...
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<button type="button"
class="btn"
{{ stimulus_controller('modal-button', [], [], {'ajax-modal': '#ajax-modal'}) }}
{{ stimulus_action('modal-button', 'ajax', null, {
'title': 'Dokumente hinzufügen',
'url': path('app_admin_document_upload')
}) }}>
Dokumente hinzufügen
</button>
{% endblock %}
@@ -0,0 +1,14 @@
{{ form_start(form) }}
<div class="pb-4">
{% include '_partials/_upload_collection_form.html.twig' with {
'endpoint_upload': path('_uploader_upload_document'),
'max_filesize': 5,
'max_files': 1,
'accepted_files': 'application/pdf',
} %}
</div>
<button type="submit" class="btn">
ersetzen
</button>
{{ form_rest(form) }}
{{ form_end(form) }}
+13
View File
@@ -0,0 +1,13 @@
{{ form_start(form) }}
<div class="pb-4">
{% include '_partials/_upload_collection_form.html.twig' with {
'endpoint_upload': path('_uploader_upload_document'),
'max_filesize': 5,
'accepted_files': 'application/pdf',
} %}
</div>
<button type="submit" class="btn">
Uploads speichern
</button>
{{ form_rest(form) }}
{{ form_end(form) }}
@@ -35,7 +35,6 @@
<div class="pb-4">
{% include '_partials/_upload_collection_form.html.twig' with {
'endpoint_upload': path('_uploader_upload_contract'),
'upload_session_params': null,
'accepted_files': 'image/jpg,image/jpeg,application/pdf',
} %}
</div>