49 lines
1.2 KiB
Rust
49 lines
1.2 KiB
Rust
use askama::Template;
|
|
|
|
use crate::{i18n::Locale, tr};
|
|
use crate::ui::{Alert, Nav, render};
|
|
|
|
use super::state::AddLogicPageState;
|
|
|
|
/// GET /admin/logic/new
|
|
#[derive(Template)]
|
|
#[template(path = "pages/add_logic/add_logic.html")]
|
|
struct AddLogicPage<'a> {
|
|
nav: Nav,
|
|
page: &'a AddLogicPageState,
|
|
}
|
|
|
|
pub(crate) fn render_page(page: &AddLogicPageState) -> String {
|
|
render(&AddLogicPage {
|
|
nav: page.nav.clone(),
|
|
page,
|
|
})
|
|
}
|
|
|
|
/// POST /admin/logic — the #submission-status swaps.
|
|
pub(crate) fn render_submission_error(locale: Locale, message: &str) -> String {
|
|
render(&Alert::error(
|
|
locale,
|
|
&tr!(locale, "add-logic-error-title"),
|
|
message,
|
|
))
|
|
}
|
|
|
|
pub(crate) fn render_success(locale: Locale, id: i64, warnings: &str) -> String {
|
|
let message = if warnings.trim().is_empty() {
|
|
tr!(locale, "add-logic-saved", "id" => id.to_string())
|
|
} else {
|
|
tr!(
|
|
locale,
|
|
"add-logic-saved-warnings",
|
|
"id" => id.to_string(),
|
|
"warnings" => warnings.to_string(),
|
|
)
|
|
};
|
|
render(&Alert::success(
|
|
locale,
|
|
&tr!(locale, "add-logic-success-title"),
|
|
&message,
|
|
))
|
|
}
|