From 58edaf8cdb5ed87a5e00599330c9d91f621becd4 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Fri, 10 Jan 2025 21:49:11 +0530 Subject: [PATCH] feat: bootstrap ordering templates --- web_ui/src/billing/add_bill.rs | 14 ++-- web_ui/src/billing/add_line_item.rs | 10 +-- web_ui/src/billing/delete_bill.rs | 13 ++-- web_ui/src/billing/delete_line_item.rs | 8 +-- web_ui/src/billing/mod.rs | 6 +- web_ui/src/billing/update_bill.rs | 14 ++-- web_ui/src/billing/update_line_item.rs | 10 +-- web_ui/src/lib.rs | 3 +- web_ui/src/ordering/add_category.rs | 69 +++++++++++++++++++ web_ui/src/ordering/add_customization.rs | 69 +++++++++++++++++++ web_ui/src/ordering/add_kot.rs | 69 +++++++++++++++++++ web_ui/src/ordering/add_line_item.rs | 69 +++++++++++++++++++ web_ui/src/ordering/add_order.rs | 69 +++++++++++++++++++ web_ui/src/ordering/add_product.rs | 69 +++++++++++++++++++ web_ui/src/ordering/delete_kot.rs | 69 +++++++++++++++++++ web_ui/src/ordering/delete_line_item.rs | 69 +++++++++++++++++++ web_ui/src/ordering/delete_order.rs | 69 +++++++++++++++++++ web_ui/src/ordering/mod.rs | 43 ++++++++++++ web_ui/src/ordering/update_category.rs | 69 +++++++++++++++++++ web_ui/src/ordering/update_customization.rs | 69 +++++++++++++++++++ web_ui/src/ordering/update_kot.rs | 69 +++++++++++++++++++ web_ui/src/ordering/update_line_item.rs | 69 +++++++++++++++++++ web_ui/src/ordering/update_order.rs | 69 +++++++++++++++++++ web_ui/src/ordering/update_product.rs | 69 +++++++++++++++++++ web_ui/src/utils.rs | 1 + web_ui/templates/billing/delete_bill.html | 1 - web_ui/templates/ordering/add_category.html | 0 .../templates/ordering/add_customization.html | 0 web_ui/templates/ordering/add_kot.html | 0 web_ui/templates/ordering/add_line_item.html | 0 web_ui/templates/ordering/add_order.html | 0 web_ui/templates/ordering/add_product.html | 0 web_ui/templates/ordering/delete_kot.html | 0 .../templates/ordering/delete_line_item.html | 0 web_ui/templates/ordering/delete_order.html | 0 .../templates/ordering/update_category.html | 0 .../ordering/update_customization.html | 0 web_ui/templates/ordering/update_kot.html | 0 .../templates/ordering/update_line_item.html | 0 web_ui/templates/ordering/update_order.html | 0 web_ui/templates/ordering/update_product.html | 0 41 files changed, 1105 insertions(+), 53 deletions(-) create mode 100644 web_ui/src/ordering/add_category.rs create mode 100644 web_ui/src/ordering/add_customization.rs create mode 100644 web_ui/src/ordering/add_kot.rs create mode 100644 web_ui/src/ordering/add_line_item.rs create mode 100644 web_ui/src/ordering/add_order.rs create mode 100644 web_ui/src/ordering/add_product.rs create mode 100644 web_ui/src/ordering/delete_kot.rs create mode 100644 web_ui/src/ordering/delete_line_item.rs create mode 100644 web_ui/src/ordering/delete_order.rs create mode 100644 web_ui/src/ordering/mod.rs create mode 100644 web_ui/src/ordering/update_category.rs create mode 100644 web_ui/src/ordering/update_customization.rs create mode 100644 web_ui/src/ordering/update_kot.rs create mode 100644 web_ui/src/ordering/update_line_item.rs create mode 100644 web_ui/src/ordering/update_order.rs create mode 100644 web_ui/src/ordering/update_product.rs create mode 100644 web_ui/templates/ordering/add_category.html create mode 100644 web_ui/templates/ordering/add_customization.html create mode 100644 web_ui/templates/ordering/add_kot.html create mode 100644 web_ui/templates/ordering/add_line_item.html create mode 100644 web_ui/templates/ordering/add_order.html create mode 100644 web_ui/templates/ordering/add_product.html create mode 100644 web_ui/templates/ordering/delete_kot.html create mode 100644 web_ui/templates/ordering/delete_line_item.html create mode 100644 web_ui/templates/ordering/delete_order.html create mode 100644 web_ui/templates/ordering/update_category.html create mode 100644 web_ui/templates/ordering/update_customization.html create mode 100644 web_ui/templates/ordering/update_kot.html create mode 100644 web_ui/templates/ordering/update_line_item.html create mode 100644 web_ui/templates/ordering/update_order.html create mode 100644 web_ui/templates/ordering/update_product.html diff --git a/web_ui/src/billing/add_bill.rs b/web_ui/src/billing/add_bill.rs index 800ab3c..a47c144 100644 --- a/web_ui/src/billing/add_bill.rs +++ b/web_ui/src/billing/add_bill.rs @@ -1,4 +1,3 @@ - // SPDX-FileCopyrightText: 2024 Aravinth Manivannan // // SPDX-License-Identifier: AGPL-3.0-or-later @@ -13,15 +12,11 @@ use url::Url; pub use super::*; use crate::utils::*; -pub const ADD_BILL_PAGE: TemplateFile = TemplateFile::new( - "billing.add_bill", - "billing/add_bill.html", -); +pub const ADD_BILL_PAGE: TemplateFile = + TemplateFile::new("billing.add_bill", "billing/add_bill.html"); pub fn register_templates(t: &mut tera::Tera) { - ADD_BILL_PAGE - .register(t) - .expect(ADD_BILL_PAGE.name); + ADD_BILL_PAGE.register(t).expect(ADD_BILL_PAGE.name); } pub struct AddBillPage { @@ -65,5 +60,4 @@ mod tests { .unwrap(); tw.write(); } -} - +} diff --git a/web_ui/src/billing/add_line_item.rs b/web_ui/src/billing/add_line_item.rs index 31653e9..f0afd67 100644 --- a/web_ui/src/billing/add_line_item.rs +++ b/web_ui/src/billing/add_line_item.rs @@ -1,4 +1,3 @@ - // SPDX-FileCopyrightText: 2024 Aravinth Manivannan // // SPDX-License-Identifier: AGPL-3.0-or-later @@ -13,10 +12,8 @@ use url::Url; pub use super::*; use crate::utils::*; -pub const ADD_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new( - "billing.add_line_item", - "billing/add_line_item.html", -); +pub const ADD_LINE_ITEM_PAGE: TemplateFile = + TemplateFile::new("billing.add_line_item", "billing/add_line_item.html"); pub fn register_templates(t: &mut tera::Tera) { ADD_LINE_ITEM_PAGE @@ -65,5 +62,4 @@ mod tests { .unwrap(); tw.write(); } -} - +} diff --git a/web_ui/src/billing/delete_bill.rs b/web_ui/src/billing/delete_bill.rs index af87b11..9c75427 100644 --- a/web_ui/src/billing/delete_bill.rs +++ b/web_ui/src/billing/delete_bill.rs @@ -1,4 +1,3 @@ - // SPDX-FileCopyrightText: 2024 Aravinth Manivannan // // SPDX-License-Identifier: AGPL-3.0-or-later @@ -13,15 +12,11 @@ use url::Url; pub use super::*; use crate::utils::*; -pub const DELETE_BILL_PAGE: TemplateFile = TemplateFile::new( - "billing.delete_bill", - "billing/delete_bill.html", -); +pub const DELETE_BILL_PAGE: TemplateFile = + TemplateFile::new("billing.delete_bill", "billing/delete_bill.html"); pub fn register_templates(t: &mut tera::Tera) { - DELETE_BILL_PAGE - .register(t) - .expect(DELETE_BILL_PAGE.name); + DELETE_BILL_PAGE.register(t).expect(DELETE_BILL_PAGE.name); } pub struct DeleteBillPage { @@ -65,4 +60,4 @@ mod tests { .unwrap(); tw.write(); } -} +} diff --git a/web_ui/src/billing/delete_line_item.rs b/web_ui/src/billing/delete_line_item.rs index ae5b064..cdaad53 100644 --- a/web_ui/src/billing/delete_line_item.rs +++ b/web_ui/src/billing/delete_line_item.rs @@ -12,10 +12,8 @@ use url::Url; pub use super::*; use crate::utils::*; -pub const DELETE_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new( - "billing.delete_line_item", - "billing/delete_line_item.html", -); +pub const DELETE_LINE_ITEM_PAGE: TemplateFile = + TemplateFile::new("billing.delete_line_item", "billing/delete_line_item.html"); pub fn register_templates(t: &mut tera::Tera) { DELETE_LINE_ITEM_PAGE @@ -64,4 +62,4 @@ mod tests { .unwrap(); tw.write(); } -} +} diff --git a/web_ui/src/billing/mod.rs b/web_ui/src/billing/mod.rs index 400cefa..bf2b70e 100644 --- a/web_ui/src/billing/mod.rs +++ b/web_ui/src/billing/mod.rs @@ -3,11 +3,11 @@ // SPDX-License-Identifier: AGPL-3.0-or-later pub mod add_bill; -pub mod update_bill; -pub mod delete_bill; pub mod add_line_item; -pub mod update_line_item; +pub mod delete_bill; pub mod delete_line_item; +pub mod update_bill; +pub mod update_line_item; pub fn register_templates(t: &mut tera::Tera) { for template in [ diff --git a/web_ui/src/billing/update_bill.rs b/web_ui/src/billing/update_bill.rs index de1d001..aace18a 100644 --- a/web_ui/src/billing/update_bill.rs +++ b/web_ui/src/billing/update_bill.rs @@ -1,4 +1,3 @@ - // SPDX-FileCopyrightText: 2024 Aravinth Manivannan // // SPDX-License-Identifier: AGPL-3.0-or-later @@ -13,15 +12,11 @@ use url::Url; pub use super::*; use crate::utils::*; -pub const UPDATE_BILL_PAGE: TemplateFile = TemplateFile::new( - "billing.update_bill", - "billing/update_bill.html", -); +pub const UPDATE_BILL_PAGE: TemplateFile = + TemplateFile::new("billing.update_bill", "billing/update_bill.html"); pub fn register_templates(t: &mut tera::Tera) { - UPDATE_BILL_PAGE - .register(t) - .expect(UPDATE_BILL_PAGE.name); + UPDATE_BILL_PAGE.register(t).expect(UPDATE_BILL_PAGE.name); } pub struct UpdateBillPage { @@ -65,5 +60,4 @@ mod tests { .unwrap(); tw.write(); } -} - +} diff --git a/web_ui/src/billing/update_line_item.rs b/web_ui/src/billing/update_line_item.rs index d23f80b..d5dac6f 100644 --- a/web_ui/src/billing/update_line_item.rs +++ b/web_ui/src/billing/update_line_item.rs @@ -1,4 +1,3 @@ - // SPDX-FileCopyrightText: 2024 Aravinth Manivannan // // SPDX-License-Identifier: AGPL-3.0-or-later @@ -13,10 +12,8 @@ use url::Url; pub use super::*; use crate::utils::*; -pub const UPDATE_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new( - "billing.update_line_item", - "billing/update_line_item.html", -); +pub const UPDATE_LINE_ITEM_PAGE: TemplateFile = + TemplateFile::new("billing.update_line_item", "billing/update_line_item.html"); pub fn register_templates(t: &mut tera::Tera) { UPDATE_LINE_ITEM_PAGE @@ -65,5 +62,4 @@ mod tests { .unwrap(); tw.write(); } -} - +} diff --git a/web_ui/src/lib.rs b/web_ui/src/lib.rs index 9e1b0e4..6f6c2e5 100644 --- a/web_ui/src/lib.rs +++ b/web_ui/src/lib.rs @@ -2,11 +2,12 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +pub mod billing; pub mod identity; pub mod inventory; mod log; +pub mod ordering; mod utils; -pub mod billing; pub fn init() { lazy_static::initialize(&utils::TEMPLATES); diff --git a/web_ui/src/ordering/add_category.rs b/web_ui/src/ordering/add_category.rs new file mode 100644 index 0000000..2ea3f85 --- /dev/null +++ b/web_ui/src/ordering/add_category.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 ADD_CATEGORY_PAGE: TemplateFile = TemplateFile::new( + "ordering.add_category", + "ordering/add_category.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + ADD_CATEGORY_PAGE + .register(t) + .expect(ADD_CATEGORY_PAGE.name); +} + +pub struct AddCategoryPage { + ctx: RefCell, +} + +impl AddCategoryPage { + 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(ADD_CATEGORY_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-add_category.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(AddCategoryPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/add_customization.rs b/web_ui/src/ordering/add_customization.rs new file mode 100644 index 0000000..5166671 --- /dev/null +++ b/web_ui/src/ordering/add_customization.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 ADD_CUSTOMIZATION_PAGE: TemplateFile = TemplateFile::new( + "ordering.add_customization", + "ordering/add_customization.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + ADD_CUSTOMIZATION_PAGE + .register(t) + .expect(ADD_CUSTOMIZATION_PAGE.name); +} + +pub struct AddCustomizationPage { + ctx: RefCell, +} + +impl AddCustomizationPage { + 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(ADD_CUSTOMIZATION_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-add_customization.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(AddCustomizationPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/add_kot.rs b/web_ui/src/ordering/add_kot.rs new file mode 100644 index 0000000..f1ababd --- /dev/null +++ b/web_ui/src/ordering/add_kot.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 ADD_KOT_PAGE: TemplateFile = TemplateFile::new( + "ordering.add_kot", + "ordering/add_kot.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + ADD_KOT_PAGE + .register(t) + .expect(ADD_KOT_PAGE.name); +} + +pub struct AddKotPage { + ctx: RefCell, +} + +impl AddKotPage { + 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(ADD_KOT_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-add_kot.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(AddKotPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/add_line_item.rs b/web_ui/src/ordering/add_line_item.rs new file mode 100644 index 0000000..b6636e2 --- /dev/null +++ b/web_ui/src/ordering/add_line_item.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 ADD_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new( + "ordering.add_line_item", + "ordering/add_line_item.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + ADD_LINE_ITEM_PAGE + .register(t) + .expect(ADD_LINE_ITEM_PAGE.name); +} + +pub struct AddLineItemPage { + ctx: RefCell, +} + +impl AddLineItemPage { + 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(ADD_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-add_line_item.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(AddLineItemPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/add_order.rs b/web_ui/src/ordering/add_order.rs new file mode 100644 index 0000000..5655f78 --- /dev/null +++ b/web_ui/src/ordering/add_order.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 ADD_ORDER_PAGE: TemplateFile = TemplateFile::new( + "ordering.add_order", + "ordering/add_order.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + ADD_ORDER_PAGE + .register(t) + .expect(ADD_ORDER_PAGE.name); +} + +pub struct AddOrderPage { + ctx: RefCell, +} + +impl AddOrderPage { + 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(ADD_ORDER_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-add_order.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(AddOrderPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/add_product.rs b/web_ui/src/ordering/add_product.rs new file mode 100644 index 0000000..43c20d9 --- /dev/null +++ b/web_ui/src/ordering/add_product.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 ADD_PRODUCT_PAGE: TemplateFile = TemplateFile::new( + "ordering.add_product", + "ordering/add_product.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + ADD_PRODUCT_PAGE + .register(t) + .expect(ADD_PRODUCT_PAGE.name); +} + +pub struct AddProductPage { + ctx: RefCell, +} + +impl AddProductPage { + 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(ADD_PRODUCT_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-add_product.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(AddProductPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/delete_kot.rs b/web_ui/src/ordering/delete_kot.rs new file mode 100644 index 0000000..721e347 --- /dev/null +++ b/web_ui/src/ordering/delete_kot.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 DELETE_KOT_PAGE: TemplateFile = TemplateFile::new( + "ordering.delete_kot", + "ordering/delete_kot.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + DELETE_KOT_PAGE + .register(t) + .expect(DELETE_KOT_PAGE.name); +} + +pub struct DeleteKotPage { + ctx: RefCell, +} + +impl DeleteKotPage { + 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(DELETE_KOT_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-delete_kot.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(DeleteKotPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/delete_line_item.rs b/web_ui/src/ordering/delete_line_item.rs new file mode 100644 index 0000000..d646c1c --- /dev/null +++ b/web_ui/src/ordering/delete_line_item.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 DELETE_LINE_ITEM_PAGE: TemplateFile = TemplateFile::new( + "ordering.delete_line_item", + "ordering/delete_line_item.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + DELETE_LINE_ITEM_PAGE + .register(t) + .expect(DELETE_LINE_ITEM_PAGE.name); +} + +pub struct DeleteLineItemPage { + ctx: RefCell, +} + +impl DeleteLineItemPage { + 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(DELETE_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-delete_line_item.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(DeleteLineItemPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/delete_order.rs b/web_ui/src/ordering/delete_order.rs new file mode 100644 index 0000000..47d06e4 --- /dev/null +++ b/web_ui/src/ordering/delete_order.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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 DELETE_ORDER_PAGE: TemplateFile = TemplateFile::new( + "ordering.delete_order", + "ordering/delete_order.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + DELETE_ORDER_PAGE + .register(t) + .expect(DELETE_ORDER_PAGE.name); +} + +pub struct DeleteOrderPage { + ctx: RefCell, +} + +impl DeleteOrderPage { + 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(DELETE_ORDER_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-delete_order.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(DeleteOrderPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/mod.rs b/web_ui/src/ordering/mod.rs new file mode 100644 index 0000000..0e6d015 --- /dev/null +++ b/web_ui/src/ordering/mod.rs @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +pub mod add_category; +pub mod add_customization; +pub mod add_kot; +pub mod add_line_item; +pub mod add_order; +pub mod add_product; +pub mod delete_kot; +pub mod delete_line_item; +pub mod delete_order; +pub mod update_category; +pub mod update_customization; +pub mod update_kot; +pub mod update_line_item; +pub mod update_order; +pub mod update_product; + +pub fn register_templates(t: &mut tera::Tera) { + for template in [ + add_category::ADD_CATEGORY_PAGE, + add_customization::ADD_CUSTOMIZATION_PAGE, + add_kot::ADD_KOT_PAGE, + add_line_item::ADD_LINE_ITEM_PAGE, + add_order::ADD_ORDER_PAGE, + add_product::ADD_PRODUCT_PAGE, + delete_kot::DELETE_KOT_PAGE, + delete_order::DELETE_ORDER_PAGE, + delete_line_item::DELETE_LINE_ITEM_PAGE, + update_category::UPDATE_CATEGORY_PAGE, + update_customization::UPDATE_CUSTOMIZATION_PAGE, + update_kot::UPDATE_KOT_PAGE, + update_line_item::UPDATE_LINE_ITEM_PAGE, + update_order::UPDATE_ORDER_PAGE, + update_product::UPDATE_PRODUCT_PAGE, + ] + .iter() + { + template.register(t).expect(template.name); + } +} diff --git a/web_ui/src/ordering/update_category.rs b/web_ui/src/ordering/update_category.rs new file mode 100644 index 0000000..d9a1419 --- /dev/null +++ b/web_ui/src/ordering/update_category.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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_CATEGORY_PAGE: TemplateFile = TemplateFile::new( + "ordering.update_category", + "ordering/update_category.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + UPDATE_CATEGORY_PAGE + .register(t) + .expect(UPDATE_CATEGORY_PAGE.name); +} + +pub struct UpdateCategoryPage { + ctx: RefCell, +} + +impl UpdateCategoryPage { + 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_CATEGORY_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_category.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(UpdateCategoryPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/update_customization.rs b/web_ui/src/ordering/update_customization.rs new file mode 100644 index 0000000..bfc0547 --- /dev/null +++ b/web_ui/src/ordering/update_customization.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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_CUSTOMIZATION_PAGE: TemplateFile = TemplateFile::new( + "ordering.update_customization", + "ordering/update_customization.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + UPDATE_CUSTOMIZATION_PAGE + .register(t) + .expect(UPDATE_CUSTOMIZATION_PAGE.name); +} + +pub struct UpdateCustomizationPage { + ctx: RefCell, +} + +impl UpdateCustomizationPage { + 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_CUSTOMIZATION_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_customization.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(UpdateCustomizationPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/update_kot.rs b/web_ui/src/ordering/update_kot.rs new file mode 100644 index 0000000..340d649 --- /dev/null +++ b/web_ui/src/ordering/update_kot.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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_KOT_PAGE: TemplateFile = TemplateFile::new( + "ordering.update_kot", + "ordering/update_kot.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + UPDATE_KOT_PAGE + .register(t) + .expect(UPDATE_KOT_PAGE.name); +} + +pub struct UpdateKotPage { + ctx: RefCell, +} + +impl UpdateKotPage { + 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_KOT_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_kot.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(UpdateKotPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/update_line_item.rs b/web_ui/src/ordering/update_line_item.rs new file mode 100644 index 0000000..5c379d9 --- /dev/null +++ b/web_ui/src/ordering/update_line_item.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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, +} + +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(); + } +} + diff --git a/web_ui/src/ordering/update_order.rs b/web_ui/src/ordering/update_order.rs new file mode 100644 index 0000000..f798435 --- /dev/null +++ b/web_ui/src/ordering/update_order.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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_ORDER_PAGE: TemplateFile = TemplateFile::new( + "ordering.update_order", + "ordering/update_order.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + UPDATE_ORDER_PAGE + .register(t) + .expect(UPDATE_ORDER_PAGE.name); +} + +pub struct UpdateOrderPage { + ctx: RefCell, +} + +impl UpdateOrderPage { + 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_ORDER_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_order.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(UpdateOrderPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/ordering/update_product.rs b/web_ui/src/ordering/update_product.rs new file mode 100644 index 0000000..ce9adc0 --- /dev/null +++ b/web_ui/src/ordering/update_product.rs @@ -0,0 +1,69 @@ + +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// 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_PRODUCT_PAGE: TemplateFile = TemplateFile::new( + "ordering.update_product", + "ordering/update_product.html", +); + +pub fn register_templates(t: &mut tera::Tera) { + UPDATE_PRODUCT_PAGE + .register(t) + .expect(UPDATE_PRODUCT_PAGE.name); +} + +pub struct UpdateProductPage { + ctx: RefCell, +} + +impl UpdateProductPage { + 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_PRODUCT_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_product.html"; + + let tw = TestWriterBuilder::default() + .file(FILE.into()) + .contents(UpdateProductPage::page()) + .build() + .unwrap(); + tw.write(); + } +} + diff --git a/web_ui/src/utils.rs b/web_ui/src/utils.rs index 5fd6108..48d5ea9 100644 --- a/web_ui/src/utils.rs +++ b/web_ui/src/utils.rs @@ -49,6 +49,7 @@ lazy_static! { crate::identity::register_templates(&mut tera); crate::inventory::register_templates(&mut tera); crate::billing::register_templates(&mut tera); + crate::ordering::register_templates(&mut tera); tera }; } diff --git a/web_ui/templates/billing/delete_bill.html b/web_ui/templates/billing/delete_bill.html index 6868117..63c716d 100644 --- a/web_ui/templates/billing/delete_bill.html +++ b/web_ui/templates/billing/delete_bill.html @@ -6,7 +6,6 @@ Delete Bill | Vanikam - Token Refreshed
diff --git a/web_ui/templates/ordering/add_category.html b/web_ui/templates/ordering/add_category.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/add_customization.html b/web_ui/templates/ordering/add_customization.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/add_kot.html b/web_ui/templates/ordering/add_kot.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/add_line_item.html b/web_ui/templates/ordering/add_line_item.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/add_order.html b/web_ui/templates/ordering/add_order.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/add_product.html b/web_ui/templates/ordering/add_product.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/delete_kot.html b/web_ui/templates/ordering/delete_kot.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/delete_line_item.html b/web_ui/templates/ordering/delete_line_item.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/delete_order.html b/web_ui/templates/ordering/delete_order.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/update_category.html b/web_ui/templates/ordering/update_category.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/update_customization.html b/web_ui/templates/ordering/update_customization.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/update_kot.html b/web_ui/templates/ordering/update_kot.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/update_line_item.html b/web_ui/templates/ordering/update_line_item.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/update_order.html b/web_ui/templates/ordering/update_order.html new file mode 100644 index 0000000..e69de29 diff --git a/web_ui/templates/ordering/update_product.html b/web_ui/templates/ordering/update_product.html new file mode 100644 index 0000000..e69de29