diff options
Diffstat (limited to 'schist_desktop_gui/src/gui/components/transactions_view')
| -rw-r--r-- | schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs b/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs index 7ceadda..f43ee48 100644 --- a/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs +++ b/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs @@ -9,7 +9,7 @@ use iced::{ }, Element, Length, }; -use schist_models::Transaction; +use schist_models::{Bucket, Transaction}; use crate::{gui::components::Text, style::SPACING_LG, traits::Viewable}; @@ -26,7 +26,7 @@ impl<'a> Viewable<'a, Message> for TransactionsView { ), column( Text::default("Bucket").width(iced::Length::Fixed(128.0)), - |t: Transaction| view_bucket_cell(t), + |t: Transaction| view_bucket_cell(t, &self.buckets), ), column( Text::default("Payee").width(iced::Length::Fixed(256.0)), @@ -76,13 +76,16 @@ fn view_date_cell(transaction: Transaction) -> Text { .clip() } -fn view_bucket_cell(t: Transaction) -> Text { - Text::default( - t.bucket_id - .map(|id| id.to_string()) - .unwrap_or(String::from("None")) - .as_str(), - ) +fn view_bucket_cell(t: Transaction, buckets: &[Bucket]) -> Text { + (t.bucket_id.map_or_else( + || Text::default("None").italic(), + |id| { + buckets.iter().find(|b| b.id == id).map_or_else( + || Text::default(format!("<{}>", id).as_str()).italic(), + |b| Text::default(&b.name), + ) + }, + )) .width(iced::Length::Fixed(128.0)) .small() .clip() |
