From 6e695bf7a0253b4f6d1db78fa4310616d8a1357f Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 10 Oct 2021 19:27:22 +0200 Subject: Search by name, cost and user --- src/controller/payments.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/controller') 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))) -- cgit v1.2.3