From a22a052c99145f3e6eee7fd0332a0941f2968ce1 Mon Sep 17 00:00:00 2001 From: Wes Holland Date: Sat, 28 Dec 2024 18:25:00 -0600 Subject: [PATCH] Layout changes --- src/app/item.rs | 11 ++-- templates/adjustment-new-stock-form.html | 65 ++++++++++++++---------- templates/adjustment-sale-form.html | 35 ++++++++----- templates/item-stats-fragment.html | 38 ++++++++++++-- templates/item.html | 29 +++++++---- 5 files changed, 119 insertions(+), 59 deletions(-) diff --git a/src/app/item.rs b/src/app/item.rs index e91ad8b..44d3be8 100644 --- a/src/app/item.rs +++ b/src/app/item.rs @@ -50,7 +50,7 @@ pub async fn item(State(db): State, Path(id): Path, user: SessionUser ) -> Result { - let mut item: ItemDisplayItem = inventory_item_get_by_id_with_unit(&db, id).await?.into(); + let item: ItemDisplayItem = inventory_item_get_by_id_with_unit(&db, id).await?.into(); Ok(ItemTemplate { item_id: id, item }.into_response()) } @@ -67,16 +67,13 @@ pub async fn item_count(State(db): State, Path(id): Path) -> Re #[template(path = "item-stats-fragment.html")] struct ItemStatsTemplate { pub item_id: i64, - pub amount: String, - pub unit_abbreviation: String, + pub item: ItemDisplayItem, pub value: String, } pub async fn item_stats(State(db): State, Path(id): Path) -> Result { //TODO This is pretty chatty with the database. Might could cut down the // number of queries - let amount = sum_all_adjustments_for_item(&db, id).await?.to_string(); - - let unit_abbreviation = inventory_item_get_unit_abbreviation(&db, id).await?; + let item: ItemDisplayItem = inventory_item_get_by_id_with_unit(&db, id).await?.into(); let value = get_item_adjustment_valuation_weighted_mean(&db, id) .await? @@ -86,5 +83,5 @@ pub async fn item_stats(State(db): State, Path(id): Path) -> Re let value = int_cents_to_dollars_string(value); - Ok(ItemStatsTemplate { item_id: id, amount, unit_abbreviation, value }.into_response()) + Ok(ItemStatsTemplate { item_id: id, item, value }.into_response()) } diff --git a/templates/adjustment-new-stock-form.html b/templates/adjustment-new-stock-form.html index cc52379..55f0467 100644 --- a/templates/adjustment-new-stock-form.html +++ b/templates/adjustment-new-stock-form.html @@ -1,30 +1,43 @@
-
- - - {% if !amount_error.is_empty() -%} - {{ amount_error }} - {% endif -%} -
-
- - - {% if !price_error.is_empty() -%} - {{ price_error }} - {% endif -%} -
-
- +
+
+ + {% if !amount_error.is_empty() -%} + {{ amount_error }} + {% endif -%} +
+
+ + {% if !price_error.is_empty() -%} + {{ price_error }} + {% endif -%} +
+
+ +
diff --git a/templates/adjustment-sale-form.html b/templates/adjustment-sale-form.html index 6e239f3..b6ed7d5 100644 --- a/templates/adjustment-sale-form.html +++ b/templates/adjustment-sale-form.html @@ -1,18 +1,27 @@
-
- - - {% if !amount_error.is_empty() -%} +
+
+ + + {% if !amount_error.is_empty() -%} {{ amount_error }} - {% endif -%} -
-
- + {% endif -%} +
+
+ +
diff --git a/templates/item-stats-fragment.html b/templates/item-stats-fragment.html index 547d65c..14ccfc9 100644 --- a/templates/item-stats-fragment.html +++ b/templates/item-stats-fragment.html @@ -1,6 +1,36 @@ -
-
Amount in stock: {{amount}} {{unit_abbreviation}}
-
Total Value: {{value}}
-
+
+
+
+
+
+

Stock

+
+
+

{{item.amount}} {{item.display_unit_short}}

+
+
+
+
+
+
+

Reorder Point

+
+
+

{{item.reorder_point}} {{item.display_unit_short}}

+
+
+
+
+
+
+

Value

+
+
+

{{value}}

+
+
+
+
+
diff --git a/templates/item.html b/templates/item.html index 57792a1..67383ff 100644 --- a/templates/item.html +++ b/templates/item.html @@ -4,26 +4,37 @@ {% block content %} +

{{item.name}} {% if !item.active %}Inactive {% endif %}

+
- -
-
Reorder at: {{item.reorder_point}}
-
{% if item.active %}
-
-
-
+ +
+
+
+ +
+
+
-
-
+
+ +
+
+
+ +
+
+
+