Support entity actions in reports
This commit is contained in:
parent
afb243d36d
commit
f8930bc187
|
|
@ -89,7 +89,7 @@ ReportResult clientReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<ClientReportFields> columns;
|
BuiltList<ClientReportFields> columns;
|
||||||
|
|
||||||
final reportSettings = userCompany.settings?.reportSettings;
|
final reportSettings = userCompany.settings?.reportSettings;
|
||||||
|
|
@ -336,7 +336,7 @@ ReportResult clientReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(client.id);
|
entities.add(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -351,7 +351,6 @@ ReportResult clientReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.client,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ ReportResult creditReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<CreditReportFields> columns;
|
BuiltList<CreditReportFields> columns;
|
||||||
|
|
||||||
final reportSettings = userCompany.settings?.reportSettings;
|
final reportSettings = userCompany.settings?.reportSettings;
|
||||||
|
|
@ -363,7 +363,7 @@ ReportResult creditReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(credit.id);
|
entities.add(credit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -378,7 +378,6 @@ ReportResult creditReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.credit,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ ReportResult documentReport(
|
||||||
BuiltMap<String, UserEntity> userMap,
|
BuiltMap<String, UserEntity> userMap,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<DocumentReportFields> columns;
|
BuiltList<DocumentReportFields> columns;
|
||||||
|
|
||||||
final localization =
|
final localization =
|
||||||
|
|
@ -188,7 +188,7 @@ ReportResult documentReport(
|
||||||
final row = _getRow(quote, document);
|
final row = _getRow(quote, document);
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(document.id);
|
entities.add(document);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -205,7 +205,6 @@ ReportResult documentReport(
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
showTotals: false,
|
showTotals: false,
|
||||||
entityType: EntityType.document,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ ReportResult expenseReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<ExpenseReportFields> columns;
|
BuiltList<ExpenseReportFields> columns;
|
||||||
|
|
||||||
final reportSettings = userCompany.settings?.reportSettings;
|
final reportSettings = userCompany.settings?.reportSettings;
|
||||||
|
|
@ -241,7 +241,7 @@ ReportResult expenseReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(expense.id);
|
entities.add(expense);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,7 +256,6 @@ ReportResult expenseReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.expense,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ ReportResult invoiceReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<InvoiceReportFields> columns;
|
BuiltList<InvoiceReportFields> columns;
|
||||||
|
|
||||||
final reportSettings = userCompany.settings?.reportSettings;
|
final reportSettings = userCompany.settings?.reportSettings;
|
||||||
|
|
@ -419,7 +419,7 @@ ReportResult invoiceReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(invoice.id);
|
entities.add(invoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -434,7 +434,6 @@ ReportResult invoiceReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.invoice,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ ReportResult paymentReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<PaymentReportFields> columns;
|
BuiltList<PaymentReportFields> columns;
|
||||||
|
|
||||||
final reportSettings = userCompany.settings?.reportSettings;
|
final reportSettings = userCompany.settings?.reportSettings;
|
||||||
|
|
@ -233,7 +233,7 @@ ReportResult paymentReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(payment.id);
|
entities.add(payment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,7 +248,6 @@ ReportResult paymentReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.payment,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ ReportResult productReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<ProductReportFields> columns;
|
BuiltList<ProductReportFields> columns;
|
||||||
|
|
||||||
final reportSettings = userCompany.settings?.reportSettings;
|
final reportSettings = userCompany.settings?.reportSettings;
|
||||||
|
|
@ -154,7 +154,7 @@ ReportResult productReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(product.id);
|
entities.add(product);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,7 +169,6 @@ ReportResult productReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.product,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ ReportResult quoteReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<QuoteReportFields> columns;
|
BuiltList<QuoteReportFields> columns;
|
||||||
|
|
||||||
final reportSettings = userCompany.settings?.reportSettings;
|
final reportSettings = userCompany.settings?.reportSettings;
|
||||||
|
|
@ -355,7 +355,7 @@ ReportResult quoteReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(quote.id);
|
entities.add(quote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,7 +370,6 @@ ReportResult quoteReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.quote,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ ReportResult recurringExpenseReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<RecurringExpenseReportFields> columns;
|
BuiltList<RecurringExpenseReportFields> columns;
|
||||||
|
|
||||||
final localization = AppLocalization.of(navigatorKey.currentContext);
|
final localization = AppLocalization.of(navigatorKey.currentContext);
|
||||||
|
|
@ -249,7 +249,7 @@ ReportResult recurringExpenseReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(expense.id);
|
entities.add(expense);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,7 +265,6 @@ ReportResult recurringExpenseReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.recurringExpense,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ ReportResult recurringInvoiceReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<RecurringInvoiceReportFields> columns;
|
BuiltList<RecurringInvoiceReportFields> columns;
|
||||||
|
|
||||||
final localization = AppLocalization.of(navigatorKey.currentContext);
|
final localization = AppLocalization.of(navigatorKey.currentContext);
|
||||||
|
|
@ -400,7 +400,7 @@ ReportResult recurringInvoiceReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(invoice.id);
|
entities.add(invoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,7 +416,6 @@ ReportResult recurringInvoiceReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.recurringInvoice,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -188,14 +188,10 @@ class ReportsScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
final firstEntityId =
|
final firstEntity =
|
||||||
reportResult.entityIds != null && reportResult.entityIds.isNotEmpty
|
reportResult.entities != null && reportResult.entities.isNotEmpty
|
||||||
? reportResult.entityIds.first
|
? reportResult.entities.first
|
||||||
: null;
|
: null;
|
||||||
BaseEntity firstEntity;
|
|
||||||
if (firstEntityId != null) {
|
|
||||||
firstEntity = state.getEntityMap(reportResult.entityType)[firstEntityId];
|
|
||||||
}
|
|
||||||
|
|
||||||
final chartChildren = [
|
final chartChildren = [
|
||||||
AppDropdownButton<String>(
|
AppDropdownButton<String>(
|
||||||
|
|
@ -280,14 +276,14 @@ class ReportsScreen extends StatelessWidget {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 8),
|
padding: const EdgeInsets.only(right: 8),
|
||||||
child: ActionMenuButton(
|
child: ActionMenuButton(
|
||||||
entityActions: firstEntity == null
|
entityActions: firstEntity == null
|
||||||
? null
|
? null
|
||||||
: firstEntity.getActions(
|
: firstEntity.getActions(
|
||||||
userCompany: state.userCompany, multiselect: true),
|
userCompany: state.userCompany, multiselect: true),
|
||||||
entity: firstEntity,
|
entity: firstEntity,
|
||||||
onSelected: (context, action) {
|
onSelected: (context, action) =>
|
||||||
//
|
handleEntitiesActions(reportResult.entities, action),
|
||||||
}),
|
),
|
||||||
),
|
),
|
||||||
if (isMobile(context) || !state.prefState.isHistoryVisible)
|
if (isMobile(context) || !state.prefState.isHistoryVisible)
|
||||||
Builder(
|
Builder(
|
||||||
|
|
@ -670,8 +666,7 @@ class ReportResult {
|
||||||
@required this.allColumns,
|
@required this.allColumns,
|
||||||
@required this.defaultColumns,
|
@required this.defaultColumns,
|
||||||
@required this.data,
|
@required this.data,
|
||||||
this.entityType,
|
this.entities,
|
||||||
this.entityIds,
|
|
||||||
this.showTotals = true,
|
this.showTotals = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -679,8 +674,7 @@ class ReportResult {
|
||||||
final List<String> allColumns;
|
final List<String> allColumns;
|
||||||
final List<String> defaultColumns;
|
final List<String> defaultColumns;
|
||||||
final List<List<ReportElement>> data;
|
final List<List<ReportElement>> data;
|
||||||
final List<String> entityIds;
|
final List<BaseEntity> entities;
|
||||||
final EntityType entityType;
|
|
||||||
final bool showTotals;
|
final bool showTotals;
|
||||||
|
|
||||||
static bool matchField({
|
static bool matchField({
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ ReportResult taskReport(
|
||||||
StaticState staticState,
|
StaticState staticState,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
final List<String> entityIds = [];
|
final List<BaseEntity> entities = [];
|
||||||
BuiltList<TaskReportFields> columns;
|
BuiltList<TaskReportFields> columns;
|
||||||
|
|
||||||
final reportSettings = userCompany.settings?.reportSettings;
|
final reportSettings = userCompany.settings?.reportSettings;
|
||||||
|
|
@ -239,7 +239,7 @@ ReportResult taskReport(
|
||||||
|
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
data.add(row);
|
data.add(row);
|
||||||
entityIds.add(task.id);
|
entities.add(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,7 +253,6 @@ ReportResult taskReport(
|
||||||
defaultColumns:
|
defaultColumns:
|
||||||
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
defaultColumns.map((item) => EnumUtils.parse(item)).toList(),
|
||||||
data: data,
|
data: data,
|
||||||
entityType: EntityType.task,
|
entities: entities,
|
||||||
entityIds: entityIds,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue