diff options
| author | Joe Carstairs <me@joeac.net> | 2026-02-22 08:49:25 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-02-22 08:49:25 +0000 |
| commit | 6137e4bec5fd7f34c66162b32424343a30b3c5f2 (patch) | |
| tree | ccaa976de636aedf03a8fa7cfea63be8e6d811d2 /schist_desktop_gui/src/gui/components/transactions_view | |
| parent | 376ad725248c9c50596adb8bbebab9d6c5c9dea7 (diff) | |
task-085: formats bucket cells
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() |
