group teams by routes, sort by last inserted; Fixes #36
All checks were successful
CI/CD Pipeline / test (push) Successful in 4m10s
CI/CD Pipeline / deploy (push) Successful in 2m39s

This commit is contained in:
Philipp Hofer 2025-04-14 14:13:31 +02:00
parent 944d4d8d19
commit f55ce1829d
2 changed files with 47 additions and 42 deletions

View File

@ -87,7 +87,7 @@ impl Team {
pub(crate) async fn all_with_route(db: &SqlitePool, route: &Route) -> Vec<Self> {
sqlx::query_as!(
Team,
"select id, name, notes, amount_people, first_station_id, route_id from team where route_id = ?;",
"SELECT id, name, notes, amount_people, first_station_id, route_id FROM team WHERE route_id = ?;",
route.id
)
.fetch_all(db)

View File

@ -528,32 +528,7 @@ async fn index(State(db): State<Arc<SqlitePool>>, session: Session) -> Markup {
a href="/admin/route" { "Route" }
" sie zugewiesen sind."
}
ol {
@for team in &teams{
li {
a href=(format!("/admin/team/{}", team.id)){
(team.name)
}
a href=(format!("/admin/team/{}/delete", team.id))
onclick="return confirm('Bist du sicher, dass das Team gelöscht werden soll? Das kann _NICHT_ mehr rückgängig gemacht werden.');" {
"🗑️"
}
}
}
}
@if teams.is_empty() {
article class="warning" {
"Es gibt noch keine Teams. "
@if !routes.is_empty() {
"Das kannst du hier ändern ⤵️"
}
}
}
a href="/admin/team/lost" {
button class="outline" {
"Hab ich eine Gruppe verloren? 😳"
}
}
article {
h2 { "Neues Team" }
@if routes.is_empty() {
article class="error" {
@ -583,6 +558,36 @@ async fn index(State(db): State<Arc<SqlitePool>>, session: Session) -> Markup {
}
}
}
}
a href="/admin/team/lost" {
button class="outline" {
"Hab ich eine Gruppe verloren? 😳"
}
}
@for route in &routes {
h2 { (route.name) }
ol {
@for team in &route.teams(&db).await{
li {
a href=(format!("/admin/team/{}", team.id)){
(team.name)
}
a href=(format!("/admin/team/{}/delete", team.id))
onclick="return confirm('Bist du sicher, dass das Team gelöscht werden soll? Das kann _NICHT_ mehr rückgängig gemacht werden.');" {
"🗑️"
}
}
}
}
}
@if teams.is_empty() {
article class="warning" {
"Es gibt noch keine Teams. "
@if !routes.is_empty() {
"Das kannst du hier ändern ⤵️"
}
}
}
};
page(content, session, false).await
}