diff --git a/src/main.rs b/src/main.rs
index 876853c..a194c4b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -84,7 +84,7 @@ fn rocket() -> _ {
account::export_data,
],
)
- .mount("/admin", routes![admin::index,])
+ .mount("/admin", routes![admin::index, admin::handle_in_page_forms])
.mount(
"/",
routes![
diff --git a/src/pages.rs b/src/pages.rs
index 8f6c8e7..11e89e3 100644
--- a/src/pages.rs
+++ b/src/pages.rs
@@ -71,7 +71,7 @@ impl<'r> FromRequest<'r> for CommonTemplateState {
/// FakeContext exists to be used as a replacement for Context when reusing a form for creation and edition, to avoid repeating lots of code.
///
/// Note: i made this custom context thingy because i couldn't find a way to create a real context with the right populated data.
-#[derive(Debug, Serialize)]
+#[derive(Debug, Serialize, Default)]
#[serde(crate = "rocket::serde")]
pub struct FakeContext {
/// Values are made to simulate the same structure as the real Context
diff --git a/src/routes/admin.rs b/src/routes/admin.rs
index 33c3679..a79e4b3 100644
--- a/src/routes/admin.rs
+++ b/src/routes/admin.rs
@@ -1,3 +1,7 @@
+use rocket::{
+ form::{Context, Contextual, Form},
+ serde::Serialize,
+};
use rocket_dyn_templates::{context, Template};
use sqlx::Acquire;
@@ -9,14 +13,6 @@ use crate::{
use super::error_handlers::PageResult;
-#[derive(FromForm)]
-pub struct TagHandover<'a> {
- #[field(validate=crate::ids::validate_id())]
- pub tag_id: &'a str,
- #[field(validate=len(..=256))]
- pub dest_account: &'a str,
-}
-
#[get("/")]
pub async fn index(meta: CommonTemplateState, mut db: DollTagsDb, user: Admin) -> PageResult {
let mut trx = db.begin().await?;
@@ -32,3 +28,76 @@ pub async fn index(meta: CommonTemplateState, mut db: DollTagsDb, user: Admin) -
)
.into())
}
+
+#[derive(Debug, FromFormField, Serialize)]
+#[serde(crate = "rocket::serde")]
+pub enum SelectedForm {
+ TagHandover,
+}
+
+#[derive(Debug, FromForm)]
+pub struct Forms<'a> {
+ pub form: SelectedForm,
+ pub tag_handover: Contextual<'a, TagHandover<'a>>,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(crate = "rocket::serde")]
+pub struct Contexts<'a, 'b> {
+ pub form: &'a SelectedForm,
+ pub tag_handover: &'a Context<'b>,
+}
+
+impl<'a, 'b> From<&'a Form