Auflisten der Elemente beim Eintragen

fixes: #5
This commit is contained in:
Dietrich 2020-08-07 20:19:40 +02:00
parent 7b0dd543b1
commit 34eed9680b
4 changed files with 91 additions and 34 deletions

Binary file not shown.

View File

@ -127,12 +127,23 @@ fn klasse_view(conn: DbConn, class_id: i32) -> Template {
#[derive(Serialize)] #[derive(Serialize)]
struct AddKlasseContext<'a> { struct AddKlasseContext<'a> {
klassen: Vec<Klasse>,
parent: &'a str, parent: &'a str,
} }
#[get("/add/klasse")] #[get("/add/klasse")]
fn get_klasse_form() -> Template { fn get_klasse_form(conn: DbConn) -> Template {
Template::render("add_klasse_form", AddKlasseContext { parent: "base" }) let klassen = klassen::table
.order(klassen::ordnung.asc())
.load::<Klasse>(&*conn)
.expect("could not load stunden");
Template::render(
"add_klasse_form",
AddKlasseContext {
klassen,
parent: "base",
},
)
} }
#[derive(FromForm, Insertable)] #[derive(FromForm, Insertable)]
@ -155,9 +166,25 @@ fn post_klasse_form(klasse: Form<KlasseForm>, conn: DbConn) -> Result<Redirect,
} }
} }
#[derive(Serialize)]
struct AddStundeContext<'a> {
stunden: Vec<Stunde>,
parent: &'a str,
}
#[get("/add/stunde")] #[get("/add/stunde")]
fn get_stunde_form() -> Template { fn get_stunde_form(conn: DbConn) -> Template {
Template::render("add_stunde_form", AddKlasseContext { parent: "base" }) let stunden = stunden::table
.order(stunden::ordinal.asc())
.load::<Stunde>(&*conn)
.expect("could not load stunden");
Template::render(
"add_stunde_form",
AddStundeContext {
stunden,
parent: "base",
},
)
} }
#[derive(FromForm, Insertable)] #[derive(FromForm, Insertable)]

View File

@ -1,29 +1,44 @@
{{#* inline "page"}} {{#* inline "page"}}
<h1>Klasse hinzu fügen</h1> <h1>Klassen</h1>
<form action="/admin/add/klasse" method="post" accept-charset="utf-8"> <table>
<table> <tr>
<tr> <th>Klasse</th>
<th>Stufe:</th> <th>Titel</th>
<td><input type="number" name="stufe"></td> <th>Priorität</th>
</tr> </tr>
<tr> {{#each klassen}}
<th>Teil:</th> <tr>
<td><input type="text" name="gruppe"></td> <td>{{ this.stufe }}{{this.gruppe}}</td>
</tr> <td>{{this.titel}}</td>
<tr> <td>{{this.ordnung}}</td>
<th>Titel:</th> </tr>
<td><input type="text" name="titel"></td> {{/each}}
</tr> </table>
<tr> <h1>Klasse hinzu fügen</h1>
<th>Ordnung:</th> <form action="/admin/add/klasse" method="post" accept-charset="utf-8">
<td><input type="number" name="ordnung"></td> <table>
</tr> <tr>
<tr> <th>Stufe:</th>
<th></th> <td><input type="number" name="stufe"></td>
<td><input type="submit" value="Klasse Erstellen"></td> </tr>
</tr> <tr>
</table> <th>Teil:</th>
</form> <td><input type="text" name="gruppe"></td>
{{/inline}} </tr>
{{! remove whitespaces with ~ }} <tr>
{{~> (parent)~}} <th>Titel:</th>
<td><input type="text" name="titel"></td>
</tr>
<tr>
<th>Ordnung:</th>
<td><input type="number" name="ordnung"></td>
</tr>
<tr>
<th></th>
<td><input type="submit" value="Klasse Erstellen"></td>
</tr>
</table>
</form>
{{/inline}}
{{! remove whitespaces with ~ }}
{{~> (parent)~}}

View File

@ -1,9 +1,24 @@
{{#* inline "page"}} {{#* inline "page"}}
<h1>Stunden</h1>
<table>
<tr>
<th>Name</th>
<th>Abkürzung</th>
<th>Priorität</th>
</tr>
{{#each stunden}}
<tr>
<td>{{ this.title }}</td>
<td>{{this.short}}</td>
<td>{{this.ordinal}}</td>
</tr>
{{/each}}
</table>
<h1>Stunde hinzu fügen</h1> <h1>Stunde hinzu fügen</h1>
<form action="/admin/add/stunde" method="post" accept-charset="utf-8"> <form action="/admin/add/stunde" method="post" accept-charset="utf-8">
<table> <table>
<tr> <tr>
<th>Titel:</th> <th>Name:</th>
<td><input type="text" name="title"></td> <td><input type="text" name="title"></td>
</tr> </tr>
<tr> <tr>
@ -11,7 +26,7 @@
<td><input type="text" name="short"></td> <td><input type="text" name="short"></td>
</tr> </tr>
<tr> <tr>
<th>Ordnung:</th> <th>Priorität:</th>
<td><input type="number" name="ordinal"></td> <td><input type="number" name="ordinal"></td>
</tr> </tr>
<tr> <tr>