web routing is POG now

This commit is contained in:
Priec
2026-08-12 23:40:14 +02:00
parent 10c8235420
commit f8e483efa8
28 changed files with 1015 additions and 697 deletions

View File

@@ -1,9 +1,18 @@
//! The table-definition workspace: pick a profile and a table, then do
//! anything the `TableDefinition` service offers to it.
//! What can be done to a table once it exists, as one page per decision.
//!
//! Creating a table is the one operation that lives elsewhere — it is a form
//! long enough to want its own page, `pages/add_table` — and the workspace
//! links to it with the chosen profile already filled in.
//! Adding columns, dropping the table, copying its profile, generating tables
//! from a template and reading the rename history are five different jobs, and
//! they used to be five panels stacked on one `/admin/table-definition`
//! workspace — which meant that after creating a table you landed on a screen
//! where finding the delete form meant scrolling past five other forms.
//!
//! They are now five routes, and the browsing they all needed — which profile,
//! which table — is done in the admin panel, which was already a three-pane
//! browser for exactly that. Every page here is entered with its selection in
//! the query string, and links back to the panel it came from.
//!
//! Creating a table is still elsewhere: it is a form long enough to want its
//! own page, `pages/add_table`.
mod loader;
mod logic;
@@ -12,6 +21,7 @@ mod ui;
use axum::{
Router,
response::Redirect,
routing::{get, post},
};
@@ -19,18 +29,28 @@ use crate::AppState;
pub(crate) fn router() -> Router<AppState> {
Router::new()
.route("/admin/table-definition", get(logic::page))
.route("/admin/table-definition/workspace", get(logic::workspace))
// Table-scoped.
.route("/admin/tables/columns", get(logic::columns_page))
.route("/admin/tables/columns", post(logic::add_columns))
.route(
"/admin/table-definition/columns/builder",
"/admin/tables/columns/builder",
post(logic::update_columns),
)
.route("/admin/table-definition/columns", post(logic::add_columns))
.route("/admin/table-definition/rename", post(logic::rename_column))
.route("/admin/table-definition/delete", post(logic::delete_table))
.route("/admin/table-definition/copy", post(logic::copy_profile))
.route("/admin/tables/rename", post(logic::rename_column))
.route("/admin/tables/delete", get(logic::delete_page))
.route("/admin/tables/delete", post(logic::delete_table))
// Profile-scoped.
.route("/admin/profiles/copy", get(logic::copy_page))
.route("/admin/profiles/copy", post(logic::copy_profile))
.route("/admin/profiles/history", get(logic::history_page))
.route(
"/admin/table-definition/invoice-template",
post(logic::create_from_invoice_template),
"/admin/tables/from-template",
get(logic::template_page).post(logic::create_from_invoice_template),
)
// The workspace these came out of. Anything still pointing at it —
// a bookmark, an old link — lands on the browser instead.
.route(
"/admin/table-definition",
get(|| async { Redirect::permanent("/admin") }),
)
}