From af726ea3f7923fcd4db2cb53aec02b5421ef3db7 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 6 Aug 2020 17:46:05 +0300 Subject: [PATCH] Client/product documents --- lib/data/models/entities.dart | 14 ++++++++++++-- lib/ui/reports/document_report.dart | 16 +++++++++++++++- lib/ui/reports/reports_screen.dart | 19 +++++++++++++++++++ lib/utils/strings.dart | 6 +++--- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/lib/data/models/entities.dart b/lib/data/models/entities.dart index 8a0d875a7..fe35653f4 100644 --- a/lib/data/models/entities.dart +++ b/lib/data/models/entities.dart @@ -275,8 +275,8 @@ abstract class BaseEntity implements SelectableEntity { ReportStringValue getReportString({String value}) => ReportStringValue(entityId: id, entityType: entityType, value: value); - ReportEntityTypeValue getReportEntityType() => - ReportEntityTypeValue(entityId: id, entityType: entityType, value: entityType); + ReportEntityTypeValue getReportEntityType() => ReportEntityTypeValue( + entityId: id, entityType: entityType, value: entityType); ReportBoolValue getReportBool({bool value}) => ReportBoolValue(entityId: id, entityType: entityType, value: value); @@ -298,6 +298,16 @@ abstract class BaseEntity implements SelectableEntity { currencyId: currencyId, formatNumberType: formatNumberType); + ReportIntValue getReportInt( + {int value, + String currencyId, + FormatNumberType formatNumberType}) => + ReportIntValue( + entityId: id, + entityType: entityType, + value: value, + ); + List getActions( {UserCompanyEntity userCompany, ClientEntity client, diff --git a/lib/ui/reports/document_report.dart b/lib/ui/reports/document_report.dart index c90e76a8b..9926c4913 100644 --- a/lib/ui/reports/document_report.dart +++ b/lib/ui/reports/document_report.dart @@ -13,6 +13,9 @@ import 'package:memoize/memoize.dart'; enum DocumentReportFields { name, + size, + width, + height, file_type, record_type, record_name, @@ -117,6 +120,15 @@ ReportResult documentReport( case DocumentReportFields.updated_at: value = convertTimestampToDateString(document.updatedAt); break; + case DocumentReportFields.size: + value = document.size; + break; + case DocumentReportFields.width: + value = document.width; + break; + case DocumentReportFields.height: + value = document.height; + break; } if (!ReportResult.matchField( @@ -131,7 +143,9 @@ ReportResult documentReport( if (value.runtimeType == bool) { row.add(entity.getReportBool(value: value)); - } else if (value.runtimeType == double || value.runtimeType == int) { + } else if (value.runtimeType == int) { + row.add(entity.getReportInt(value: value)); + } else if (value.runtimeType == double) { row.add(entity.getReportNumber(value: value)); } else if (value.runtimeType == EntityType) { row.add(entity.getReportEntityType()); diff --git a/lib/ui/reports/reports_screen.dart b/lib/ui/reports/reports_screen.dart index cab044998..4dc84195e 100644 --- a/lib/ui/reports/reports_screen.dart +++ b/lib/ui/reports/reports_screen.dart @@ -1320,6 +1320,25 @@ class ReportAgeValue extends ReportElement { } } +class ReportIntValue extends ReportElement { + ReportIntValue({ + dynamic value, + EntityType entityType, + String entityId, + }) : super(value: value, entityType: entityType, entityId: entityId); + + @override + Widget renderWidget(BuildContext context, String column) { + return Text(renderText(context, column)); + } + + @override + String renderText(BuildContext context, String column) { + return formatNumber((value as int).toDouble(), context, + formatNumberType: FormatNumberType.int); + } +} + class ReportNumberValue extends ReportElement { ReportNumberValue({ dynamic value, diff --git a/lib/utils/strings.dart b/lib/utils/strings.dart index acc56076b..b98d5b323 100644 --- a/lib/utils/strings.dart +++ b/lib/utils/strings.dart @@ -66,10 +66,10 @@ bool isValidDate(String input) { } void printWrapped(String text) { - print(text); + //print(text); - //final pattern = RegExp('.{1,800}'); // 800 is the size of each chunk - //pattern.allMatches(text).forEach((match) => print(match.group(0))); + final pattern = RegExp('.{1,800}'); // 800 is the size of each chunk + pattern.allMatches(text).forEach((match) => print(match.group(0))); } bool matchesStrings({