simplified JS code, removed unused HTML

This commit is contained in:
eclipse 2025-05-06 19:43:18 +02:00
parent ef7947ff41
commit aabded298d

View File

@ -4,8 +4,6 @@
{% block script %}
<script>
const SCRIPT_ROOT = {{ request.script_root | tojson }};
window.onload = function () {
// initialise DataTable
let table = new DataTable('#werk-table', {
@ -14,12 +12,12 @@
});
deRole("#werk-table");
// create and append "New"-button to
// create "New"-button and append it to the <div> containing the DataTables search field
let a = document.createElement("a");
a.id = "create-button";
a.setAttribute("title", "Werk hinzufügen");
a.setAttribute("role", "button");
a.setAttribute("href", `${SCRIPT_ROOT}/werk/read/0`);
a.setAttribute("href", "{{ url_for('werk.read', id=0) }}"); // there's no DB entry with id = 0, therefore the backend knows to serve an empty form
a.innerHTML = "Neu …";
document.getElementById("werk-table_wrapper").firstElementChild.firstElementChild.appendChild(a);
}
@ -57,120 +55,4 @@
{% endfor %}
</tbody>
</table>
<dialog aria-labelledby="dialog-heading" id="werkmodal">
<article>
<form id="werk_detail_form" method="post" enctype="multipart/form-data" action="#" readonly>
<header>
<button aria-label="close" rel="prev" onclick="werkmodal.close()"></button>
<h1 id="dialog-heading">#</h1>
</header>
<fieldset>
<article>
<label>
Titel (erforderlich)
<input id="form_Titel" name="form_Titel" aria-label="Titel" placeholder="Titel" required autofocus />
</label>
</article>
<article>
<details name="werk" open>
<summary>Untertitel und Werksform</summary>
<label>
Untertitel
<input id="form_Untertitel" name="form_Untertitel" aria-label="Untertitel" placeholder="Untertitel" />
</label>
<label>
Werksform (erforderlich)
<select id="form_Werksform" name="form_Werksform" aria-label="Werksform" required>
<option value="">keine Werksform</option>
{% for wf in werksformen %}<option value="{{ wf.ID }}">{{ wf.Werksform }}</option>{% endfor %}
</select>
</label>
</details>
</article>
<article>
<details name="werk">
<summary>Verlag und Reihe</summary>
<label>
Verlag
<select id="form_Verlag" name="form_Verlag" aria-label="Verlag">
<option selected value="">kein Verlag</option>
{% for v in verlage %}<option value="{{ v.ID }}">{{ v.Verlag }}</option>{% endfor %}
</select>
</label>
<label>
Reihe
<select id="form_Reihe" name="form_Reihe" aria-label="Der Text gehört zur Reihe …">
<option value="" >keine Reihe</option>
{% for r in reihen %}<option value="{{ r.ID }}">{{ r.Titel }}</option>{% endfor %}
</select>
</label>
<label>
Reihennummer
<input id="form_Reihennummer" name="form_Reihennummer" aria-label="Reihennummer" placeholder="keine Reihennummer" />
</label>
</details>
</article>
<article>
<details name="werk">
<summary>Preis und Erscheinungsdatum</summary>
<label>
Preis
<input id="form_Preis" name="form_Preis" aria-label="Preis" placeholder="kein Preis" />
</label>
<label>
Erscheinungsdatum
<input type="date" id="form_Erscheinungsdatum" name="form_Erscheinungsdatum" aria-label="Erscheinungsdatum" placeholder="kein Datum" />
</label>
</details>
</article>
<article>
<details name="werk">
<summary>ISBNs</summary>
<label>
ISBN-13
<input id="form_ISBN_13" name="form_ISBN_13" aria-label="ISBN-13" placeholder="keine ISBN-13" />
</label>
<label>
ISBN-10
<input id="form_ISBN_10" name="form_ISBN_10" aria-label="ISBN-10" placeholder="keine ISBN-10" />
</label>
<label>
ISSN
<input id="form_ISSN" name="form_ISSN" aria-label="ISSN" placeholder="keine ISSN" />
</label>
</details>
</article>
<article>
<details name="werk">
<summary>Titelbild und Klappentext</summary>
<label>
Titelbild
<input type="file" id="form_Titelbild" name="form_Titelbild" aria-label="Titelbild" placeholder="kein Titelbild" />
</label>
<label>
Klappentext
<textarea id="form_Klappentext" name="form_Klappentext" aria-label="Klappentext" placeholder="kein Klappentext" rows="10"></textarea>
</label>
<label>
Anmerkungen
<textarea id="form_Anmerkungen" name="form_Anmerkungen" aria-label="Anmerkungen" placeholder="keine Anmerkungen" rows="10"></textarea>
</label>
</details>
</article>
</fieldset>
<footer class="grid">
<button id="form_submit" type="submit" formmethod="post" formaction="{{ url_for('werk.create') }}">OK</button>
<button class="secondary" aria-label="close" formmethod="dialog" formnovalidate>Abbrechen</button>
</footer>
</form>
</article>
</dialog>
{% endblock content %}