aboutsummaryrefslogtreecommitdiff
path: root/src/controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller')
-rw-r--r--src/controller/payments.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/controller/payments.rs b/src/controller/payments.rs
index 883f9e1..66ec056 100644
--- a/src/controller/payments.rs
+++ b/src/controller/payments.rs
@@ -22,6 +22,7 @@ pub async fn table(
let payments =
db::payments::list_for_table(&wallet.pool, &query, PER_PAGE).await;
let max_page = (count.count as f32 / PER_PAGE as f32).ceil() as i64;
+ let users = db::users::list(&wallet.pool).await;
let categories = db::categories::list(&wallet.pool).await;
let mut context = Context::new();
@@ -33,6 +34,7 @@ pub async fn table(
context.insert("query", &query);
context.insert("count", &count.count);
context.insert("total_cost", &count.total_cost);
+ context.insert("users", &users);
context.insert("categories", &categories);
utils::template(
@@ -98,9 +100,11 @@ pub async fn create(
let page = (row - 1) / PER_PAGE + 1;
let query = queries::Payments {
page: Some(page),
- search: None,
+ name: None,
+ cost: None,
frequency: Some(create_payment.frequency),
highlight: Some(id),
+ user: None,
category: None,
};
utils::redirect(&format!(
@@ -176,11 +180,14 @@ pub async fn update(
let row =
db::payments::get_row(&wallet.pool, id, frequency).await;
let page = (row - 1) / PER_PAGE + 1;
+ // TODO: keep name, cost, user and category when updating a line
let query = queries::Payments {
page: Some(page),
- search: None,
+ name: None,
+ cost: None,
frequency: Some(frequency),
highlight: Some(id),
+ user: None,
category: None,
};
utils::redirect(&format!("/{}", queries::payments_url(query)))