From c048fdcce493d54571fbae6b69eb2d628b59bdd9 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 12 Aug 2022 09:53:07 +0300 Subject: [PATCH] Dashboard overview --- lib/ui/dashboard/dashboard_panels.dart | 33 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/ui/dashboard/dashboard_panels.dart b/lib/ui/dashboard/dashboard_panels.dart index 34f5fe274..6355de62b 100644 --- a/lib/ui/dashboard/dashboard_panels.dart +++ b/lib/ui/dashboard/dashboard_panels.dart @@ -998,8 +998,33 @@ class _DashboardTotalsSettingsState extends State<_DashboardTotalsSettings> { final localization = AppLocalization.of(context); final store = StoreProvider.of(context); final state = store.state; + final company = state.company; final settings = state.dashboardUIState.settings; + final List> items = []; + final fieldMap = { + EntityType.invoice: [ + DashboardUISettings.FIELD_ACTIVE_INVOICES, + DashboardUISettings.FIELD_OUTSTANDING_INVOICES, + ], + EntityType.payment: [ + DashboardUISettings.FIELD_COMPLETED_PAYMENTS, + DashboardUISettings.FIELD_REFUNDED_PAYMENTS, + ] + }; + + fieldMap.forEach((entityType, fields) { + fields.forEach((field) { + if (company.isModuleEnabled(entityType) && + !settings.totalFields.contains(field)) { + items.add(DropdownMenuItem( + child: Text(localization.lookup(field)), + value: field, + )); + } + }); + }); + return Column( children: [ for (var field in settings.totalFields) @@ -1027,13 +1052,7 @@ class _DashboardTotalsSettingsState extends State<_DashboardTotalsSettings> { setState(() {}); }, hint: Text(localization.addField), - items: [ - DropdownMenuItem( - child: Text(localization - .lookup(DashboardUISettings.FIELD_ACTIVE_INVOICES)), - value: DashboardUISettings.FIELD_ACTIVE_INVOICES, - ), - ].toList(), + items: items, ), ), ),