48 lines
3.9 KiB
HTML
48 lines
3.9 KiB
HTML
{# Documenten met versies (contact en relatie). docs = documents_of(…); upload_url = waar nieuwe documenten heen gaan;
|
|
chosen_id = gekozen woning (alleen bij een contact, dan ook "Kies als woning"). #}
|
|
{% macro documents_list(docs, upload_url, chosen_id=None, choose_url=None) %}
|
|
<div class="docs">
|
|
{% for d in docs %}{% set v0 = d.latest %}
|
|
<details class="doc">
|
|
<summary>
|
|
<span class="doc-icon">{% if v0.mime.startswith('image/') %}<img src="{{ url_for('upload_file', name=v0.stored) }}" alt="" loading="lazy">{% elif d.kind == 'woning' %}3D{% else %}{{ v0.original.rsplit('.', 1)[-1][:4] if '.' in v0.original else 'doc' }}{% endif %}</span>
|
|
<span class="doc-main"><span class="doc-title" title="{{ d.title }}">{{ d.title }}</span>
|
|
<span class="muted">{{ DOC_KINDS.get(d.kind, 'Document') }} · versie {{ v0.version }} · {{ v0.created_at|dt('%d-%m-%Y') }}{% if d.kind == 'werk' %} · intern, niet in portaal{% endif %}{% if chosen_id and d.id == chosen_id %} · gekozen woning{% endif %}{% if d.contact_name and not chosen_id %} · {{ d.contact_name }}{% endif %}</span></span>
|
|
</summary>
|
|
<ul class="versions">
|
|
{% for v in d.versions %}
|
|
<li><a href="{{ url_for('design_viewer', fid=v.id) if d.kind == 'woning' else url_for('upload_file', name=v.stored) }}" target="_blank">Versie {{ v.version }}</a>
|
|
<a class="muted" href="{{ url_for('upload_file', name=v.stored) }}" download="{{ v.original }}" title="Downloaden">↓</a>
|
|
<span class="muted">{{ v.created_at|dt }}{% if v.user_name %} · {{ v.user_name }}{% endif %}{% if v.note %} · {{ v.note }}{% endif %}</span>
|
|
<form method="post" action="{{ url_for('file_delete', fid=v.id) }}" onsubmit="return confirm('Versie {{ v.version }} van {{ d.title|e }} verwijderen?{{ ' Dit is de enige versie: het document verdwijnt.' if d.versions|length == 1 }}')"><button class="linkbtn">Verwijderen</button></form>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
<div class="doc-forms">
|
|
{% if d.kind in ('bestand', 'woning') %}
|
|
<form method="post" action="{{ url_for('document_version', did=d.id) }}" enctype="multipart/form-data" class="row g-2">
|
|
<div class="col-12"><input class="form-control form-control-sm" type="file" name="file" required aria-label="Nieuwe versie"{% if d.kind == 'woning' %} accept=".json,application/json"{% endif %}></div>
|
|
<div class="col"><input class="form-control form-control-sm" name="note" placeholder="Wat is er veranderd?" aria-label="Opmerking"></div>
|
|
<div class="col-auto"><button class="btn btn-outline-primary btn-sm">Nieuwe versie</button></div>
|
|
</form>
|
|
{% endif %}
|
|
<div class="actions">
|
|
{% if choose_url and d.kind == 'woning' and d.id != chosen_id %}
|
|
<form method="post" action="{{ choose_url }}" class="inline"><input type="hidden" name="document_id" value="{{ d.id }}"><button class="linkbtn">Kies als woning</button></form>
|
|
{% endif %}
|
|
<form method="post" action="{{ url_for('document_delete', did=d.id) }}" class="inline" onsubmit="return confirm('{{ d.title|e }} met alle versies{{ ' en tekeningen' if d.kind == 'woning' }} verwijderen?')"><button class="linkbtn">Document verwijderen</button></form>
|
|
</div>
|
|
</div>
|
|
</details>
|
|
{% else %}
|
|
<p class="empty">Nog geen documenten.</p>
|
|
{% endfor %}
|
|
</div>
|
|
<form method="post" action="{{ upload_url }}" enctype="multipart/form-data">
|
|
<input class="form-control" type="file" name="files" multiple required aria-label="Documenten kiezen">
|
|
<input class="form-control mt-2" name="note" placeholder="Opmerking (optioneel)" aria-label="Opmerking">
|
|
<div class="actions"><button class="btn btn-outline-primary btn-sm">Uploaden</button></div>
|
|
<p class="muted" style="margin:.5rem 0 0;font-size:.8rem">Elk bestand wordt een nieuw document; een woningontwerp uit Tectum (JSON) wordt een woning. Een nieuwe versie van een bestaand document voeg je toe bij dat document.</p>
|
|
</form>
|
|
{% endmacro %}
|