Merge branch 'master' into gractwo
All checks were successful
mnemo-build-and-publish / gractwo-mnemo-build (push) Successful in 1m13s
All checks were successful
mnemo-build-and-publish / gractwo-mnemo-build (push) Successful in 1m13s
This commit is contained in:
@@ -51,7 +51,10 @@ pub fn pages() -> Router<MnemoState> {
|
|||||||
//
|
//
|
||||||
.route("/quotes", get(quotes::page))
|
.route("/quotes", get(quotes::page))
|
||||||
.route("/quotes/{id}", get(quotes::id::page))
|
.route("/quotes/{id}", get(quotes::id::page))
|
||||||
.route("/quotes/{id}/delete", post(quotes::id::delete))
|
.route(
|
||||||
|
"/quotes/{id}/delete",
|
||||||
|
get(quotes::id::delete_confirm).post(quotes::id::delete),
|
||||||
|
)
|
||||||
.route("/quotes/add", get(quotes::add::page))
|
.route("/quotes/add", get(quotes::add::page))
|
||||||
.route("/quotes/add-form", post(quotes::add::form))
|
.route("/quotes/add-form", post(quotes::add::form))
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -53,12 +53,62 @@ pub async fn page(
|
|||||||
span class="scale-[.75]" {(PreEscaped(icons::PEN))}
|
span class="scale-[.75]" {(PreEscaped(icons::PEN))}
|
||||||
"Edit"
|
"Edit"
|
||||||
}
|
}
|
||||||
|
a href=(format!("/quotes/{id}/delete")) class="px-2 py-1 cursor-pointer border rounded flex flex-row gap-1 bg-pink-400/10 border-pink-400/25 hover:bg-pink-400/20 hover:border-pink-400/45" {
|
||||||
|
span class="scale-[.75]" {(PreEscaped(icons::TRASH))}
|
||||||
|
"Delete"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} @else {
|
||||||
|
"Failed to fetch quote. Are you sure it exists?"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.into_response())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn delete_confirm(
|
||||||
|
State(state): State<MnemoState>,
|
||||||
|
Path(id): Path<Uuid>,
|
||||||
|
req: Request,
|
||||||
|
) -> Result<Response, CompositeError> {
|
||||||
|
let mut conn = state.pool.acquire().await?;
|
||||||
|
let u = match User::authenticate(&mut *conn, req.headers()).await? {
|
||||||
|
Some(u) => u,
|
||||||
|
None => return Ok(Redirect::to(&format!("/login?r={}", req.uri().path())).into_response()),
|
||||||
|
};
|
||||||
|
let q = Quote::get_by_id(&mut conn, id).await;
|
||||||
|
|
||||||
|
Ok(base(
|
||||||
|
"Delete Quote | Mnemosyne",
|
||||||
|
html!(
|
||||||
|
(nav(&mut conn, Some(&u), req.uri().path()).await)
|
||||||
|
|
||||||
|
div class="max-w-4xl mx-auto px-2" {
|
||||||
|
div class="my-4 flex justify-between" {
|
||||||
|
p class="flex items-center gap-2 text-neutral-500" {
|
||||||
|
(PreEscaped(icons::TRASH))
|
||||||
|
span class="font-lora" {"Deleting quote of ID " (id)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@if let Ok(q) = q {
|
||||||
|
div class="border border-pink-400/25 bg-pink-400/10 rounded-md p-3 mb-4" {
|
||||||
|
p class="flex flex-wrap items-center gap-2 text-pink-200" {
|
||||||
|
span class="font-semibold" {"Are you sure you want to delete this quote?"}
|
||||||
|
span class="text-pink-300/80" {"This cannot be undone."}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(quote(&q))
|
||||||
|
div class="flex flex-row w-full flex-wrap justify-start gap-2 mt-2" {
|
||||||
form method="post" action=(format!("/quotes/{id}/delete")) {
|
form method="post" action=(format!("/quotes/{id}/delete")) {
|
||||||
button type="submit" class="px-2 py-1 border rounded flex flex-row gap-1 bg-pink-400/10 border-pink-400/25 hover:bg-pink-400/20 hover:border-pink-400/45" {
|
button type="submit" class="px-2 py-1 cursor-pointer border rounded flex flex-row gap-1 bg-pink-400/10 border-pink-400/25 hover:bg-pink-400/20 hover:border-pink-400/45" {
|
||||||
span class="scale-[.75]" {(PreEscaped(icons::TRASH))}
|
span class="scale-[.75]" {(PreEscaped(icons::TRASH))}
|
||||||
"Delete"
|
"Delete"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
a href=(format!("/quotes/{id}")) class="px-2 py-1 border rounded flex flex-row gap-1 bg-neutral-200/5 border-neutral-200/25 hover:bg-neutral-200/15 hover:border-neutral-200/45" {
|
||||||
|
"Cancel"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} @else {
|
} @else {
|
||||||
"Failed to fetch quote. Are you sure it exists?"
|
"Failed to fetch quote. Are you sure it exists?"
|
||||||
|
|||||||
Reference in New Issue
Block a user