67 lines
1.4 KiB
Rust
67 lines
1.4 KiB
Rust
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
use std::cell::RefCell;
|
|
|
|
use derive_builder::*;
|
|
use derive_more::*;
|
|
use serde::*;
|
|
use tera::Context;
|
|
use url::Url;
|
|
|
|
pub use super::*;
|
|
use crate::utils::*;
|
|
|
|
pub const UPDATE_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new(
|
|
"ordering.update_line_item",
|
|
"ordering/update_line_item.html",
|
|
);
|
|
|
|
pub fn register_templates(t: &mut tera::Tera) {
|
|
UPDATE_LINE_ITEM_PAGE
|
|
.register(t)
|
|
.expect(UPDATE_LINE_ITEM_PAGE.name);
|
|
}
|
|
|
|
pub struct UpdateLineItemPage {
|
|
ctx: RefCell<Context>,
|
|
}
|
|
|
|
impl UpdateLineItemPage {
|
|
pub fn new() -> Self {
|
|
let mut ctx = context();
|
|
|
|
//ctx.insert(PAYLOAD_KEY, p);
|
|
|
|
let ctx = RefCell::new(ctx);
|
|
Self { ctx }
|
|
}
|
|
|
|
pub fn render(&self) -> String {
|
|
TEMPLATES
|
|
.render(UPDATE_LINE_ITEM_PAGE.name, &self.ctx.borrow())
|
|
.unwrap()
|
|
}
|
|
|
|
pub fn page() -> String {
|
|
let p = Self::new();
|
|
p.render()
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn render_page_and_write() {
|
|
const FILE: &str = "./tmp/ordering-update_line_item.html";
|
|
|
|
let tw = TestWriterBuilder::default()
|
|
.file(FILE.into())
|
|
.contents(UpdateLineItemPage::page())
|
|
.build()
|
|
.unwrap();
|
|
tw.write();
|
|
}
|
|
}
|