From 599955c980c14d7c3e1e0c083a49d76a91596755 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 16 Mar 2022 21:27:15 +0200 Subject: [PATCH] Support entity actions in reports --- lib/data/models/document_model.dart | 4 ++-- lib/redux/document/document_actions.dart | 21 +++++++++++---------- lib/redux/tax_rate/tax_rate_actions.dart | 10 ---------- lib/redux/vendor/vendor_actions.dart | 10 ---------- lib/ui/reports/document_report.dart | 3 +++ 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/lib/data/models/document_model.dart b/lib/data/models/document_model.dart index 32dc4ee6f..81595c35f 100644 --- a/lib/data/models/document_model.dart +++ b/lib/data/models/document_model.dart @@ -216,8 +216,8 @@ abstract class DocumentEntity extends Object } } - if (userCompany.canCreate(EntityType.document)) { - actions.add(EntityAction.clone); + if (!isDeleted && multiselect) { + actions.add(EntityAction.documents); } if (actions.isNotEmpty && actions.last != null) { diff --git a/lib/redux/document/document_actions.dart b/lib/redux/document/document_actions.dart index e08d40dde..24656f533 100644 --- a/lib/redux/document/document_actions.dart +++ b/lib/redux/document/document_actions.dart @@ -265,16 +265,6 @@ class FilterDocumentsByCustom4 implements PersistUI { void handleDocumentAction( BuildContext context, List documents, EntityAction action) { - assert( - [ - EntityAction.restore, - EntityAction.archive, - EntityAction.delete, - EntityAction.toggleMultiselect - ].contains(action) || - documents.length == 1, - 'Cannot perform this action on more than one document'); - if (documents.isEmpty) { return; } @@ -338,6 +328,17 @@ void handleDocumentAction( entities: [document], ); break; + case EntityAction.documents: + store.dispatch( + DownloadDocumentsRequest( + documentIds: documentIds, + completer: snackBarCompleter( + context, + localization.exportedData, + ), + ), + ); + break; } } diff --git a/lib/redux/tax_rate/tax_rate_actions.dart b/lib/redux/tax_rate/tax_rate_actions.dart index 654d334a5..ac74865db 100644 --- a/lib/redux/tax_rate/tax_rate_actions.dart +++ b/lib/redux/tax_rate/tax_rate_actions.dart @@ -216,16 +216,6 @@ class FilterTaxRatesByState implements PersistUI { void handleTaxRateAction( BuildContext context, List taxRates, EntityAction action) { - assert( - [ - EntityAction.restore, - EntityAction.archive, - EntityAction.delete, - EntityAction.toggleMultiselect - ].contains(action) || - taxRates.length == 1, - 'Cannot perform this action on more than one tax rate'); - if (taxRates.isEmpty) { return; } diff --git a/lib/redux/vendor/vendor_actions.dart b/lib/redux/vendor/vendor_actions.dart index 682a6efa7..665276a8a 100644 --- a/lib/redux/vendor/vendor_actions.dart +++ b/lib/redux/vendor/vendor_actions.dart @@ -274,16 +274,6 @@ class FilterVendorsByCustom4 implements PersistUI { void handleVendorAction( BuildContext context, List vendors, EntityAction action) { - assert( - [ - EntityAction.restore, - EntityAction.archive, - EntityAction.delete, - EntityAction.toggleMultiselect - ].contains(action) || - vendors.length == 1, - 'Cannot perform this action on more than one vendor'); - if (vendors.isEmpty) { return; } diff --git a/lib/ui/reports/document_report.dart b/lib/ui/reports/document_report.dart index 67ed68613..27c25d9b3 100644 --- a/lib/ui/reports/document_report.dart +++ b/lib/ui/reports/document_report.dart @@ -161,6 +161,7 @@ ReportResult documentReport( final row = _getRow(client, document); if (row != null) { data.add(row); + entities.add(document); } }); }); @@ -170,6 +171,7 @@ ReportResult documentReport( final row = _getRow(product, document); if (row != null) { data.add(row); + entities.add(document); } }); }); @@ -179,6 +181,7 @@ ReportResult documentReport( final row = _getRow(invoice, document); if (row != null) { data.add(row); + entities.add(document); } }); });