From b51bdfffbcf34ae9fdacd163b546f45c8caf50aa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2018 22:47:25 -0700 Subject: [PATCH] Add product fields --- lib/data/models/entities.g.dart | 123 ++++++++++++++------------- lib/data/models/product_model.dart | 18 ++-- lib/data/models/product_model.g.dart | 89 +++++++++++++++++-- lib/utils/localization.dart | 2 +- 4 files changed, 160 insertions(+), 72 deletions(-) diff --git a/lib/data/models/entities.g.dart b/lib/data/models/entities.g.dart index 0aa6e50be..dc6424ec5 100644 --- a/lib/data/models/entities.g.dart +++ b/lib/data/models/entities.g.dart @@ -127,13 +127,19 @@ class _$CompanyEntitySerializer implements StructuredSerializer { @override Iterable serialize(Serializers serializers, CompanyEntity object, {FullType specifiedType: FullType.unspecified}) { - final result = [ - 'name', - serializers.serialize(object.name, specifiedType: const FullType(String)), - 'token', - serializers.serialize(object.token, - specifiedType: const FullType(String)), - ]; + final result = []; + if (object.name != null) { + result + ..add('name') + ..add(serializers.serialize(object.name, + specifiedType: const FullType(String))); + } + if (object.token != null) { + result + ..add('token') + ..add(serializers.serialize(object.token, + specifiedType: const FullType(String))); + } if (object.plan != null) { result ..add('plan') @@ -236,32 +242,55 @@ class _$DashboardEntitySerializer @override Iterable serialize(Serializers serializers, DashboardEntity object, {FullType specifiedType: FullType.unspecified}) { - final result = [ - 'paidToDate', - serializers.serialize(object.paidToDate, - specifiedType: const FullType(double)), - 'paidToDateCurrency', - serializers.serialize(object.paidToDateCurrency, - specifiedType: const FullType(int)), - 'balances', - serializers.serialize(object.balances, - specifiedType: const FullType(double)), - 'balancesCurrency', - serializers.serialize(object.balancesCurrency, - specifiedType: const FullType(int)), - 'averageInvoice', - serializers.serialize(object.averageInvoice, - specifiedType: const FullType(double)), - 'averageInvoiceCurrency', - serializers.serialize(object.averageInvoiceCurrency, - specifiedType: const FullType(int)), - 'invoicesSent', - serializers.serialize(object.invoicesSent, - specifiedType: const FullType(int)), - 'activeClients', - serializers.serialize(object.activeClients, - specifiedType: const FullType(int)), - ]; + final result = []; + if (object.paidToDate != null) { + result + ..add('paidToDate') + ..add(serializers.serialize(object.paidToDate, + specifiedType: const FullType(double))); + } + if (object.paidToDateCurrency != null) { + result + ..add('paidToDateCurrency') + ..add(serializers.serialize(object.paidToDateCurrency, + specifiedType: const FullType(int))); + } + if (object.balances != null) { + result + ..add('balances') + ..add(serializers.serialize(object.balances, + specifiedType: const FullType(double))); + } + if (object.balancesCurrency != null) { + result + ..add('balancesCurrency') + ..add(serializers.serialize(object.balancesCurrency, + specifiedType: const FullType(int))); + } + if (object.averageInvoice != null) { + result + ..add('averageInvoice') + ..add(serializers.serialize(object.averageInvoice, + specifiedType: const FullType(double))); + } + if (object.averageInvoiceCurrency != null) { + result + ..add('averageInvoiceCurrency') + ..add(serializers.serialize(object.averageInvoiceCurrency, + specifiedType: const FullType(int))); + } + if (object.invoicesSent != null) { + result + ..add('invoicesSent') + ..add(serializers.serialize(object.invoicesSent, + specifiedType: const FullType(int))); + } + if (object.activeClients != null) { + result + ..add('activeClients') + ..add(serializers.serialize(object.activeClients, + specifiedType: const FullType(int))); + } return result; } @@ -507,12 +536,7 @@ class _$CompanyEntity extends CompanyEntity { (new CompanyEntityBuilder()..update(updates)).build(); _$CompanyEntity._({this.name, this.token, this.plan, this.logoUrl}) - : super._() { - if (name == null) - throw new BuiltValueNullFieldError('CompanyEntity', 'name'); - if (token == null) - throw new BuiltValueNullFieldError('CompanyEntity', 'token'); - } + : super._(); @override CompanyEntity rebuild(void updates(CompanyEntityBuilder b)) => @@ -723,26 +747,7 @@ class _$DashboardEntity extends DashboardEntity { this.averageInvoiceCurrency, this.invoicesSent, this.activeClients}) - : super._() { - if (paidToDate == null) - throw new BuiltValueNullFieldError('DashboardEntity', 'paidToDate'); - if (paidToDateCurrency == null) - throw new BuiltValueNullFieldError( - 'DashboardEntity', 'paidToDateCurrency'); - if (balances == null) - throw new BuiltValueNullFieldError('DashboardEntity', 'balances'); - if (balancesCurrency == null) - throw new BuiltValueNullFieldError('DashboardEntity', 'balancesCurrency'); - if (averageInvoice == null) - throw new BuiltValueNullFieldError('DashboardEntity', 'averageInvoice'); - if (averageInvoiceCurrency == null) - throw new BuiltValueNullFieldError( - 'DashboardEntity', 'averageInvoiceCurrency'); - if (invoicesSent == null) - throw new BuiltValueNullFieldError('DashboardEntity', 'invoicesSent'); - if (activeClients == null) - throw new BuiltValueNullFieldError('DashboardEntity', 'activeClients'); - } + : super._(); @override DashboardEntity rebuild(void updates(DashboardEntityBuilder b)) => diff --git a/lib/data/models/product_model.dart b/lib/data/models/product_model.dart index a5ade272e..6bd0f1d63 100644 --- a/lib/data/models/product_model.dart +++ b/lib/data/models/product_model.dart @@ -37,6 +37,18 @@ abstract class ProductEntity implements Built { ..add(serializers.serialize(object.cost, specifiedType: const FullType(double))); } + if (object.updatedAt != null) { + result + ..add('updated_at') + ..add(serializers.serialize(object.updatedAt, + specifiedType: const FullType(int))); + } + if (object.archivedAt != null) { + result + ..add('archived_at') + ..add(serializers.serialize(object.archivedAt, + specifiedType: const FullType(int))); + } + if (object.isDeleted != null) { + result + ..add('is_deleted') + ..add(serializers.serialize(object.isDeleted, + specifiedType: const FullType(bool))); + } return result; } @@ -177,6 +195,18 @@ class _$ProductEntitySerializer implements StructuredSerializer { result.cost = serializers.deserialize(value, specifiedType: const FullType(double)) as double; break; + case 'updated_at': + result.updatedAt = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case 'archived_at': + result.archivedAt = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + break; + case 'is_deleted': + result.isDeleted = serializers.deserialize(value, + specifiedType: const FullType(bool)) as bool; + break; } } @@ -374,11 +404,24 @@ class _$ProductEntity extends ProductEntity { final String notes; @override final double cost; + @override + final int updatedAt; + @override + final int archivedAt; + @override + final bool isDeleted; factory _$ProductEntity([void updates(ProductEntityBuilder b)]) => (new ProductEntityBuilder()..update(updates)).build(); - _$ProductEntity._({this.id, this.productKey, this.notes, this.cost}) + _$ProductEntity._( + {this.id, + this.productKey, + this.notes, + this.cost, + this.updatedAt, + this.archivedAt, + this.isDeleted}) : super._(); @override @@ -395,14 +438,24 @@ class _$ProductEntity extends ProductEntity { return id == other.id && productKey == other.productKey && notes == other.notes && - cost == other.cost; + cost == other.cost && + updatedAt == other.updatedAt && + archivedAt == other.archivedAt && + isDeleted == other.isDeleted; } @override int get hashCode { return $jf($jc( - $jc($jc($jc(0, id.hashCode), productKey.hashCode), notes.hashCode), - cost.hashCode)); + $jc( + $jc( + $jc( + $jc($jc($jc(0, id.hashCode), productKey.hashCode), + notes.hashCode), + cost.hashCode), + updatedAt.hashCode), + archivedAt.hashCode), + isDeleted.hashCode)); } @override @@ -411,7 +464,10 @@ class _$ProductEntity extends ProductEntity { ..add('id', id) ..add('productKey', productKey) ..add('notes', notes) - ..add('cost', cost)) + ..add('cost', cost) + ..add('updatedAt', updatedAt) + ..add('archivedAt', archivedAt) + ..add('isDeleted', isDeleted)) .toString(); } } @@ -436,6 +492,18 @@ class ProductEntityBuilder double get cost => _$this._cost; set cost(double cost) => _$this._cost = cost; + int _updatedAt; + int get updatedAt => _$this._updatedAt; + set updatedAt(int updatedAt) => _$this._updatedAt = updatedAt; + + int _archivedAt; + int get archivedAt => _$this._archivedAt; + set archivedAt(int archivedAt) => _$this._archivedAt = archivedAt; + + bool _isDeleted; + bool get isDeleted => _$this._isDeleted; + set isDeleted(bool isDeleted) => _$this._isDeleted = isDeleted; + ProductEntityBuilder(); ProductEntityBuilder get _$this { @@ -444,6 +512,9 @@ class ProductEntityBuilder _productKey = _$v.productKey; _notes = _$v.notes; _cost = _$v.cost; + _updatedAt = _$v.updatedAt; + _archivedAt = _$v.archivedAt; + _isDeleted = _$v.isDeleted; _$v = null; } return this; @@ -464,7 +535,13 @@ class ProductEntityBuilder _$ProductEntity build() { final _$result = _$v ?? new _$ProductEntity._( - id: id, productKey: productKey, notes: notes, cost: cost); + id: id, + productKey: productKey, + notes: notes, + cost: cost, + updatedAt: updatedAt, + archivedAt: archivedAt, + isDeleted: isDeleted); replace(_$result); return _$result; } diff --git a/lib/utils/localization.dart b/lib/utils/localization.dart index 6bfe8b3d9..abc8a655a 100644 --- a/lib/utils/localization.dart +++ b/lib/utils/localization.dart @@ -15,7 +15,7 @@ class AppLocalization { 'en': { 'log_out': 'Log Out', 'dashboard': 'Dashboard', - 'refresh_complete': 'Refresh complete', + 'refresh_complete': 'Refresh Complete', 'please_enter_your_email': 'Please enter your email', 'please_enter_your_password': 'Please enter your password', 'please_enter_your_url': 'Please enter your URL',