Archive/delete

This commit is contained in:
Hillel Coren 2020-01-06 17:49:11 +02:00
parent e2b83bbd83
commit 847bec3a75
34 changed files with 309 additions and 304 deletions

View File

@ -260,7 +260,7 @@ class _$ClientEntitySerializer implements StructuredSerializer<ClientEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -456,7 +456,7 @@ class _$ClientEntitySerializer implements StructuredSerializer<ClientEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
@ -553,7 +553,7 @@ class _$ContactEntitySerializer implements StructuredSerializer<ContactEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -656,7 +656,7 @@ class _$ContactEntitySerializer implements StructuredSerializer<ContactEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -201,7 +201,7 @@ class _$CompanyGatewayEntitySerializer
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -307,7 +307,7 @@ class _$CompanyGatewayEntitySerializer
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -306,7 +306,7 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -587,7 +587,7 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -152,7 +152,7 @@ class _$CreditEntitySerializer implements StructuredSerializer<CreditEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -234,7 +234,7 @@ class _$CreditEntitySerializer implements StructuredSerializer<CreditEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -206,7 +206,7 @@ class _$DocumentEntitySerializer
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -325,7 +325,7 @@ class _$DocumentEntitySerializer
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -168,7 +168,7 @@ abstract class BaseEntity implements SelectableEntity {
int get updatedAt; int get updatedAt;
@nullable @nullable
@BuiltValueField(wireName: 'archived_at') @BuiltValueField(wireName: 'deleted_at')
int get archivedAt; int get archivedAt;
@nullable @nullable

View File

@ -245,7 +245,7 @@ class _$ExpenseEntitySerializer implements StructuredSerializer<ExpenseEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -412,7 +412,7 @@ class _$ExpenseEntitySerializer implements StructuredSerializer<ExpenseEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
@ -477,7 +477,7 @@ class _$ExpenseCategoryEntitySerializer
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -536,7 +536,7 @@ class _$ExpenseCategoryEntitySerializer
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -153,7 +153,7 @@ class _$GatewayTokenEntitySerializer
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -224,7 +224,7 @@ class _$GatewayTokenEntitySerializer
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -135,7 +135,7 @@ class _$GroupEntitySerializer implements StructuredSerializer<GroupEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -197,7 +197,7 @@ class _$GroupEntitySerializer implements StructuredSerializer<GroupEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -300,7 +300,7 @@ class _$InvoiceEntitySerializer implements StructuredSerializer<InvoiceEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -527,7 +527,7 @@ class _$InvoiceEntitySerializer implements StructuredSerializer<InvoiceEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
@ -780,7 +780,7 @@ class _$InvitationEntitySerializer
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -855,7 +855,7 @@ class _$InvitationEntitySerializer
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -247,7 +247,7 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -394,7 +394,7 @@ class _$PaymentEntitySerializer implements StructuredSerializer<PaymentEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -201,7 +201,7 @@ class _$ProductEntitySerializer implements StructuredSerializer<ProductEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -324,7 +324,7 @@ class _$ProductEntitySerializer implements StructuredSerializer<ProductEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -168,7 +168,7 @@ class _$ProjectEntitySerializer implements StructuredSerializer<ProjectEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -263,7 +263,7 @@ class _$ProjectEntitySerializer implements StructuredSerializer<ProjectEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -278,7 +278,7 @@ class _$QuoteEntitySerializer implements StructuredSerializer<QuoteEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -512,7 +512,7 @@ class _$QuoteEntitySerializer implements StructuredSerializer<QuoteEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
@ -584,7 +584,7 @@ class _$InvitationEntitySerializer
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -659,7 +659,7 @@ class _$InvitationEntitySerializer
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -248,7 +248,7 @@ class _$TaskEntitySerializer implements StructuredSerializer<TaskEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -358,7 +358,7 @@ class _$TaskEntitySerializer implements StructuredSerializer<TaskEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -143,7 +143,7 @@ class _$TaxRateEntitySerializer implements StructuredSerializer<TaxRateEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -206,7 +206,7 @@ class _$TaxRateEntitySerializer implements StructuredSerializer<TaxRateEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -172,7 +172,7 @@ class _$UserEntitySerializer implements StructuredSerializer<UserEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -263,7 +263,7 @@ class _$UserEntitySerializer implements StructuredSerializer<UserEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -195,7 +195,7 @@ class _$VendorEntitySerializer implements StructuredSerializer<VendorEntity> {
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -335,7 +335,7 @@ class _$VendorEntitySerializer implements StructuredSerializer<VendorEntity> {
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
@ -413,7 +413,7 @@ class _$VendorContactEntitySerializer
} }
if (object.archivedAt != null) { if (object.archivedAt != null) {
result result
..add('archived_at') ..add('deleted_at')
..add(serializers.serialize(object.archivedAt, ..add(serializers.serialize(object.archivedAt,
specifiedType: const FullType(int))); specifiedType: const FullType(int)));
} }
@ -488,7 +488,7 @@ class _$VendorContactEntitySerializer
result.updatedAt = serializers.deserialize(value, result.updatedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'archived_at': case 'deleted_at':
result.archivedAt = serializers.deserialize(value, result.archivedAt = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;

View File

@ -176,46 +176,46 @@ class SaveClientFailure implements StopSaving {
final Object error; final Object error;
} }
class ArchiveClientRequest implements StartSaving { class ArchiveClientsRequest implements StartSaving {
ArchiveClientRequest(this.completer, this.clientIds); ArchiveClientsRequest(this.completer, this.clientIds);
final Completer completer; final Completer completer;
final List<String> clientIds; final List<String> clientIds;
} }
class ArchiveClientSuccess implements StopSaving, PersistData { class ArchiveClientsSuccess implements StopSaving, PersistData {
ArchiveClientSuccess(this.clients); ArchiveClientsSuccess(this.clients);
final List<ClientEntity> clients; final List<ClientEntity> clients;
} }
class ArchiveClientFailure implements StopSaving { class ArchiveClientsFailure implements StopSaving {
ArchiveClientFailure(this.clients); ArchiveClientsFailure(this.clients);
final List<ClientEntity> clients; final List<ClientEntity> clients;
} }
class DeleteClientRequest implements StartSaving { class DeleteClientsRequest implements StartSaving {
DeleteClientRequest(this.completer, this.clientIds); DeleteClientsRequest(this.completer, this.clientIds);
final Completer completer; final Completer completer;
final List<String> clientIds; final List<String> clientIds;
} }
class DeleteClientSuccess implements StopSaving, PersistData { class DeleteClientsSuccess implements StopSaving, PersistData {
DeleteClientSuccess(this.clients); DeleteClientsSuccess(this.clients);
final List<ClientEntity> clients; final List<ClientEntity> clients;
} }
class DeleteClientFailure implements StopSaving { class DeleteClientsFailure implements StopSaving {
DeleteClientFailure(this.clients); DeleteClientsFailure(this.clients);
final List<ClientEntity> clients; final List<ClientEntity> clients;
} }
class RestoreClientRequest implements StartSaving { class RestoreClientsRequest implements StartSaving {
RestoreClientRequest(this.completer, this.clientIds); RestoreClientsRequest(this.completer, this.clientIds);
final Completer completer; final Completer completer;
final List<String> clientIds; final List<String> clientIds;
@ -373,17 +373,17 @@ void handleClientAction(
.rebuild((b) => b.clientId = client.id)); .rebuild((b) => b.clientId = client.id));
break; break;
case EntityAction.restore: case EntityAction.restore:
store.dispatch(RestoreClientRequest( store.dispatch(RestoreClientsRequest(
snackBarCompleter<Null>(context, localization.restoredClient), snackBarCompleter<Null>(context, localization.restoredClient),
clientIds)); clientIds));
break; break;
case EntityAction.archive: case EntityAction.archive:
store.dispatch(ArchiveClientRequest( store.dispatch(ArchiveClientsRequest(
snackBarCompleter<Null>(context, localization.archivedClient), snackBarCompleter<Null>(context, localization.archivedClient),
clientIds)); clientIds));
break; break;
case EntityAction.delete: case EntityAction.delete:
store.dispatch(DeleteClientRequest( store.dispatch(DeleteClientsRequest(
snackBarCompleter<Null>(context, localization.deletedClient), snackBarCompleter<Null>(context, localization.deletedClient),
clientIds)); clientIds));
break; break;

View File

@ -33,9 +33,9 @@ List<Middleware<AppState>> createStoreClientsMiddleware([
TypedMiddleware<AppState, LoadClients>(loadClients), TypedMiddleware<AppState, LoadClients>(loadClients),
TypedMiddleware<AppState, LoadClient>(loadClient), TypedMiddleware<AppState, LoadClient>(loadClient),
TypedMiddleware<AppState, SaveClientRequest>(saveClient), TypedMiddleware<AppState, SaveClientRequest>(saveClient),
TypedMiddleware<AppState, ArchiveClientRequest>(archiveClient), TypedMiddleware<AppState, ArchiveClientsRequest>(archiveClient),
TypedMiddleware<AppState, DeleteClientRequest>(deleteClient), TypedMiddleware<AppState, DeleteClientsRequest>(deleteClient),
TypedMiddleware<AppState, RestoreClientRequest>(restoreClient), TypedMiddleware<AppState, RestoreClientsRequest>(restoreClient),
]; ];
} }
@ -104,20 +104,20 @@ Middleware<AppState> _viewClientList() {
Middleware<AppState> _archiveClient(ClientRepository repository) { Middleware<AppState> _archiveClient(ClientRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveClientRequest; final action = dynamicAction as ArchiveClientsRequest;
final prevClients = final prevClients =
action.clientIds.map((id) => store.state.clientState.map[id]).toList(); action.clientIds.map((id) => store.state.clientState.map[id]).toList();
repository repository
.bulkAction( .bulkAction(
store.state.credentials, action.clientIds, EntityAction.archive) store.state.credentials, action.clientIds, EntityAction.archive)
.then((List<ClientEntity> clients) { .then((List<ClientEntity> clients) {
store.dispatch(ArchiveClientSuccess(clients)); store.dispatch(ArchiveClientsSuccess(clients));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(ArchiveClientFailure(prevClients)); store.dispatch(ArchiveClientsFailure(prevClients));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -129,20 +129,20 @@ Middleware<AppState> _archiveClient(ClientRepository repository) {
Middleware<AppState> _deleteClient(ClientRepository repository) { Middleware<AppState> _deleteClient(ClientRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteClientRequest; final action = dynamicAction as DeleteClientsRequest;
final prevClients = final prevClients =
action.clientIds.map((id) => store.state.clientState.map[id]).toList(); action.clientIds.map((id) => store.state.clientState.map[id]).toList();
repository repository
.bulkAction( .bulkAction(
store.state.credentials, action.clientIds, EntityAction.delete) store.state.credentials, action.clientIds, EntityAction.delete)
.then((List<ClientEntity> clients) { .then((List<ClientEntity> clients) {
store.dispatch(DeleteClientSuccess(clients)); store.dispatch(DeleteClientsSuccess(clients));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(DeleteClientFailure(prevClients)); store.dispatch(DeleteClientsFailure(prevClients));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -154,7 +154,7 @@ Middleware<AppState> _deleteClient(ClientRepository repository) {
Middleware<AppState> _restoreClient(ClientRepository repository) { Middleware<AppState> _restoreClient(ClientRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreClientRequest; final action = dynamicAction as RestoreClientsRequest;
final prevClients = final prevClients =
action.clientIds.map((id) => store.state.clientState.map[id]).toList(); action.clientIds.map((id) => store.state.clientState.map[id]).toList();
repository repository

View File

@ -63,10 +63,10 @@ final editingReducer = combineReducers<ClientEntity>([
TypedReducer<ClientEntity, RestoreClientSuccess>((clients, action) { TypedReducer<ClientEntity, RestoreClientSuccess>((clients, action) {
return action.clients[0]; return action.clients[0];
}), }),
TypedReducer<ClientEntity, ArchiveClientSuccess>((clients, action) { TypedReducer<ClientEntity, ArchiveClientsSuccess>((clients, action) {
return action.clients[0]; return action.clients[0];
}), }),
TypedReducer<ClientEntity, DeleteClientSuccess>((clients, action) { TypedReducer<ClientEntity, DeleteClientsSuccess>((clients, action) {
return action.clients[0]; return action.clients[0];
}), }),
TypedReducer<ClientEntity, EditClient>((client, action) { TypedReducer<ClientEntity, EditClient>((client, action) {
@ -211,19 +211,19 @@ final clientsReducer = combineReducers<ClientState>([
TypedReducer<ClientState, AddClientSuccess>(_addClient), TypedReducer<ClientState, AddClientSuccess>(_addClient),
TypedReducer<ClientState, LoadClientsSuccess>(_setLoadedClients), TypedReducer<ClientState, LoadClientsSuccess>(_setLoadedClients),
TypedReducer<ClientState, LoadClientSuccess>(_setLoadedClient), TypedReducer<ClientState, LoadClientSuccess>(_setLoadedClient),
TypedReducer<ClientState, ArchiveClientRequest>(_archiveClientRequest), TypedReducer<ClientState, ArchiveClientsRequest>(_archiveClientRequest),
TypedReducer<ClientState, ArchiveClientSuccess>(_archiveClientSuccess), TypedReducer<ClientState, ArchiveClientsSuccess>(_archiveClientSuccess),
TypedReducer<ClientState, ArchiveClientFailure>(_archiveClientFailure), TypedReducer<ClientState, ArchiveClientsFailure>(_archiveClientFailure),
TypedReducer<ClientState, DeleteClientRequest>(_deleteClientRequest), TypedReducer<ClientState, DeleteClientsRequest>(_deleteClientRequest),
TypedReducer<ClientState, DeleteClientSuccess>(_deleteClientSuccess), TypedReducer<ClientState, DeleteClientsSuccess>(_deleteClientSuccess),
TypedReducer<ClientState, DeleteClientFailure>(_deleteClientFailure), TypedReducer<ClientState, DeleteClientsFailure>(_deleteClientFailure),
TypedReducer<ClientState, RestoreClientRequest>(_restoreClientRequest), TypedReducer<ClientState, RestoreClientsRequest>(_restoreClientRequest),
TypedReducer<ClientState, RestoreClientSuccess>(_restoreClientSuccess), TypedReducer<ClientState, RestoreClientSuccess>(_restoreClientSuccess),
TypedReducer<ClientState, RestoreClientFailure>(_restoreClientFailure), TypedReducer<ClientState, RestoreClientFailure>(_restoreClientFailure),
]); ]);
ClientState _archiveClientRequest( ClientState _archiveClientRequest(
ClientState clientState, ArchiveClientRequest action) { ClientState clientState, ArchiveClientsRequest action) {
final clients = action.clientIds.map((id) => clientState.map[id]).toList(); final clients = action.clientIds.map((id) => clientState.map[id]).toList();
for (int i = 0; i < clients.length; i++) { for (int i = 0; i < clients.length; i++) {
@ -238,7 +238,7 @@ ClientState _archiveClientRequest(
} }
ClientState _archiveClientSuccess( ClientState _archiveClientSuccess(
ClientState clientState, ArchiveClientSuccess action) { ClientState clientState, ArchiveClientsSuccess action) {
return clientState.rebuild((b) { return clientState.rebuild((b) {
for (final client in action.clients) { for (final client in action.clients) {
b.map[client.id] = client; b.map[client.id] = client;
@ -247,7 +247,7 @@ ClientState _archiveClientSuccess(
} }
ClientState _archiveClientFailure( ClientState _archiveClientFailure(
ClientState clientState, ArchiveClientFailure action) { ClientState clientState, ArchiveClientsFailure action) {
return clientState.rebuild((b) { return clientState.rebuild((b) {
for (final client in action.clients) { for (final client in action.clients) {
b.map[client.id] = client; b.map[client.id] = client;
@ -256,7 +256,7 @@ ClientState _archiveClientFailure(
} }
ClientState _deleteClientRequest( ClientState _deleteClientRequest(
ClientState clientState, DeleteClientRequest action) { ClientState clientState, DeleteClientsRequest action) {
final clients = action.clientIds.map((id) => clientState.map[id]).toList(); final clients = action.clientIds.map((id) => clientState.map[id]).toList();
for (int i = 0; i < clients.length; i++) { for (int i = 0; i < clients.length; i++) {
@ -272,7 +272,7 @@ ClientState _deleteClientRequest(
} }
ClientState _deleteClientSuccess( ClientState _deleteClientSuccess(
ClientState clientState, DeleteClientSuccess action) { ClientState clientState, DeleteClientsSuccess action) {
return clientState.rebuild((b) { return clientState.rebuild((b) {
for (final client in action.clients) { for (final client in action.clients) {
b.map[client.id] = client; b.map[client.id] = client;
@ -281,7 +281,7 @@ ClientState _deleteClientSuccess(
} }
ClientState _deleteClientFailure( ClientState _deleteClientFailure(
ClientState clientState, DeleteClientFailure action) { ClientState clientState, DeleteClientsFailure action) {
return clientState.rebuild((b) { return clientState.rebuild((b) {
for (final client in action.clients) { for (final client in action.clients) {
b.map[client.id] = client; b.map[client.id] = client;
@ -290,7 +290,7 @@ ClientState _deleteClientFailure(
} }
ClientState _restoreClientRequest( ClientState _restoreClientRequest(
ClientState clientState, RestoreClientRequest action) { ClientState clientState, RestoreClientsRequest action) {
final clients = action.clientIds.map((id) => clientState.map[id]).toList(); final clients = action.clientIds.map((id) => clientState.map[id]).toList();
for (int i = 0; i < clients.length; i++) { for (int i = 0; i < clients.length; i++) {

View File

@ -252,59 +252,59 @@ class MarkInvoicesPaidFailure implements StopSaving {
final dynamic error; final dynamic error;
} }
class ArchiveInvoiceRequest implements StartSaving { class ArchiveInvoicesRequest implements StartSaving {
ArchiveInvoiceRequest(this.completer, this.invoiceIds); ArchiveInvoicesRequest(this.completer, this.invoiceIds);
final Completer completer; final Completer completer;
final List<String> invoiceIds; final List<String> invoiceIds;
} }
class ArchiveInvoiceSuccess implements StopSaving, PersistData { class ArchiveInvoicesSuccess implements StopSaving, PersistData {
ArchiveInvoiceSuccess(this.invoices); ArchiveInvoicesSuccess(this.invoices);
final List<InvoiceEntity> invoices; final List<InvoiceEntity> invoices;
} }
class ArchiveInvoiceFailure implements StopSaving { class ArchiveInvoicesFailure implements StopSaving {
ArchiveInvoiceFailure(this.invoices); ArchiveInvoicesFailure(this.invoices);
final List<InvoiceEntity> invoices; final List<InvoiceEntity> invoices;
} }
class DeleteInvoiceRequest implements StartSaving { class DeleteInvoicesRequest implements StartSaving {
DeleteInvoiceRequest(this.completer, this.invoiceIds); DeleteInvoicesRequest(this.completer, this.invoiceIds);
final Completer completer; final Completer completer;
final List<String> invoiceIds; final List<String> invoiceIds;
} }
class DeleteInvoiceSuccess implements StopSaving, PersistData { class DeleteInvoicesSuccess implements StopSaving, PersistData {
DeleteInvoiceSuccess(this.invoices); DeleteInvoicesSuccess(this.invoices);
final List<InvoiceEntity> invoices; final List<InvoiceEntity> invoices;
} }
class DeleteInvoiceFailure implements StopSaving { class DeleteInvoicesFailure implements StopSaving {
DeleteInvoiceFailure(this.invoices); DeleteInvoicesFailure(this.invoices);
final List<InvoiceEntity> invoices; final List<InvoiceEntity> invoices;
} }
class RestoreInvoiceRequest implements StartSaving { class RestoreInvoicesRequest implements StartSaving {
RestoreInvoiceRequest(this.completer, this.invoiceIds); RestoreInvoicesRequest(this.completer, this.invoiceIds);
final Completer completer; final Completer completer;
final List<String> invoiceIds; final List<String> invoiceIds;
} }
class RestoreInvoiceSuccess implements StopSaving, PersistData { class RestoreInvoicesSuccess implements StopSaving, PersistData {
RestoreInvoiceSuccess(this.invoices); RestoreInvoicesSuccess(this.invoices);
final List<InvoiceEntity> invoices; final List<InvoiceEntity> invoices;
} }
class RestoreInvoiceFailure implements StopSaving { class RestoreInvoicesFailure implements StopSaving {
RestoreInvoiceFailure(this.invoices); RestoreInvoicesFailure(this.invoices);
final List<InvoiceEntity> invoices; final List<InvoiceEntity> invoices;
} }
@ -436,17 +436,17 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
.toList()))); .toList())));
break; break;
case EntityAction.restore: case EntityAction.restore:
store.dispatch(RestoreInvoiceRequest( store.dispatch(RestoreInvoicesRequest(
snackBarCompleter<Null>(context, localization.restoredInvoice), snackBarCompleter<Null>(context, localization.restoredInvoice),
invoiceIds)); invoiceIds));
break; break;
case EntityAction.archive: case EntityAction.archive:
store.dispatch(ArchiveInvoiceRequest( store.dispatch(ArchiveInvoicesRequest(
snackBarCompleter<Null>(context, localization.archivedInvoice), snackBarCompleter<Null>(context, localization.archivedInvoice),
invoiceIds)); invoiceIds));
break; break;
case EntityAction.delete: case EntityAction.delete:
store.dispatch(DeleteInvoiceRequest( store.dispatch(DeleteInvoicesRequest(
snackBarCompleter<Null>(context, localization.deletedInvoice), snackBarCompleter<Null>(context, localization.deletedInvoice),
invoiceIds)); invoiceIds));
break; break;

View File

@ -44,9 +44,9 @@ List<Middleware<AppState>> createStoreInvoicesMiddleware([
TypedMiddleware<AppState, LoadInvoices>(loadInvoices), TypedMiddleware<AppState, LoadInvoices>(loadInvoices),
TypedMiddleware<AppState, LoadInvoice>(loadInvoice), TypedMiddleware<AppState, LoadInvoice>(loadInvoice),
TypedMiddleware<AppState, SaveInvoiceRequest>(saveInvoice), TypedMiddleware<AppState, SaveInvoiceRequest>(saveInvoice),
TypedMiddleware<AppState, ArchiveInvoiceRequest>(archiveInvoice), TypedMiddleware<AppState, ArchiveInvoicesRequest>(archiveInvoice),
TypedMiddleware<AppState, DeleteInvoiceRequest>(deleteInvoice), TypedMiddleware<AppState, DeleteInvoicesRequest>(deleteInvoice),
TypedMiddleware<AppState, RestoreInvoiceRequest>(restoreInvoice), TypedMiddleware<AppState, RestoreInvoicesRequest>(restoreInvoice),
TypedMiddleware<AppState, EmailInvoiceRequest>(emailInvoice), TypedMiddleware<AppState, EmailInvoiceRequest>(emailInvoice),
TypedMiddleware<AppState, MarkInvoicesSentRequest>(markInvoiceSent), TypedMiddleware<AppState, MarkInvoicesSentRequest>(markInvoiceSent),
TypedMiddleware<AppState, MarkInvoicesPaidRequest>(markInvoicePaid), TypedMiddleware<AppState, MarkInvoicesPaidRequest>(markInvoicePaid),
@ -138,7 +138,7 @@ Middleware<AppState> _showEmailInvoice() {
Middleware<AppState> _archiveInvoice(InvoiceRepository repository) { Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveInvoiceRequest; final action = dynamicAction as ArchiveInvoicesRequest;
final prevInvoices = action.invoiceIds final prevInvoices = action.invoiceIds
.map((id) => store.state.invoiceState.map[id]) .map((id) => store.state.invoiceState.map[id])
.toList(); .toList();
@ -146,13 +146,13 @@ Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.invoiceIds, EntityAction.archive) store.state.credentials, action.invoiceIds, EntityAction.archive)
.then((List<InvoiceEntity> invoices) { .then((List<InvoiceEntity> invoices) {
store.dispatch(ArchiveInvoiceSuccess(invoices)); store.dispatch(ArchiveInvoicesSuccess(invoices));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(ArchiveInvoiceFailure(prevInvoices)); store.dispatch(ArchiveInvoicesFailure(prevInvoices));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -164,7 +164,7 @@ Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
Middleware<AppState> _deleteInvoice(InvoiceRepository repository) { Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteInvoiceRequest; final action = dynamicAction as DeleteInvoicesRequest;
final prevInvoices = action.invoiceIds final prevInvoices = action.invoiceIds
.map((id) => store.state.invoiceState.map[id]) .map((id) => store.state.invoiceState.map[id])
.toList(); .toList();
@ -172,14 +172,14 @@ Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.invoiceIds, EntityAction.delete) store.state.credentials, action.invoiceIds, EntityAction.delete)
.then((List<InvoiceEntity> invoices) { .then((List<InvoiceEntity> invoices) {
store.dispatch(DeleteInvoiceSuccess(invoices)); store.dispatch(DeleteInvoicesSuccess(invoices));
store.dispatch(LoadClient(clientId: invoices.first.clientId)); store.dispatch(LoadClient(clientId: invoices.first.clientId));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(DeleteInvoiceFailure(prevInvoices)); store.dispatch(DeleteInvoicesFailure(prevInvoices));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -191,7 +191,7 @@ Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
Middleware<AppState> _restoreInvoice(InvoiceRepository repository) { Middleware<AppState> _restoreInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreInvoiceRequest; final action = dynamicAction as RestoreInvoicesRequest;
final prevInvoices = action.invoiceIds final prevInvoices = action.invoiceIds
.map((id) => store.state.invoiceState.map[id]) .map((id) => store.state.invoiceState.map[id])
.toList(); .toList();
@ -199,14 +199,14 @@ Middleware<AppState> _restoreInvoice(InvoiceRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.invoiceIds, EntityAction.restore) store.state.credentials, action.invoiceIds, EntityAction.restore)
.then((List<InvoiceEntity> invoices) { .then((List<InvoiceEntity> invoices) {
store.dispatch(RestoreInvoiceSuccess(invoices)); store.dispatch(RestoreInvoicesSuccess(invoices));
store.dispatch(LoadClient(clientId: invoices.first.clientId)); store.dispatch(LoadClient(clientId: invoices.first.clientId));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(RestoreInvoiceFailure(prevInvoices)); store.dispatch(RestoreInvoicesFailure(prevInvoices));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }

View File

@ -66,9 +66,9 @@ final editingReducer = combineReducers<InvoiceEntity>([
.where((contact) => contact.sendInvoice) .where((contact) => contact.sendInvoice)
.map((contact) => InvitationEntity(contactId: contact.id)))); .map((contact) => InvitationEntity(contactId: contact.id))));
}), }),
TypedReducer<InvoiceEntity, RestoreInvoiceSuccess>(_updateEditing), TypedReducer<InvoiceEntity, RestoreInvoicesSuccess>(_updateEditing),
TypedReducer<InvoiceEntity, ArchiveInvoiceSuccess>(_updateEditing), TypedReducer<InvoiceEntity, ArchiveInvoicesSuccess>(_updateEditing),
TypedReducer<InvoiceEntity, DeleteInvoiceSuccess>(_updateEditing), TypedReducer<InvoiceEntity, DeleteInvoicesSuccess>(_updateEditing),
TypedReducer<InvoiceEntity, AddInvoiceItem>(_addInvoiceItem), TypedReducer<InvoiceEntity, AddInvoiceItem>(_addInvoiceItem),
TypedReducer<InvoiceEntity, AddInvoiceItems>(_addInvoiceItems), TypedReducer<InvoiceEntity, AddInvoiceItems>(_addInvoiceItems),
TypedReducer<InvoiceEntity, DeleteInvoiceItem>(_removeInvoiceItem), TypedReducer<InvoiceEntity, DeleteInvoiceItem>(_removeInvoiceItem),
@ -252,15 +252,15 @@ final invoicesReducer = combineReducers<InvoiceState>([
TypedReducer<InvoiceState, LoadInvoiceSuccess>(_updateInvoice), TypedReducer<InvoiceState, LoadInvoiceSuccess>(_updateInvoice),
TypedReducer<InvoiceState, MarkInvoicesSentSuccess>(_markInvoicesSentSuccess), TypedReducer<InvoiceState, MarkInvoicesSentSuccess>(_markInvoicesSentSuccess),
TypedReducer<InvoiceState, MarkInvoicesPaidSuccess>(_markInvoicesPaidSuccess), TypedReducer<InvoiceState, MarkInvoicesPaidSuccess>(_markInvoicesPaidSuccess),
TypedReducer<InvoiceState, ArchiveInvoiceRequest>(_archiveInvoiceRequest), TypedReducer<InvoiceState, ArchiveInvoicesRequest>(_archiveInvoiceRequest),
TypedReducer<InvoiceState, ArchiveInvoiceSuccess>(_archiveInvoiceSuccess), TypedReducer<InvoiceState, ArchiveInvoicesSuccess>(_archiveInvoiceSuccess),
TypedReducer<InvoiceState, ArchiveInvoiceFailure>(_archiveInvoiceFailure), TypedReducer<InvoiceState, ArchiveInvoicesFailure>(_archiveInvoiceFailure),
TypedReducer<InvoiceState, DeleteInvoiceRequest>(_deleteInvoiceRequest), TypedReducer<InvoiceState, DeleteInvoicesRequest>(_deleteInvoiceRequest),
TypedReducer<InvoiceState, DeleteInvoiceSuccess>(_deleteInvoiceSuccess), TypedReducer<InvoiceState, DeleteInvoicesSuccess>(_deleteInvoiceSuccess),
TypedReducer<InvoiceState, DeleteInvoiceFailure>(_deleteInvoiceFailure), TypedReducer<InvoiceState, DeleteInvoicesFailure>(_deleteInvoiceFailure),
TypedReducer<InvoiceState, RestoreInvoiceRequest>(_restoreInvoiceRequest), TypedReducer<InvoiceState, RestoreInvoicesRequest>(_restoreInvoiceRequest),
TypedReducer<InvoiceState, RestoreInvoiceSuccess>(_restoreInvoiceSuccess), TypedReducer<InvoiceState, RestoreInvoicesSuccess>(_restoreInvoiceSuccess),
TypedReducer<InvoiceState, RestoreInvoiceFailure>(_restoreInvoiceFailure), TypedReducer<InvoiceState, RestoreInvoicesFailure>(_restoreInvoiceFailure),
TypedReducer<InvoiceState, ConvertQuoteSuccess>(_convertQuoteSuccess), TypedReducer<InvoiceState, ConvertQuoteSuccess>(_convertQuoteSuccess),
]); ]);
@ -283,7 +283,7 @@ InvoiceState _markInvoicesPaidSuccess(
} }
InvoiceState _archiveInvoiceRequest( InvoiceState _archiveInvoiceRequest(
InvoiceState invoiceState, ArchiveInvoiceRequest action) { InvoiceState invoiceState, ArchiveInvoicesRequest action) {
final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList(); final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList();
for (int i = 0; i < invoices.length; i++) { for (int i = 0; i < invoices.length; i++) {
@ -299,7 +299,7 @@ InvoiceState _archiveInvoiceRequest(
} }
InvoiceState _archiveInvoiceSuccess( InvoiceState _archiveInvoiceSuccess(
InvoiceState invoiceState, ArchiveInvoiceSuccess action) { InvoiceState invoiceState, ArchiveInvoicesSuccess action) {
return invoiceState.rebuild((b) { return invoiceState.rebuild((b) {
for (final invoice in action.invoices) { for (final invoice in action.invoices) {
b.map[invoice.id] = invoice; b.map[invoice.id] = invoice;
@ -308,7 +308,7 @@ InvoiceState _archiveInvoiceSuccess(
} }
InvoiceState _archiveInvoiceFailure( InvoiceState _archiveInvoiceFailure(
InvoiceState invoiceState, ArchiveInvoiceFailure action) { InvoiceState invoiceState, ArchiveInvoicesFailure action) {
return invoiceState.rebuild((b) { return invoiceState.rebuild((b) {
for (final invoice in action.invoices) { for (final invoice in action.invoices) {
b.map[invoice.id] = invoice; b.map[invoice.id] = invoice;
@ -317,7 +317,7 @@ InvoiceState _archiveInvoiceFailure(
} }
InvoiceState _deleteInvoiceRequest( InvoiceState _deleteInvoiceRequest(
InvoiceState invoiceState, DeleteInvoiceRequest action) { InvoiceState invoiceState, DeleteInvoicesRequest action) {
final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList(); final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList();
for (int i = 0; i < invoices.length; i++) { for (int i = 0; i < invoices.length; i++) {
@ -333,7 +333,7 @@ InvoiceState _deleteInvoiceRequest(
} }
InvoiceState _deleteInvoiceSuccess( InvoiceState _deleteInvoiceSuccess(
InvoiceState invoiceState, DeleteInvoiceSuccess action) { InvoiceState invoiceState, DeleteInvoicesSuccess action) {
return invoiceState.rebuild((b) { return invoiceState.rebuild((b) {
for (final invoice in action.invoices) { for (final invoice in action.invoices) {
b.map[invoice.id] = invoice; b.map[invoice.id] = invoice;
@ -342,7 +342,7 @@ InvoiceState _deleteInvoiceSuccess(
} }
InvoiceState _deleteInvoiceFailure( InvoiceState _deleteInvoiceFailure(
InvoiceState invoiceState, DeleteInvoiceFailure action) { InvoiceState invoiceState, DeleteInvoicesFailure action) {
return invoiceState.rebuild((b) { return invoiceState.rebuild((b) {
for (final invoice in action.invoices) { for (final invoice in action.invoices) {
b.map[invoice.id] = invoice; b.map[invoice.id] = invoice;
@ -351,7 +351,7 @@ InvoiceState _deleteInvoiceFailure(
} }
InvoiceState _restoreInvoiceRequest( InvoiceState _restoreInvoiceRequest(
InvoiceState invoiceState, RestoreInvoiceRequest action) { InvoiceState invoiceState, RestoreInvoicesRequest action) {
final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList(); final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList();
for (int i = 0; i < invoices.length; i++) { for (int i = 0; i < invoices.length; i++) {
@ -367,7 +367,7 @@ InvoiceState _restoreInvoiceRequest(
} }
InvoiceState _restoreInvoiceSuccess( InvoiceState _restoreInvoiceSuccess(
InvoiceState invoiceState, RestoreInvoiceSuccess action) { InvoiceState invoiceState, RestoreInvoicesSuccess action) {
return invoiceState.rebuild((b) { return invoiceState.rebuild((b) {
for (final invoice in action.invoices) { for (final invoice in action.invoices) {
b.map[invoice.id] = invoice; b.map[invoice.id] = invoice;
@ -376,7 +376,7 @@ InvoiceState _restoreInvoiceSuccess(
} }
InvoiceState _restoreInvoiceFailure( InvoiceState _restoreInvoiceFailure(
InvoiceState invoiceState, RestoreInvoiceFailure action) { InvoiceState invoiceState, RestoreInvoicesFailure action) {
return invoiceState.rebuild((b) { return invoiceState.rebuild((b) {
for (final invoice in action.invoices) { for (final invoice in action.invoices) {
b.map[invoice.id] = invoice; b.map[invoice.id] = invoice;

View File

@ -143,59 +143,59 @@ class SavePaymentFailure implements StopSaving {
final Object error; final Object error;
} }
class ArchivePaymentRequest implements StartSaving { class ArchivePaymentsRequest implements StartSaving {
ArchivePaymentRequest(this.completer, this.paymentIds); ArchivePaymentsRequest(this.completer, this.paymentIds);
final Completer completer; final Completer completer;
final List<String> paymentIds; final List<String> paymentIds;
} }
class ArchivePaymentSuccess implements StopSaving, PersistData { class ArchivePaymentsSuccess implements StopSaving, PersistData {
ArchivePaymentSuccess(this.payments); ArchivePaymentsSuccess(this.payments);
final List<PaymentEntity> payments; final List<PaymentEntity> payments;
} }
class ArchivePaymentFailure implements StopSaving { class ArchivePaymentsFailure implements StopSaving {
ArchivePaymentFailure(this.payments); ArchivePaymentsFailure(this.payments);
final List<PaymentEntity> payments; final List<PaymentEntity> payments;
} }
class DeletePaymentRequest implements StartSaving { class DeletePaymentsRequest implements StartSaving {
DeletePaymentRequest(this.completer, this.paymentIds); DeletePaymentsRequest(this.completer, this.paymentIds);
final Completer completer; final Completer completer;
final List<String> paymentIds; final List<String> paymentIds;
} }
class DeletePaymentSuccess implements StopSaving, PersistData { class DeletePaymentsSuccess implements StopSaving, PersistData {
DeletePaymentSuccess(this.payments); DeletePaymentsSuccess(this.payments);
final List<PaymentEntity> payments; final List<PaymentEntity> payments;
} }
class DeletePaymentFailure implements StopSaving { class DeletePaymentsFailure implements StopSaving {
DeletePaymentFailure(this.payments); DeletePaymentsFailure(this.payments);
final List<PaymentEntity> payments; final List<PaymentEntity> payments;
} }
class RestorePaymentRequest implements StartSaving { class RestorePaymentsRequest implements StartSaving {
RestorePaymentRequest(this.completer, this.paymentIds); RestorePaymentsRequest(this.completer, this.paymentIds);
final Completer completer; final Completer completer;
final List<String> paymentIds; final List<String> paymentIds;
} }
class RestorePaymentSuccess implements StopSaving, PersistData { class RestorePaymentsSuccess implements StopSaving, PersistData {
RestorePaymentSuccess(this.payments); RestorePaymentsSuccess(this.payments);
final List<PaymentEntity> payments; final List<PaymentEntity> payments;
} }
class RestorePaymentFailure implements StopSaving { class RestorePaymentsFailure implements StopSaving {
RestorePaymentFailure(this.payments); RestorePaymentsFailure(this.payments);
final List<PaymentEntity> payments; final List<PaymentEntity> payments;
} }
@ -295,17 +295,17 @@ void handlePaymentAction(
payment)); payment));
break; break;
case EntityAction.restore: case EntityAction.restore:
store.dispatch(RestorePaymentRequest( store.dispatch(RestorePaymentsRequest(
snackBarCompleter<Null>(context, localization.restoredPayment), snackBarCompleter<Null>(context, localization.restoredPayment),
paymentIds)); paymentIds));
break; break;
case EntityAction.archive: case EntityAction.archive:
store.dispatch(ArchivePaymentRequest( store.dispatch(ArchivePaymentsRequest(
snackBarCompleter<Null>(context, localization.archivedPayment), snackBarCompleter<Null>(context, localization.archivedPayment),
paymentIds)); paymentIds));
break; break;
case EntityAction.delete: case EntityAction.delete:
store.dispatch(DeletePaymentRequest( store.dispatch(DeletePaymentsRequest(
snackBarCompleter<Null>(context, localization.deletedPayment), snackBarCompleter<Null>(context, localization.deletedPayment),
paymentIds)); paymentIds));
break; break;

View File

@ -35,9 +35,9 @@ List<Middleware<AppState>> createStorePaymentsMiddleware([
TypedMiddleware<AppState, LoadPayments>(loadPayments), TypedMiddleware<AppState, LoadPayments>(loadPayments),
//TypedMiddleware<AppState, LoadPayment>(loadPayment), //TypedMiddleware<AppState, LoadPayment>(loadPayment),
TypedMiddleware<AppState, SavePaymentRequest>(savePayment), TypedMiddleware<AppState, SavePaymentRequest>(savePayment),
TypedMiddleware<AppState, ArchivePaymentRequest>(archivePayment), TypedMiddleware<AppState, ArchivePaymentsRequest>(archivePayment),
TypedMiddleware<AppState, DeletePaymentRequest>(deletePayment), TypedMiddleware<AppState, DeletePaymentsRequest>(deletePayment),
TypedMiddleware<AppState, RestorePaymentRequest>(restorePayment), TypedMiddleware<AppState, RestorePaymentsRequest>(restorePayment),
TypedMiddleware<AppState, EmailPaymentRequest>(emailPayment), TypedMiddleware<AppState, EmailPaymentRequest>(emailPayment),
]; ];
} }
@ -104,7 +104,7 @@ Middleware<AppState> _viewPaymentList() {
Middleware<AppState> _archivePayment(PaymentRepository repository) { Middleware<AppState> _archivePayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchivePaymentRequest; final action = dynamicAction as ArchivePaymentsRequest;
final prevPayments = action.paymentIds final prevPayments = action.paymentIds
.map((id) => store.state.paymentState.map[id]) .map((id) => store.state.paymentState.map[id])
.toList(); .toList();
@ -112,13 +112,13 @@ Middleware<AppState> _archivePayment(PaymentRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.paymentIds, EntityAction.archive) store.state.credentials, action.paymentIds, EntityAction.archive)
.then((List<PaymentEntity> payments) { .then((List<PaymentEntity> payments) {
store.dispatch(ArchivePaymentSuccess(payments)); store.dispatch(ArchivePaymentsSuccess(payments));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(ArchivePaymentFailure(prevPayments)); store.dispatch(ArchivePaymentsFailure(prevPayments));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -130,7 +130,7 @@ Middleware<AppState> _archivePayment(PaymentRepository repository) {
Middleware<AppState> _deletePayment(PaymentRepository repository) { Middleware<AppState> _deletePayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeletePaymentRequest; final action = dynamicAction as DeletePaymentsRequest;
final prevPayments = action.paymentIds final prevPayments = action.paymentIds
.map((id) => store.state.paymentState.map[id]) .map((id) => store.state.paymentState.map[id])
.toList(); .toList();
@ -138,14 +138,14 @@ Middleware<AppState> _deletePayment(PaymentRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.paymentIds, EntityAction.delete) store.state.credentials, action.paymentIds, EntityAction.delete)
.then((List<PaymentEntity> payments) { .then((List<PaymentEntity> payments) {
store.dispatch(DeletePaymentSuccess(payments)); store.dispatch(DeletePaymentsSuccess(payments));
store.dispatch(LoadInvoice(invoiceId: payments.first.invoiceId)); store.dispatch(LoadInvoice(invoiceId: payments.first.invoiceId));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(DeletePaymentFailure(prevPayments)); store.dispatch(DeletePaymentsFailure(prevPayments));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -157,7 +157,7 @@ Middleware<AppState> _deletePayment(PaymentRepository repository) {
Middleware<AppState> _restorePayment(PaymentRepository repository) { Middleware<AppState> _restorePayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestorePaymentRequest; final action = dynamicAction as RestorePaymentsRequest;
final prevPayments = action.paymentIds final prevPayments = action.paymentIds
.map((id) => store.state.paymentState.map[id]) .map((id) => store.state.paymentState.map[id])
.toList(); .toList();
@ -165,14 +165,14 @@ Middleware<AppState> _restorePayment(PaymentRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.paymentIds, EntityAction.restore) store.state.credentials, action.paymentIds, EntityAction.restore)
.then((List<PaymentEntity> payments) { .then((List<PaymentEntity> payments) {
store.dispatch(RestorePaymentSuccess(payments)); store.dispatch(RestorePaymentsSuccess(payments));
store.dispatch(LoadInvoice(invoiceId: payments.first.invoiceId)); store.dispatch(LoadInvoice(invoiceId: payments.first.invoiceId));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(RestorePaymentFailure(prevPayments)); store.dispatch(RestorePaymentsFailure(prevPayments));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }

View File

@ -24,9 +24,9 @@ Reducer<String> selectedIdReducer = combineReducers([
final editingReducer = combineReducers<PaymentEntity>([ final editingReducer = combineReducers<PaymentEntity>([
TypedReducer<PaymentEntity, SavePaymentSuccess>(_updateEditing), TypedReducer<PaymentEntity, SavePaymentSuccess>(_updateEditing),
TypedReducer<PaymentEntity, AddPaymentSuccess>(_updateEditing), TypedReducer<PaymentEntity, AddPaymentSuccess>(_updateEditing),
TypedReducer<PaymentEntity, RestorePaymentSuccess>(_updateEditing), TypedReducer<PaymentEntity, RestorePaymentsSuccess>(_updateEditing),
TypedReducer<PaymentEntity, ArchivePaymentSuccess>(_updateEditing), TypedReducer<PaymentEntity, ArchivePaymentsSuccess>(_updateEditing),
TypedReducer<PaymentEntity, DeletePaymentSuccess>(_updateEditing), TypedReducer<PaymentEntity, DeletePaymentsSuccess>(_updateEditing),
TypedReducer<PaymentEntity, EditPayment>(_updateEditing), TypedReducer<PaymentEntity, EditPayment>(_updateEditing),
TypedReducer<PaymentEntity, UpdatePayment>((payment, action) { TypedReducer<PaymentEntity, UpdatePayment>((payment, action) {
return action.payment.rebuild((b) => b..isChanged = true); return action.payment.rebuild((b) => b..isChanged = true);
@ -157,19 +157,19 @@ final paymentsReducer = combineReducers<PaymentState>([
TypedReducer<PaymentState, AddPaymentSuccess>(_addPayment), TypedReducer<PaymentState, AddPaymentSuccess>(_addPayment),
TypedReducer<PaymentState, LoadPaymentsSuccess>(_setLoadedPayments), TypedReducer<PaymentState, LoadPaymentsSuccess>(_setLoadedPayments),
TypedReducer<PaymentState, LoadPaymentSuccess>(_setLoadedPayment), TypedReducer<PaymentState, LoadPaymentSuccess>(_setLoadedPayment),
TypedReducer<PaymentState, ArchivePaymentRequest>(_archivePaymentRequest), TypedReducer<PaymentState, ArchivePaymentsRequest>(_archivePaymentRequest),
TypedReducer<PaymentState, ArchivePaymentSuccess>(_archivePaymentSuccess), TypedReducer<PaymentState, ArchivePaymentsSuccess>(_archivePaymentSuccess),
TypedReducer<PaymentState, ArchivePaymentFailure>(_archivePaymentFailure), TypedReducer<PaymentState, ArchivePaymentsFailure>(_archivePaymentFailure),
TypedReducer<PaymentState, DeletePaymentRequest>(_deletePaymentRequest), TypedReducer<PaymentState, DeletePaymentsRequest>(_deletePaymentRequest),
TypedReducer<PaymentState, DeletePaymentSuccess>(_deletePaymentSuccess), TypedReducer<PaymentState, DeletePaymentsSuccess>(_deletePaymentSuccess),
TypedReducer<PaymentState, DeletePaymentFailure>(_deletePaymentFailure), TypedReducer<PaymentState, DeletePaymentsFailure>(_deletePaymentFailure),
TypedReducer<PaymentState, RestorePaymentRequest>(_restorePaymentRequest), TypedReducer<PaymentState, RestorePaymentsRequest>(_restorePaymentRequest),
TypedReducer<PaymentState, RestorePaymentSuccess>(_restorePaymentSuccess), TypedReducer<PaymentState, RestorePaymentsSuccess>(_restorePaymentSuccess),
TypedReducer<PaymentState, RestorePaymentFailure>(_restorePaymentFailure), TypedReducer<PaymentState, RestorePaymentsFailure>(_restorePaymentFailure),
]); ]);
PaymentState _archivePaymentRequest( PaymentState _archivePaymentRequest(
PaymentState paymentState, ArchivePaymentRequest action) { PaymentState paymentState, ArchivePaymentsRequest action) {
final payments = action.paymentIds.map((id) => paymentState.map[id]).toList(); final payments = action.paymentIds.map((id) => paymentState.map[id]).toList();
for (int i = 0; i < payments.length; i++) { for (int i = 0; i < payments.length; i++) {
@ -184,7 +184,7 @@ PaymentState _archivePaymentRequest(
} }
PaymentState _archivePaymentSuccess( PaymentState _archivePaymentSuccess(
PaymentState paymentState, ArchivePaymentSuccess action) { PaymentState paymentState, ArchivePaymentsSuccess action) {
return paymentState.rebuild((b) { return paymentState.rebuild((b) {
for (final payment in action.payments) { for (final payment in action.payments) {
b.map[payment.id] = payment; b.map[payment.id] = payment;
@ -193,7 +193,7 @@ PaymentState _archivePaymentSuccess(
} }
PaymentState _archivePaymentFailure( PaymentState _archivePaymentFailure(
PaymentState paymentState, ArchivePaymentFailure action) { PaymentState paymentState, ArchivePaymentsFailure action) {
return paymentState.rebuild((b) { return paymentState.rebuild((b) {
for (final payment in action.payments) { for (final payment in action.payments) {
b.map[payment.id] = payment; b.map[payment.id] = payment;
@ -202,7 +202,7 @@ PaymentState _archivePaymentFailure(
} }
PaymentState _deletePaymentRequest( PaymentState _deletePaymentRequest(
PaymentState paymentState, DeletePaymentRequest action) { PaymentState paymentState, DeletePaymentsRequest action) {
final payments = action.paymentIds.map((id) => paymentState.map[id]).toList(); final payments = action.paymentIds.map((id) => paymentState.map[id]).toList();
for (int i = 0; i < payments.length; i++) { for (int i = 0; i < payments.length; i++) {
@ -218,7 +218,7 @@ PaymentState _deletePaymentRequest(
} }
PaymentState _deletePaymentSuccess( PaymentState _deletePaymentSuccess(
PaymentState paymentState, DeletePaymentSuccess action) { PaymentState paymentState, DeletePaymentsSuccess action) {
return paymentState.rebuild((b) { return paymentState.rebuild((b) {
for (final payment in action.payments) { for (final payment in action.payments) {
b.map[payment.id] = payment; b.map[payment.id] = payment;
@ -227,7 +227,7 @@ PaymentState _deletePaymentSuccess(
} }
PaymentState _deletePaymentFailure( PaymentState _deletePaymentFailure(
PaymentState paymentState, DeletePaymentFailure action) { PaymentState paymentState, DeletePaymentsFailure action) {
return paymentState.rebuild((b) { return paymentState.rebuild((b) {
for (final payment in action.payments) { for (final payment in action.payments) {
b.map[payment.id] = payment; b.map[payment.id] = payment;
@ -236,7 +236,7 @@ PaymentState _deletePaymentFailure(
} }
PaymentState _restorePaymentRequest( PaymentState _restorePaymentRequest(
PaymentState paymentState, RestorePaymentRequest action) { PaymentState paymentState, RestorePaymentsRequest action) {
final payments = action.paymentIds.map((id) => paymentState.map[id]).toList(); final payments = action.paymentIds.map((id) => paymentState.map[id]).toList();
for (int i = 0; i < payments.length; i++) { for (int i = 0; i < payments.length; i++) {
@ -252,7 +252,7 @@ PaymentState _restorePaymentRequest(
} }
PaymentState _restorePaymentSuccess( PaymentState _restorePaymentSuccess(
PaymentState paymentState, RestorePaymentSuccess action) { PaymentState paymentState, RestorePaymentsSuccess action) {
return paymentState.rebuild((b) { return paymentState.rebuild((b) {
for (final payment in action.payments) { for (final payment in action.payments) {
b.map[payment.id] = payment; b.map[payment.id] = payment;
@ -261,7 +261,7 @@ PaymentState _restorePaymentSuccess(
} }
PaymentState _restorePaymentFailure( PaymentState _restorePaymentFailure(
PaymentState paymentState, RestorePaymentFailure action) { PaymentState paymentState, RestorePaymentsFailure action) {
return paymentState.rebuild((b) { return paymentState.rebuild((b) {
for (final payment in action.payments) { for (final payment in action.payments) {
b.map[payment.id] = payment; b.map[payment.id] = payment;

View File

@ -105,59 +105,59 @@ class SaveProductFailure implements StopSaving {
final Object error; final Object error;
} }
class ArchiveProductRequest implements StartSaving { class ArchiveProductsRequest implements StartSaving {
ArchiveProductRequest(this.completer, this.productIds); ArchiveProductsRequest(this.completer, this.productIds);
final Completer completer; final Completer completer;
final List<String> productIds; final List<String> productIds;
} }
class ArchiveProductSuccess implements StopSaving, PersistData { class ArchiveProductsSuccess implements StopSaving, PersistData {
ArchiveProductSuccess(this.products); ArchiveProductsSuccess(this.products);
final List<ProductEntity> products; final List<ProductEntity> products;
} }
class ArchiveProductFailure implements StopSaving { class ArchiveProductsFailure implements StopSaving {
ArchiveProductFailure(this.products); ArchiveProductsFailure(this.products);
final List<ProductEntity> products; final List<ProductEntity> products;
} }
class DeleteProductRequest implements StartSaving { class DeleteProductsRequest implements StartSaving {
DeleteProductRequest(this.completer, this.productIds); DeleteProductsRequest(this.completer, this.productIds);
final Completer completer; final Completer completer;
final List<String> productIds; final List<String> productIds;
} }
class DeleteProductSuccess implements StopSaving, PersistData { class DeleteProductsSuccess implements StopSaving, PersistData {
DeleteProductSuccess(this.products); DeleteProductsSuccess(this.products);
final List<ProductEntity> products; final List<ProductEntity> products;
} }
class DeleteProductFailure implements StopSaving { class DeleteProductsFailure implements StopSaving {
DeleteProductFailure(this.products); DeleteProductsFailure(this.products);
final List<ProductEntity> products; final List<ProductEntity> products;
} }
class RestoreProductRequest implements StartSaving { class RestoreProductsRequest implements StartSaving {
RestoreProductRequest(this.completer, this.productIds); RestoreProductsRequest(this.completer, this.productIds);
final Completer completer; final Completer completer;
final List<String> productIds; final List<String> productIds;
} }
class RestoreProductSuccess implements StopSaving, PersistData { class RestoreProductsSuccess implements StopSaving, PersistData {
RestoreProductSuccess(this.products); RestoreProductsSuccess(this.products);
final List<ProductEntity> products; final List<ProductEntity> products;
} }
class RestoreProductFailure implements StopSaving { class RestoreProductsFailure implements StopSaving {
RestoreProductFailure(this.products); RestoreProductsFailure(this.products);
final List<ProductEntity> products; final List<ProductEntity> products;
} }
@ -239,17 +239,17 @@ void handleProductAction(
createEntity(context: context, entity: (product as ProductEntity).clone); createEntity(context: context, entity: (product as ProductEntity).clone);
break; break;
case EntityAction.restore: case EntityAction.restore:
store.dispatch(RestoreProductRequest( store.dispatch(RestoreProductsRequest(
snackBarCompleter<Null>(context, localization.restoredProduct), snackBarCompleter<Null>(context, localization.restoredProduct),
productIds)); productIds));
break; break;
case EntityAction.archive: case EntityAction.archive:
store.dispatch(ArchiveProductRequest( store.dispatch(ArchiveProductsRequest(
snackBarCompleter<Null>(context, localization.archivedProduct), snackBarCompleter<Null>(context, localization.archivedProduct),
productIds)); productIds));
break; break;
case EntityAction.delete: case EntityAction.delete:
store.dispatch(DeleteProductRequest( store.dispatch(DeleteProductsRequest(
snackBarCompleter<Null>(context, localization.deletedProduct), snackBarCompleter<Null>(context, localization.deletedProduct),
productIds)); productIds));
break; break;

View File

@ -30,9 +30,9 @@ List<Middleware<AppState>> createStoreProductsMiddleware([
TypedMiddleware<AppState, EditProduct>(editProduct), TypedMiddleware<AppState, EditProduct>(editProduct),
TypedMiddleware<AppState, LoadProducts>(loadProducts), TypedMiddleware<AppState, LoadProducts>(loadProducts),
TypedMiddleware<AppState, SaveProductRequest>(saveProduct), TypedMiddleware<AppState, SaveProductRequest>(saveProduct),
TypedMiddleware<AppState, ArchiveProductRequest>(archiveProduct), TypedMiddleware<AppState, ArchiveProductsRequest>(archiveProduct),
TypedMiddleware<AppState, DeleteProductRequest>(deleteProduct), TypedMiddleware<AppState, DeleteProductsRequest>(deleteProduct),
TypedMiddleware<AppState, RestoreProductRequest>(restoreProduct), TypedMiddleware<AppState, RestoreProductsRequest>(restoreProduct),
]; ];
} }
@ -101,7 +101,7 @@ Middleware<AppState> _viewProductList() {
Middleware<AppState> _archiveProduct(ProductRepository repository) { Middleware<AppState> _archiveProduct(ProductRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveProductRequest; final action = dynamicAction as ArchiveProductsRequest;
final prevProducts = action.productIds final prevProducts = action.productIds
.map((id) => store.state.productState.map[id]) .map((id) => store.state.productState.map[id])
.toList(); .toList();
@ -109,13 +109,13 @@ Middleware<AppState> _archiveProduct(ProductRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.productIds, EntityAction.archive) store.state.credentials, action.productIds, EntityAction.archive)
.then((List<ProductEntity> products) { .then((List<ProductEntity> products) {
store.dispatch(ArchiveProductSuccess(products)); store.dispatch(ArchiveProductsSuccess(products));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((dynamic error) { }).catchError((dynamic error) {
print(error); print(error);
store.dispatch(ArchiveProductFailure(prevProducts)); store.dispatch(ArchiveProductsFailure(prevProducts));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -127,7 +127,7 @@ Middleware<AppState> _archiveProduct(ProductRepository repository) {
Middleware<AppState> _deleteProduct(ProductRepository repository) { Middleware<AppState> _deleteProduct(ProductRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteProductRequest; final action = dynamicAction as DeleteProductsRequest;
final prevProducts = action.productIds final prevProducts = action.productIds
.map((id) => store.state.productState.map[id]) .map((id) => store.state.productState.map[id])
.toList(); .toList();
@ -135,13 +135,13 @@ Middleware<AppState> _deleteProduct(ProductRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.productIds, EntityAction.delete) store.state.credentials, action.productIds, EntityAction.delete)
.then((List<ProductEntity> products) { .then((List<ProductEntity> products) {
store.dispatch(DeleteProductSuccess(products)); store.dispatch(DeleteProductsSuccess(products));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(DeleteProductFailure(prevProducts)); store.dispatch(DeleteProductsFailure(prevProducts));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -153,7 +153,7 @@ Middleware<AppState> _deleteProduct(ProductRepository repository) {
Middleware<AppState> _restoreProduct(ProductRepository repository) { Middleware<AppState> _restoreProduct(ProductRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreProductRequest; final action = dynamicAction as RestoreProductsRequest;
final prevProducts = action.productIds final prevProducts = action.productIds
.map((id) => store.state.productState.map[id]) .map((id) => store.state.productState.map[id])
.toList(); .toList();
@ -161,13 +161,13 @@ Middleware<AppState> _restoreProduct(ProductRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.productIds, EntityAction.restore) store.state.credentials, action.productIds, EntityAction.restore)
.then((List<ProductEntity> products) { .then((List<ProductEntity> products) {
store.dispatch(RestoreProductSuccess(products)); store.dispatch(RestoreProductsSuccess(products));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(RestoreProductFailure(prevProducts)); store.dispatch(RestoreProductsFailure(prevProducts));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }

View File

@ -31,9 +31,9 @@ final editingReducer = combineReducers<ProductEntity>([
TypedReducer<ProductEntity, UpdateProduct>((product, action) { TypedReducer<ProductEntity, UpdateProduct>((product, action) {
return action.product.rebuild((b) => b..isChanged = true); return action.product.rebuild((b) => b..isChanged = true);
}), }),
TypedReducer<ProductEntity, RestoreProductSuccess>(_updateEditing), TypedReducer<ProductEntity, RestoreProductsSuccess>(_updateEditing),
TypedReducer<ProductEntity, ArchiveProductSuccess>(_updateEditing), TypedReducer<ProductEntity, ArchiveProductsSuccess>(_updateEditing),
TypedReducer<ProductEntity, DeleteProductSuccess>(_updateEditing), TypedReducer<ProductEntity, DeleteProductsSuccess>(_updateEditing),
TypedReducer<ProductEntity, SelectCompany>(_clearEditing), TypedReducer<ProductEntity, SelectCompany>(_clearEditing),
TypedReducer<ProductEntity, DiscardChanges>(_clearEditing), TypedReducer<ProductEntity, DiscardChanges>(_clearEditing),
]); ]);
@ -157,19 +157,19 @@ final productsReducer = combineReducers<ProductState>([
TypedReducer<ProductState, SaveProductSuccess>(_updateProduct), TypedReducer<ProductState, SaveProductSuccess>(_updateProduct),
TypedReducer<ProductState, AddProductSuccess>(_addProduct), TypedReducer<ProductState, AddProductSuccess>(_addProduct),
TypedReducer<ProductState, LoadProductsSuccess>(_setLoadedProducts), TypedReducer<ProductState, LoadProductsSuccess>(_setLoadedProducts),
TypedReducer<ProductState, ArchiveProductRequest>(_archiveProductRequest), TypedReducer<ProductState, ArchiveProductsRequest>(_archiveProductRequest),
TypedReducer<ProductState, ArchiveProductSuccess>(_archiveProductSuccess), TypedReducer<ProductState, ArchiveProductsSuccess>(_archiveProductSuccess),
TypedReducer<ProductState, ArchiveProductFailure>(_archiveProductFailure), TypedReducer<ProductState, ArchiveProductsFailure>(_archiveProductFailure),
TypedReducer<ProductState, DeleteProductRequest>(_deleteProductRequest), TypedReducer<ProductState, DeleteProductsRequest>(_deleteProductRequest),
TypedReducer<ProductState, DeleteProductSuccess>(_deleteProductSuccess), TypedReducer<ProductState, DeleteProductsSuccess>(_deleteProductSuccess),
TypedReducer<ProductState, DeleteProductFailure>(_deleteProductFailure), TypedReducer<ProductState, DeleteProductsFailure>(_deleteProductFailure),
TypedReducer<ProductState, RestoreProductRequest>(_restoreProductRequest), TypedReducer<ProductState, RestoreProductsRequest>(_restoreProductRequest),
TypedReducer<ProductState, RestoreProductSuccess>(_restoreProductSuccess), TypedReducer<ProductState, RestoreProductsSuccess>(_restoreProductSuccess),
TypedReducer<ProductState, RestoreProductFailure>(_restoreProductFailure), TypedReducer<ProductState, RestoreProductsFailure>(_restoreProductFailure),
]); ]);
ProductState _archiveProductRequest( ProductState _archiveProductRequest(
ProductState productState, ArchiveProductRequest action) { ProductState productState, ArchiveProductsRequest action) {
final products = action.productIds.map((id) => productState.map[id]).toList(); final products = action.productIds.map((id) => productState.map[id]).toList();
for (int i = 0; i < products.length; i++) { for (int i = 0; i < products.length; i++) {
@ -184,7 +184,7 @@ ProductState _archiveProductRequest(
} }
ProductState _archiveProductSuccess( ProductState _archiveProductSuccess(
ProductState productState, ArchiveProductSuccess action) { ProductState productState, ArchiveProductsSuccess action) {
return productState.rebuild((b) { return productState.rebuild((b) {
for (final product in action.products) { for (final product in action.products) {
b.map[product.id] = product; b.map[product.id] = product;
@ -193,7 +193,7 @@ ProductState _archiveProductSuccess(
} }
ProductState _archiveProductFailure( ProductState _archiveProductFailure(
ProductState productState, ArchiveProductFailure action) { ProductState productState, ArchiveProductsFailure action) {
return productState.rebuild((b) { return productState.rebuild((b) {
for (final product in action.products) { for (final product in action.products) {
b.map[product.id] = product; b.map[product.id] = product;
@ -202,7 +202,7 @@ ProductState _archiveProductFailure(
} }
ProductState _deleteProductRequest( ProductState _deleteProductRequest(
ProductState productState, DeleteProductRequest action) { ProductState productState, DeleteProductsRequest action) {
final products = action.productIds.map((id) => productState.map[id]).toList(); final products = action.productIds.map((id) => productState.map[id]).toList();
for (int i = 0; i < products.length; i++) { for (int i = 0; i < products.length; i++) {
@ -218,7 +218,7 @@ ProductState _deleteProductRequest(
} }
ProductState _deleteProductSuccess( ProductState _deleteProductSuccess(
ProductState productState, DeleteProductSuccess action) { ProductState productState, DeleteProductsSuccess action) {
return productState.rebuild((b) { return productState.rebuild((b) {
for (final product in action.products) { for (final product in action.products) {
b.map[product.id] = product; b.map[product.id] = product;
@ -227,7 +227,7 @@ ProductState _deleteProductSuccess(
} }
ProductState _deleteProductFailure( ProductState _deleteProductFailure(
ProductState productState, DeleteProductFailure action) { ProductState productState, DeleteProductsFailure action) {
return productState.rebuild((b) { return productState.rebuild((b) {
for (final product in action.products) { for (final product in action.products) {
b.map[product.id] = product; b.map[product.id] = product;
@ -236,7 +236,7 @@ ProductState _deleteProductFailure(
} }
ProductState _restoreProductRequest( ProductState _restoreProductRequest(
ProductState productState, RestoreProductRequest action) { ProductState productState, RestoreProductsRequest action) {
final products = action.productIds.map((id) => productState.map[id]).toList(); final products = action.productIds.map((id) => productState.map[id]).toList();
for (int i = 0; i < products.length; i++) { for (int i = 0; i < products.length; i++) {
@ -252,7 +252,7 @@ ProductState _restoreProductRequest(
} }
ProductState _restoreProductSuccess( ProductState _restoreProductSuccess(
ProductState productState, RestoreProductSuccess action) { ProductState productState, RestoreProductsSuccess action) {
return productState.rebuild((b) { return productState.rebuild((b) {
for (final product in action.products) { for (final product in action.products) {
b.map[product.id] = product; b.map[product.id] = product;
@ -261,7 +261,7 @@ ProductState _restoreProductSuccess(
} }
ProductState _restoreProductFailure( ProductState _restoreProductFailure(
ProductState productState, RestoreProductFailure action) { ProductState productState, RestoreProductsFailure action) {
return productState.rebuild((b) { return productState.rebuild((b) {
for (final product in action.products) { for (final product in action.products) {
b.map[product.id] = product; b.map[product.id] = product;

View File

@ -236,62 +236,62 @@ class MarkSentQuoteFailure implements StopSaving {
final InvoiceEntity quote; final InvoiceEntity quote;
} }
class ArchiveQuoteRequest implements StartSaving { class ArchiveQuotesRequest implements StartSaving {
ArchiveQuoteRequest(this.completer, this.quoteIds); ArchiveQuotesRequest(this.completer, this.quoteIds);
final Completer completer; final Completer completer;
final List<String> quoteIds; final List<String> quoteIds;
} }
class ArchiveQuoteSuccess implements StopSaving, PersistData { class ArchiveQuotesSuccess implements StopSaving, PersistData {
ArchiveQuoteSuccess(this.quotes); ArchiveQuotesSuccess(this.quotes);
final List<InvoiceEntity> quotes; final List<InvoiceEntity> quotes;
} }
class ArchiveQuoteFailure implements StopSaving { class ArchiveQuotesFailure implements StopSaving {
ArchiveQuoteFailure(this.quotes); ArchiveQuotesFailure(this.quotes);
final List<InvoiceEntity> quotes; final List<InvoiceEntity> quotes;
} }
class DeleteQuoteRequest implements StartSaving { class DeleteQuotesRequest implements StartSaving {
DeleteQuoteRequest(this.completer, this.quoteIds); DeleteQuotesRequest(this.completer, this.quoteIds);
final Completer completer; final Completer completer;
final List<String> quoteIds; final List<String> quoteIds;
} }
class DeleteQuoteSuccess implements StopSaving, PersistData { class DeleteQuotesSuccess implements StopSaving, PersistData {
DeleteQuoteSuccess(this.quotes); DeleteQuotesSuccess(this.quotes);
final List<InvoiceEntity> quotes; final List<InvoiceEntity> quotes;
} }
class DeleteQuoteFailure implements StopSaving { class DeleteQuotesFailure implements StopSaving {
DeleteQuoteFailure(this.quotes); DeleteQuotesFailure(this.quotes);
final List<InvoiceEntity> quotes; final List<InvoiceEntity> quotes;
} }
class RestoreQuoteRequest implements StartSaving { class RestoreQuotesRequest implements StartSaving {
RestoreQuoteRequest(this.completer, this.quoteIds); RestoreQuotesRequest(this.completer, this.quoteIds);
final Completer completer; final Completer completer;
final List<String> quoteIds; final List<String> quoteIds;
} }
class RestoreQuoteSuccess implements StopSaving, PersistData { class RestoreQuotesSuccess implements StopSaving, PersistData {
RestoreQuoteSuccess(this.quotes); RestoreQuotesSuccess(this.quotes);
final List<InvoiceEntity> quotes; final List<InvoiceEntity> quotes;
} }
class RestoreQuoteFailure implements StopSaving { class RestoreQuotesFailure implements StopSaving {
RestoreQuoteFailure(this.quotes); RestoreQuotesFailure(this.quotes);
final List<InvoiceEntity> quotes; final List<InvoiceEntity> quotes;
} }
@ -443,17 +443,17 @@ Future handleQuoteAction(
createEntity(context: context, entity: quote.clone); createEntity(context: context, entity: quote.clone);
break; break;
case EntityAction.restore: case EntityAction.restore:
store.dispatch(RestoreQuoteRequest( store.dispatch(RestoreQuotesRequest(
snackBarCompleter<Null>(context, localization.restoredQuote), snackBarCompleter<Null>(context, localization.restoredQuote),
quoteIds)); quoteIds));
break; break;
case EntityAction.archive: case EntityAction.archive:
store.dispatch(ArchiveQuoteRequest( store.dispatch(ArchiveQuotesRequest(
snackBarCompleter<Null>(context, localization.archivedQuote), snackBarCompleter<Null>(context, localization.archivedQuote),
quoteIds)); quoteIds));
break; break;
case EntityAction.delete: case EntityAction.delete:
store.dispatch(DeleteQuoteRequest( store.dispatch(DeleteQuotesRequest(
snackBarCompleter<Null>(context, localization.deletedQuote), snackBarCompleter<Null>(context, localization.deletedQuote),
quoteIds)); quoteIds));
break; break;

View File

@ -41,9 +41,9 @@ List<Middleware<AppState>> createStoreQuotesMiddleware([
TypedMiddleware<AppState, LoadQuotes>(loadQuotes), TypedMiddleware<AppState, LoadQuotes>(loadQuotes),
TypedMiddleware<AppState, LoadQuote>(loadQuote), TypedMiddleware<AppState, LoadQuote>(loadQuote),
TypedMiddleware<AppState, SaveQuoteRequest>(saveQuote), TypedMiddleware<AppState, SaveQuoteRequest>(saveQuote),
TypedMiddleware<AppState, ArchiveQuoteRequest>(archiveQuote), TypedMiddleware<AppState, ArchiveQuotesRequest>(archiveQuote),
TypedMiddleware<AppState, DeleteQuoteRequest>(deleteQuote), TypedMiddleware<AppState, DeleteQuotesRequest>(deleteQuote),
TypedMiddleware<AppState, RestoreQuoteRequest>(restoreQuote), TypedMiddleware<AppState, RestoreQuotesRequest>(restoreQuote),
TypedMiddleware<AppState, EmailQuoteRequest>(emailQuote), TypedMiddleware<AppState, EmailQuoteRequest>(emailQuote),
TypedMiddleware<AppState, MarkSentQuoteRequest>(markSentQuote), TypedMiddleware<AppState, MarkSentQuoteRequest>(markSentQuote),
]; ];
@ -134,20 +134,20 @@ Middleware<AppState> _showEmailQuote() {
Middleware<AppState> _archiveQuote(QuoteRepository repository) { Middleware<AppState> _archiveQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveQuoteRequest; final action = dynamicAction as ArchiveQuotesRequest;
final prevQuotes = final prevQuotes =
action.quoteIds.map((id) => store.state.quoteState.map[id]).toList(); action.quoteIds.map((id) => store.state.quoteState.map[id]).toList();
repository repository
.bulkAction( .bulkAction(
store.state.credentials, action.quoteIds, EntityAction.archive) store.state.credentials, action.quoteIds, EntityAction.archive)
.then((List<InvoiceEntity> quotes) { .then((List<InvoiceEntity> quotes) {
store.dispatch(ArchiveQuoteSuccess(quotes)); store.dispatch(ArchiveQuotesSuccess(quotes));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(ArchiveQuoteFailure(prevQuotes)); store.dispatch(ArchiveQuotesFailure(prevQuotes));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -159,7 +159,7 @@ Middleware<AppState> _archiveQuote(QuoteRepository repository) {
Middleware<AppState> _deleteQuote(QuoteRepository repository) { Middleware<AppState> _deleteQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteQuoteRequest; final action = dynamicAction as DeleteQuotesRequest;
final prevQuotes = final prevQuotes =
action.quoteIds.map((id) => store.state.quoteState.map[id]).toList(); action.quoteIds.map((id) => store.state.quoteState.map[id]).toList();
@ -167,13 +167,13 @@ Middleware<AppState> _deleteQuote(QuoteRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.quoteIds, EntityAction.delete) store.state.credentials, action.quoteIds, EntityAction.delete)
.then((List<InvoiceEntity> quotes) { .then((List<InvoiceEntity> quotes) {
store.dispatch(DeleteQuoteSuccess(quotes)); store.dispatch(DeleteQuotesSuccess(quotes));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(DeleteQuoteFailure(prevQuotes)); store.dispatch(DeleteQuotesFailure(prevQuotes));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }
@ -185,7 +185,7 @@ Middleware<AppState> _deleteQuote(QuoteRepository repository) {
Middleware<AppState> _restoreQuote(QuoteRepository repository) { Middleware<AppState> _restoreQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreQuoteRequest; final action = dynamicAction as RestoreQuotesRequest;
final prevQuotes = final prevQuotes =
action.quoteIds.map((id) => store.state.quoteState.map[id]).toList(); action.quoteIds.map((id) => store.state.quoteState.map[id]).toList();
@ -193,13 +193,13 @@ Middleware<AppState> _restoreQuote(QuoteRepository repository) {
.bulkAction( .bulkAction(
store.state.credentials, action.quoteIds, EntityAction.restore) store.state.credentials, action.quoteIds, EntityAction.restore)
.then((List<InvoiceEntity> quotes) { .then((List<InvoiceEntity> quotes) {
store.dispatch(RestoreQuoteSuccess(quotes)); store.dispatch(RestoreQuotesSuccess(quotes));
if (action.completer != null) { if (action.completer != null) {
action.completer.complete(null); action.completer.complete(null);
} }
}).catchError((Object error) { }).catchError((Object error) {
print(error); print(error);
store.dispatch(RestoreQuoteFailure(prevQuotes)); store.dispatch(RestoreQuotesFailure(prevQuotes));
if (action.completer != null) { if (action.completer != null) {
action.completer.completeError(error); action.completer.completeError(error);
} }

View File

@ -62,9 +62,9 @@ final editingReducer = combineReducers<InvoiceEntity>([
..invitations.addAll(client.contacts ..invitations.addAll(client.contacts
.map((contact) => InvitationEntity(contactId: contact.id)))); .map((contact) => InvitationEntity(contactId: contact.id))));
}), }),
TypedReducer<InvoiceEntity, RestoreQuoteSuccess>(_updateEditing), TypedReducer<InvoiceEntity, RestoreQuotesSuccess>(_updateEditing),
TypedReducer<InvoiceEntity, ArchiveQuoteSuccess>(_updateEditing), TypedReducer<InvoiceEntity, ArchiveQuotesSuccess>(_updateEditing),
TypedReducer<InvoiceEntity, DeleteQuoteSuccess>(_updateEditing), TypedReducer<InvoiceEntity, DeleteQuotesSuccess>(_updateEditing),
TypedReducer<InvoiceEntity, AddQuoteItem>(_addQuoteItem), TypedReducer<InvoiceEntity, AddQuoteItem>(_addQuoteItem),
TypedReducer<InvoiceEntity, AddQuoteItems>(_addQuoteItems), TypedReducer<InvoiceEntity, AddQuoteItems>(_addQuoteItems),
TypedReducer<InvoiceEntity, DeleteQuoteItem>(_removeQuoteItem), TypedReducer<InvoiceEntity, DeleteQuoteItem>(_removeQuoteItem),
@ -235,15 +235,15 @@ final quotesReducer = combineReducers<QuoteState>([
TypedReducer<QuoteState, LoadQuotesSuccess>(_setLoadedQuotes), TypedReducer<QuoteState, LoadQuotesSuccess>(_setLoadedQuotes),
TypedReducer<QuoteState, LoadQuoteSuccess>(_updateQuote), TypedReducer<QuoteState, LoadQuoteSuccess>(_updateQuote),
TypedReducer<QuoteState, MarkSentQuoteSuccess>(_markSentQuoteSuccess), TypedReducer<QuoteState, MarkSentQuoteSuccess>(_markSentQuoteSuccess),
TypedReducer<QuoteState, ArchiveQuoteRequest>(_archiveQuoteRequest), TypedReducer<QuoteState, ArchiveQuotesRequest>(_archiveQuoteRequest),
TypedReducer<QuoteState, ArchiveQuoteSuccess>(_archiveQuoteSuccess), TypedReducer<QuoteState, ArchiveQuotesSuccess>(_archiveQuoteSuccess),
TypedReducer<QuoteState, ArchiveQuoteFailure>(_archiveQuoteFailure), TypedReducer<QuoteState, ArchiveQuotesFailure>(_archiveQuoteFailure),
TypedReducer<QuoteState, DeleteQuoteRequest>(_deleteQuoteRequest), TypedReducer<QuoteState, DeleteQuotesRequest>(_deleteQuoteRequest),
TypedReducer<QuoteState, DeleteQuoteSuccess>(_deleteQuoteSuccess), TypedReducer<QuoteState, DeleteQuotesSuccess>(_deleteQuoteSuccess),
TypedReducer<QuoteState, DeleteQuoteFailure>(_deleteQuoteFailure), TypedReducer<QuoteState, DeleteQuotesFailure>(_deleteQuoteFailure),
TypedReducer<QuoteState, RestoreQuoteRequest>(_restoreQuoteRequest), TypedReducer<QuoteState, RestoreQuotesRequest>(_restoreQuoteRequest),
TypedReducer<QuoteState, RestoreQuoteSuccess>(_restoreQuoteSuccess), TypedReducer<QuoteState, RestoreQuotesSuccess>(_restoreQuoteSuccess),
TypedReducer<QuoteState, RestoreQuoteFailure>(_restoreQuoteFailure), TypedReducer<QuoteState, RestoreQuotesFailure>(_restoreQuoteFailure),
TypedReducer<QuoteState, ConvertQuoteSuccess>(_convertQuoteSuccess), TypedReducer<QuoteState, ConvertQuoteSuccess>(_convertQuoteSuccess),
]); ]);
@ -253,7 +253,7 @@ QuoteState _markSentQuoteSuccess(
} }
QuoteState _archiveQuoteRequest( QuoteState _archiveQuoteRequest(
QuoteState quoteState, ArchiveQuoteRequest action) { QuoteState quoteState, ArchiveQuotesRequest action) {
final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList(); final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList();
for (int i = 0; i < quotes.length; i++) { for (int i = 0; i < quotes.length; i++) {
@ -268,7 +268,7 @@ QuoteState _archiveQuoteRequest(
} }
QuoteState _archiveQuoteSuccess( QuoteState _archiveQuoteSuccess(
QuoteState quoteState, ArchiveQuoteSuccess action) { QuoteState quoteState, ArchiveQuotesSuccess action) {
return quoteState.rebuild((b) { return quoteState.rebuild((b) {
for (final quote in action.quotes) { for (final quote in action.quotes) {
b.map[quote.id] = quote; b.map[quote.id] = quote;
@ -277,7 +277,7 @@ QuoteState _archiveQuoteSuccess(
} }
QuoteState _archiveQuoteFailure( QuoteState _archiveQuoteFailure(
QuoteState quoteState, ArchiveQuoteFailure action) { QuoteState quoteState, ArchiveQuotesFailure action) {
return quoteState.rebuild((b) { return quoteState.rebuild((b) {
for (final quote in action.quotes) { for (final quote in action.quotes) {
b.map[quote.id] = quote; b.map[quote.id] = quote;
@ -286,7 +286,7 @@ QuoteState _archiveQuoteFailure(
} }
QuoteState _deleteQuoteRequest( QuoteState _deleteQuoteRequest(
QuoteState quoteState, DeleteQuoteRequest action) { QuoteState quoteState, DeleteQuotesRequest action) {
final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList(); final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList();
for (int i = 0; i < quotes.length; i++) { for (int i = 0; i < quotes.length; i++) {
@ -302,7 +302,7 @@ QuoteState _deleteQuoteRequest(
} }
QuoteState _deleteQuoteSuccess( QuoteState _deleteQuoteSuccess(
QuoteState quoteState, DeleteQuoteSuccess action) { QuoteState quoteState, DeleteQuotesSuccess action) {
return quoteState.rebuild((b) { return quoteState.rebuild((b) {
for (final quote in action.quotes) { for (final quote in action.quotes) {
b.map[quote.id] = quote; b.map[quote.id] = quote;
@ -311,7 +311,7 @@ QuoteState _deleteQuoteSuccess(
} }
QuoteState _deleteQuoteFailure( QuoteState _deleteQuoteFailure(
QuoteState quoteState, DeleteQuoteFailure action) { QuoteState quoteState, DeleteQuotesFailure action) {
return quoteState.rebuild((b) { return quoteState.rebuild((b) {
for (final quote in action.quotes) { for (final quote in action.quotes) {
b.map[quote.id] = quote; b.map[quote.id] = quote;
@ -320,7 +320,7 @@ QuoteState _deleteQuoteFailure(
} }
QuoteState _restoreQuoteRequest( QuoteState _restoreQuoteRequest(
QuoteState quoteState, RestoreQuoteRequest action) { QuoteState quoteState, RestoreQuotesRequest action) {
final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList(); final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList();
for (int i = 0; i < quotes.length; i++) { for (int i = 0; i < quotes.length; i++) {
@ -336,7 +336,7 @@ QuoteState _restoreQuoteRequest(
} }
QuoteState _restoreQuoteSuccess( QuoteState _restoreQuoteSuccess(
QuoteState quoteState, RestoreQuoteSuccess action) { QuoteState quoteState, RestoreQuotesSuccess action) {
return quoteState.rebuild((b) { return quoteState.rebuild((b) {
for (final quote in action.quotes) { for (final quote in action.quotes) {
b.map[quote.id] = quote; b.map[quote.id] = quote;
@ -345,7 +345,7 @@ QuoteState _restoreQuoteSuccess(
} }
QuoteState _restoreQuoteFailure( QuoteState _restoreQuoteFailure(
QuoteState quoteState, RestoreQuoteFailure action) { QuoteState quoteState, RestoreQuotesFailure action) {
return quoteState.rebuild((b) { return quoteState.rebuild((b) {
for (final quote in action.quotes) { for (final quote in action.quotes) {
b.map[quote.id] = quote; b.map[quote.id] = quote;

View File

@ -12,6 +12,11 @@ class EntityStateTitle extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
print('## Build');
print('## Archivd At: ${entity.archivedAt}');
print('## isDeleted: ${entity.isDeleted}');
final state = entity.entityState; final state = entity.entityState;
if (state == kEntityStateActive) { if (state == kEntityStateActive) {