summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/transactions_view.rs
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-02-12 20:00:26 +0000
committerJoe Carstairs <me@joeac.net>2026-02-12 20:00:26 +0000
commit413afad1fdf1d15fefc1b709f2eba1332a110608 (patch)
treed11385e53035a1d517154f25c72cd64ca9815d1e /schist_desktop_gui/src/gui/components/transactions_view.rs
parentb3f91aef7c9673c180690f6e22984d50e0dbeecf (diff)
task-085: uses new iced::widget::Table instead of home-made widget
Diffstat (limited to 'schist_desktop_gui/src/gui/components/transactions_view.rs')
-rw-r--r--schist_desktop_gui/src/gui/components/transactions_view.rs52
1 files changed, 3 insertions, 49 deletions
diff --git a/schist_desktop_gui/src/gui/components/transactions_view.rs b/schist_desktop_gui/src/gui/components/transactions_view.rs
index 51877cf..491049d 100644
--- a/schist_desktop_gui/src/gui/components/transactions_view.rs
+++ b/schist_desktop_gui/src/gui/components/transactions_view.rs
@@ -6,14 +6,13 @@ use itertools::Itertools;
use schist_models::{Account, Transaction};
use crate::{
- gui::components::{navigation, table, AccountNavigationEntry, Navigation, Table},
+ gui::components::{navigation, AccountNavigationEntry, Navigation},
traits::Component,
};
#[derive(Clone, Debug)]
pub struct TransactionsView {
navigation: Navigation<AccountNavigationEntry>,
- table: Table<i32>,
transactions_by_account_id: HashMap<i32, Vec<Transaction>>,
}
@@ -24,7 +23,6 @@ pub enum Message {
SelectPrevAccount,
SetAccounts(Vec<Account>),
SetTransactions(Vec<Transaction>),
- TableMessage(table::Message),
}
pub enum Action {
@@ -42,55 +40,13 @@ impl TransactionsView {
account_navigation_entries.first().cloned(),
account_navigation_entries,
);
- let mut transactions_view = Self {
+ Self {
navigation: navigation,
- table: Table::default(),
transactions_by_account_id: transactions
.into_iter()
.cloned()
.into_group_map_by(|t| t.account_id),
- };
- transactions_view.refresh_table();
- transactions_view
- }
-
- fn refresh_table(&mut self) {
- self.table =
- Table {
- cols: vec![
- table::Column::new(0, "Date"),
- table::Column::new(1, "Bucket"),
- table::Column::new(2, "Payee").mul_width(2.0),
- table::Column::new(3, "Quantity").mul_width(0.67),
- table::Column::new(4, "Balance").mul_width(0.67),
- ],
- rows: self.navigation.active_option.clone().map_or_else(
- Vec::new,
- |AccountNavigationEntry { account, .. }| {
- self.transactions_by_account_id
- .get(&account.id)
- .cloned()
- .unwrap_or_else(Vec::new)
- .iter()
- .map(|t| {
- HashMap::from([
- (0, table::Value::String(t.date.to_string())),
- (
- 1,
- table::Value::String(t.bucket_id.map_or_else(
- || String::from("None"),
- |id| id.to_string(),
- )),
- ),
- (2, table::Value::String(t.counterparty.clone())),
- (3, table::Value::Currency(t.amount)),
- (4, table::Value::String(String::from("TODO"))),
- ])
- })
- .collect()
- },
- ),
- };
+ }
}
}
@@ -110,7 +66,6 @@ impl<'a> Component<'a, Message, Action> for TransactionsView {
Message::SetTransactions(transactions) => {
self.transactions_by_account_id =
transactions.into_iter().into_group_map_by(|t| t.account_id);
- self.refresh_table();
Action::None
}
@@ -128,7 +83,6 @@ impl TransactionsView {
) -> Action {
match self.navigation.update(message) {
navigation::Action::ActivateOption(_) | navigation::Action::SelectOption(_) => {
- self.refresh_table();
Action::None
}
navigation::Action::None => Action::None,