added modal dialog with prepopulated selects

This commit is contained in:
eclipse 2025-04-18 19:42:25 +02:00
parent b75f96e4b0
commit 83fe0e949a
2 changed files with 58 additions and 2 deletions

View File

@ -5,6 +5,11 @@
{% block heading %}Texte{% endblock heading %}
{% block content %}
<article>
<section>
<button commandfor="textmodal" command="show-modal" onclick="textmodal.showModal()">Neuer Text …</button>
</section>
<table>
<thead>
<tr>
@ -27,4 +32,51 @@
{% endfor %}
</tbody>
</table>
<dialog aria-labelledby="dialog-heading" id="textmodal">
<article>
<header>
<button aria-label="close" rel="prev" onclick="textmodal.close()"></button>
<h1 id="dialog-heading">Neuer Text</h1>
</header>
<form>
<label>
Titel (erforderlich)
<input name="text_titel" placeholder="Titel" required />
</label>
<label>
Untertitel
<input name="text_untertitel" placeholder="Untertitel" />
</label>
<label>
Reihe
<select name="text_reihe" aria-label="Der Text gehört zur Reihe …">
<option selected value="">keine Reihe</option>
{% for r in reihen %}<option value="{{ r['ID'] }}">{{ r['Reihentitel']}}</option>
{% endfor %}
</select>
</label>
<label>
Textform (erforderlich)
<select name="text_textform" aria-label="Textform" required>
<option selected disabled value="">Textform auswählen …</option>
{% for tf in textformen %}<option value="{{ tf['ID'] }}">{{ tf['Textform']}}</option>
{% endfor %}
</select>
</label>
<label>
Sprache (erforderlich)
<select name="text_sprache" aria-label="Sprache des Textes" required>
<option selected disabled value="">Sprache auswählen …</option>
{% for s in sprachen %}<option value="{{ s['ID'] }}">{{ s['Sprache']}}</option>
{% endfor %}
</select>
</label>
<button type="submit" formmethod="post" formaction="">OK</button>
<button aria-label="close" formmethod="dialog" formnovalidate>Abbrechen</button>
</form>
</article>
</dialog>
</article>
{% endblock content %}

View File

@ -8,7 +8,7 @@ def home():
return render_template("views/home.html")
@bp.route("/texte")
def texte():
def texte_list():
db = get_db()
rows = db.execute(
"""SELECT
@ -22,4 +22,8 @@ def texte():
LEFT JOIN Textformen f ON t.Textform = f.ID
LEFT JOIN Sprachen s ON t.Originalsprache = s.ID;"""
).fetchall()
return render_template("views/texte.html", rows=rows)
reihen = db.execute("SELECT ID, Reihentitel from Reihen").fetchall()
textformen = db.execute("SELECT ID, Textform from Textformen").fetchall()
sprachen = db.execute("SELECT ID, Sprache from Sprachen").fetchall()
return render_template("views/texte.html", rows=rows, reihen=reihen, textformen=textformen, sprachen=sprachen)