Support entity actions in reports

This commit is contained in:
Hillel Coren 2022-03-16 21:27:15 +02:00
parent 15bcca30bb
commit 599955c980
5 changed files with 16 additions and 32 deletions

View File

@ -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) {

View File

@ -265,16 +265,6 @@ class FilterDocumentsByCustom4 implements PersistUI {
void handleDocumentAction(
BuildContext context, List<BaseEntity> 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<Null>(
context,
localization.exportedData,
),
),
);
break;
}
}

View File

@ -216,16 +216,6 @@ class FilterTaxRatesByState implements PersistUI {
void handleTaxRateAction(
BuildContext context, List<BaseEntity> 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;
}

View File

@ -274,16 +274,6 @@ class FilterVendorsByCustom4 implements PersistUI {
void handleVendorAction(
BuildContext context, List<BaseEntity> 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;
}

View File

@ -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);
}
});
});