diff options
author | Joris | 2021-10-10 19:27:22 +0200 |
---|---|---|
committer | Joris | 2021-10-10 21:21:34 +0200 |
commit | 6e695bf7a0253b4f6d1db78fa4310616d8a1357f (patch) | |
tree | a5b9f30b74a6914336993f93504df3b42fccb933 /src/controller | |
parent | 8ccd762bfc3d7da2716749d709cf5cc216882a23 (diff) |
Search by name, cost and user
Diffstat (limited to 'src/controller')
-rw-r--r-- | src/controller/payments.rs | 11 |
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))) |