Merge pull request #97 from gincos/develop
Refactor modules to use /bulk and ListFilterMessage
This commit is contained in:
commit
6d5d255dc9
|
|
@ -60,7 +60,7 @@ class ClientRepository {
|
|||
if (action != null) {
|
||||
url += '&action=' + action.toString();
|
||||
}
|
||||
response = await webClient.put(url, credentials.token,
|
||||
response = await webClient.post(url, credentials.token,
|
||||
data: json.encode([ids]));
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -44,6 +44,32 @@ class InvoiceRepository {
|
|||
return invoiceResponse.data;
|
||||
}
|
||||
|
||||
Future<List<InvoiceEntity>> bulkAction(
|
||||
Credentials credentials, List<String> ids, EntityAction action) async {
|
||||
dynamic response;
|
||||
|
||||
switch (action) {
|
||||
case EntityAction.restore:
|
||||
case EntityAction.archive:
|
||||
case EntityAction.delete:
|
||||
var url = credentials.url + '/invoices/bulk?include=activities';
|
||||
if (action != null) {
|
||||
url += '&action=' + action.toString();
|
||||
}
|
||||
response = await webClient.post(url, credentials.token,
|
||||
data: json.encode([ids]));
|
||||
break;
|
||||
default:
|
||||
// Might have other actions in the future
|
||||
break;
|
||||
}
|
||||
|
||||
final InvoiceListResponse invoiceResponse =
|
||||
serializers.deserializeWith(InvoiceListResponse.serializer, response);
|
||||
|
||||
return invoiceResponse.data.toList();
|
||||
}
|
||||
|
||||
Future<InvoiceEntity> saveData(Credentials credentials, InvoiceEntity invoice,
|
||||
[EntityAction action]) async {
|
||||
final data = serializers.serializeWith(InvoiceEntity.serializer, invoice);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,32 @@ class PaymentRepository {
|
|||
return paymentResponse.data;
|
||||
}
|
||||
|
||||
Future<List<PaymentEntity>> bulkAction(
|
||||
Credentials credentials, List<String> ids, EntityAction action) async {
|
||||
dynamic response;
|
||||
|
||||
switch (action) {
|
||||
case EntityAction.restore:
|
||||
case EntityAction.archive:
|
||||
case EntityAction.delete:
|
||||
var url = credentials.url + '/payments/bulk?include=activities';
|
||||
if (action != null) {
|
||||
url += '&action=' + action.toString();
|
||||
}
|
||||
response = await webClient.post(url, credentials.token,
|
||||
data: json.encode([ids]));
|
||||
break;
|
||||
default:
|
||||
// Might have other actions in the future
|
||||
break;
|
||||
}
|
||||
|
||||
final PaymentListResponse paymentResponse =
|
||||
serializers.deserializeWith(PaymentListResponse.serializer, response);
|
||||
|
||||
return paymentResponse.data.toList();
|
||||
}
|
||||
|
||||
Future<PaymentEntity> saveData(Credentials credentials, PaymentEntity payment,
|
||||
{EntityAction action, bool sendEmail = false}) async {
|
||||
final data = serializers.serializeWith(PaymentEntity.serializer, payment);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,32 @@ class ProductRepository {
|
|||
return productResponse.data;
|
||||
}
|
||||
|
||||
Future<List<ProductEntity>> bulkAction(
|
||||
Credentials credentials, List<String> ids, EntityAction action) async {
|
||||
dynamic response;
|
||||
|
||||
switch (action) {
|
||||
case EntityAction.restore:
|
||||
case EntityAction.archive:
|
||||
case EntityAction.delete:
|
||||
var url = credentials.url + '/products/bulk?include=activities';
|
||||
if (action != null) {
|
||||
url += '&action=' + action.toString();
|
||||
}
|
||||
response = await webClient.post(url, credentials.token,
|
||||
data: json.encode([ids]));
|
||||
break;
|
||||
default:
|
||||
// Might have other actions in the future
|
||||
break;
|
||||
}
|
||||
|
||||
final ProductListResponse productResponse =
|
||||
serializers.deserializeWith(ProductListResponse.serializer, response);
|
||||
|
||||
return productResponse.data.toList();
|
||||
}
|
||||
|
||||
Future<ProductEntity> saveData(Credentials credentials, ProductEntity product,
|
||||
[EntityAction action]) async {
|
||||
final data = serializers.serializeWith(ProductEntity.serializer, product);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,32 @@ class QuoteRepository {
|
|||
return quoteResponse.data;
|
||||
}
|
||||
|
||||
Future<List<InvoiceEntity>> bulkAction(
|
||||
Credentials credentials, List<String> ids, EntityAction action) async {
|
||||
dynamic response;
|
||||
|
||||
switch (action) {
|
||||
case EntityAction.restore:
|
||||
case EntityAction.archive:
|
||||
case EntityAction.delete:
|
||||
var url = credentials.url + '/quotes/bulk?include=activities';
|
||||
if (action != null) {
|
||||
url += '&action=' + action.toString();
|
||||
}
|
||||
response = await webClient.post(url, credentials.token,
|
||||
data: json.encode([ids]));
|
||||
break;
|
||||
default:
|
||||
// Might have other actions in the future
|
||||
break;
|
||||
}
|
||||
|
||||
final InvoiceListResponse invoiceResponse =
|
||||
serializers.deserializeWith(InvoiceListResponse.serializer, response);
|
||||
|
||||
return invoiceResponse.data.toList();
|
||||
}
|
||||
|
||||
Future<InvoiceEntity> saveData(Credentials credentials, InvoiceEntity quote,
|
||||
[EntityAction action]) async {
|
||||
final data = serializers.serializeWith(InvoiceEntity.serializer, quote);
|
||||
|
|
|
|||
|
|
@ -214,60 +214,60 @@ class MarkSentInvoiceFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class ArchiveInvoiceRequest implements StartSaving {
|
||||
ArchiveInvoiceRequest(this.completer, this.invoiceId);
|
||||
ArchiveInvoiceRequest(this.completer, this.invoiceIds);
|
||||
|
||||
final Completer completer;
|
||||
final String invoiceId;
|
||||
final List<String> invoiceIds;
|
||||
}
|
||||
|
||||
class ArchiveInvoiceSuccess implements StopSaving, PersistData {
|
||||
ArchiveInvoiceSuccess(this.invoice);
|
||||
ArchiveInvoiceSuccess(this.invoices);
|
||||
|
||||
final InvoiceEntity invoice;
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class ArchiveInvoiceFailure implements StopSaving {
|
||||
ArchiveInvoiceFailure(this.invoice);
|
||||
ArchiveInvoiceFailure(this.invoices);
|
||||
|
||||
final InvoiceEntity invoice;
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class DeleteInvoiceRequest implements StartSaving {
|
||||
DeleteInvoiceRequest(this.completer, this.invoiceId);
|
||||
DeleteInvoiceRequest(this.completer, this.invoiceIds);
|
||||
|
||||
final Completer completer;
|
||||
final String invoiceId;
|
||||
final List<String> invoiceIds;
|
||||
}
|
||||
|
||||
class DeleteInvoiceSuccess implements StopSaving, PersistData {
|
||||
DeleteInvoiceSuccess(this.invoice);
|
||||
DeleteInvoiceSuccess(this.invoices);
|
||||
|
||||
final InvoiceEntity invoice;
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class DeleteInvoiceFailure implements StopSaving {
|
||||
DeleteInvoiceFailure(this.invoice);
|
||||
DeleteInvoiceFailure(this.invoices);
|
||||
|
||||
final InvoiceEntity invoice;
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class RestoreInvoiceRequest implements StartSaving {
|
||||
RestoreInvoiceRequest(this.completer, this.invoiceId);
|
||||
RestoreInvoiceRequest(this.completer, this.invoiceIds);
|
||||
|
||||
final Completer completer;
|
||||
final String invoiceId;
|
||||
final List<String> invoiceIds;
|
||||
}
|
||||
|
||||
class RestoreInvoiceSuccess implements StopSaving, PersistData {
|
||||
RestoreInvoiceSuccess(this.invoice);
|
||||
RestoreInvoiceSuccess(this.invoices);
|
||||
|
||||
final InvoiceEntity invoice;
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class RestoreInvoiceFailure implements StopSaving {
|
||||
RestoreInvoiceFailure(this.invoice);
|
||||
RestoreInvoiceFailure(this.invoices);
|
||||
|
||||
final InvoiceEntity invoice;
|
||||
final List<InvoiceEntity> invoices;
|
||||
}
|
||||
|
||||
class FilterInvoices {
|
||||
|
|
@ -336,6 +336,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
|||
final CompanyEntity company = state.selectedCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final invoice = invoices.first as InvoiceEntity;
|
||||
final invoiceIds = invoices.map((invoice) => invoice.id).toList();
|
||||
|
||||
switch (action) {
|
||||
case EntityAction.edit:
|
||||
|
|
@ -375,16 +376,16 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
|||
case EntityAction.restore:
|
||||
store.dispatch(RestoreInvoiceRequest(
|
||||
snackBarCompleter(context, localization.restoredInvoice),
|
||||
invoice.id));
|
||||
invoiceIds));
|
||||
break;
|
||||
case EntityAction.archive:
|
||||
store.dispatch(ArchiveInvoiceRequest(
|
||||
snackBarCompleter(context, localization.archivedInvoice),
|
||||
invoice.id));
|
||||
invoiceIds));
|
||||
break;
|
||||
case EntityAction.delete:
|
||||
store.dispatch(DeleteInvoiceRequest(
|
||||
snackBarCompleter(context, localization.deletedInvoice), invoice.id));
|
||||
snackBarCompleter(context, localization.deletedInvoice), invoiceIds));
|
||||
break;
|
||||
case EntityAction.toggleMultiselect:
|
||||
if (!store.state.invoiceListState.isInMultiselect()) {
|
||||
|
|
|
|||
|
|
@ -137,17 +137,20 @@ Middleware<AppState> _showEmailInvoice() {
|
|||
Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as ArchiveInvoiceRequest;
|
||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origInvoice, EntityAction.archive)
|
||||
.then((InvoiceEntity invoice) {
|
||||
store.dispatch(ArchiveInvoiceSuccess(invoice));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.invoiceIds, EntityAction.archive)
|
||||
.then((List<InvoiceEntity> invoices) {
|
||||
store.dispatch(ArchiveInvoiceSuccess(invoices));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(ArchiveInvoiceFailure(origInvoice));
|
||||
final invoices = action.invoiceIds
|
||||
.map((id) => store.state.invoiceState.map[id])
|
||||
.toList();
|
||||
store.dispatch(ArchiveInvoiceFailure(invoices));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
@ -160,18 +163,21 @@ Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
|
|||
Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as DeleteInvoiceRequest;
|
||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origInvoice, EntityAction.delete)
|
||||
.then((InvoiceEntity invoice) {
|
||||
store.dispatch(DeleteInvoiceSuccess(invoice));
|
||||
store.dispatch(LoadClient(clientId: invoice.clientId));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.invoiceIds, EntityAction.delete)
|
||||
.then((List<InvoiceEntity> invoices) {
|
||||
store.dispatch(DeleteInvoiceSuccess(invoices));
|
||||
store.dispatch(LoadClient(clientId: invoices.first.clientId));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(DeleteInvoiceFailure(origInvoice));
|
||||
final invoices = action.invoiceIds
|
||||
.map((id) => store.state.invoiceState.map[id])
|
||||
.toList();
|
||||
store.dispatch(DeleteInvoiceFailure(invoices));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
@ -184,18 +190,21 @@ Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
|
|||
Middleware<AppState> _restoreInvoice(InvoiceRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as RestoreInvoiceRequest;
|
||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origInvoice, EntityAction.restore)
|
||||
.then((InvoiceEntity invoice) {
|
||||
store.dispatch(RestoreInvoiceSuccess(invoice));
|
||||
store.dispatch(LoadClient(clientId: invoice.clientId));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.invoiceIds, EntityAction.restore)
|
||||
.then((List<InvoiceEntity> invoices) {
|
||||
store.dispatch(RestoreInvoiceSuccess(invoices));
|
||||
store.dispatch(LoadClient(clientId: invoices.first.clientId));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(RestoreInvoiceFailure(origInvoice));
|
||||
final invoices = action.invoiceIds
|
||||
.map((id) => store.state.invoiceState.map[id])
|
||||
.toList();
|
||||
store.dispatch(RestoreInvoiceFailure(invoices));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ InvoiceItemEntity editInvoiceItem(
|
|||
}
|
||||
|
||||
Reducer<String> dropdownFilterReducer = combineReducers([
|
||||
TypedReducer<String, FilterInvoiceDropdown>(filterClientDropdownReducer),
|
||||
TypedReducer<String, FilterInvoiceDropdown>(filterInvoiceDropdownReducer),
|
||||
]);
|
||||
|
||||
String filterClientDropdownReducer(
|
||||
String filterInvoiceDropdownReducer(
|
||||
String dropdownFilter, FilterInvoiceDropdown action) {
|
||||
return action.filter;
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ final editingReducer = combineReducers<InvoiceEntity>([
|
|||
TypedReducer<InvoiceEntity, DiscardChanges>(_clearEditing),
|
||||
]);
|
||||
|
||||
InvoiceEntity _clearEditing(InvoiceEntity client, dynamic action) {
|
||||
InvoiceEntity _clearEditing(InvoiceEntity invoice, dynamic action) {
|
||||
return InvoiceEntity();
|
||||
}
|
||||
|
||||
|
|
@ -228,75 +228,104 @@ InvoiceState _markSentInvoiceSuccess(
|
|||
|
||||
InvoiceState _archiveInvoiceRequest(
|
||||
InvoiceState invoiceState, ArchiveInvoiceRequest action) {
|
||||
final invoice = invoiceState.map[action.invoiceId]
|
||||
.rebuild((b) => b..archivedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList();
|
||||
|
||||
return invoiceState.rebuild((b) => b..map[action.invoiceId] = invoice);
|
||||
for (int i = 0; i < invoices.length; i++) {
|
||||
invoices[i] = invoices[i]
|
||||
.rebuild((b) => b..archivedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
}
|
||||
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _archiveInvoiceSuccess(
|
||||
InvoiceState invoiceState, ArchiveInvoiceSuccess action) {
|
||||
return invoiceState
|
||||
.rebuild((b) => b..map[action.invoice.id] = action.invoice);
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in action.invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _archiveInvoiceFailure(
|
||||
InvoiceState invoiceState, ArchiveInvoiceFailure action) {
|
||||
return invoiceState
|
||||
.rebuild((b) => b..map[action.invoice.id] = action.invoice);
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in action.invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _deleteInvoiceRequest(
|
||||
InvoiceState invoiceState, DeleteInvoiceRequest action) {
|
||||
if (!invoiceState.map.containsKey(action.invoiceId)) {
|
||||
return invoiceState;
|
||||
final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList();
|
||||
|
||||
for (int i = 0; i < invoices.length; i++) {
|
||||
invoices[i] = invoices[i].rebuild((b) => b
|
||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isDeleted = true);
|
||||
}
|
||||
|
||||
final invoice = invoiceState.map[action.invoiceId].rebuild((b) => b
|
||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isDeleted = true);
|
||||
|
||||
return invoiceState.rebuild((b) => b..map[action.invoiceId] = invoice);
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _deleteInvoiceSuccess(
|
||||
InvoiceState invoiceState, DeleteInvoiceSuccess action) {
|
||||
if (!invoiceState.map.containsKey(action.invoice.id)) {
|
||||
return invoiceState;
|
||||
}
|
||||
|
||||
return invoiceState
|
||||
.rebuild((b) => b..map[action.invoice.id] = action.invoice);
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in action.invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _deleteInvoiceFailure(
|
||||
InvoiceState invoiceState, DeleteInvoiceFailure action) {
|
||||
if (!invoiceState.map.containsKey(action.invoice.id)) {
|
||||
return invoiceState;
|
||||
}
|
||||
|
||||
return invoiceState
|
||||
.rebuild((b) => b..map[action.invoice.id] = action.invoice);
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in action.invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _restoreInvoiceRequest(
|
||||
InvoiceState invoiceState, RestoreInvoiceRequest action) {
|
||||
final invoice = invoiceState.map[action.invoiceId].rebuild((b) => b
|
||||
..archivedAt = null
|
||||
..isDeleted = false);
|
||||
return invoiceState.rebuild((b) => b..map[action.invoiceId] = invoice);
|
||||
final invoices = action.invoiceIds.map((id) => invoiceState.map[id]).toList();
|
||||
|
||||
for (int i = 0; i < invoices.length; i++) {
|
||||
invoices[i] = invoices[i].rebuild((b) => b
|
||||
..archivedAt = null
|
||||
..isDeleted = false);
|
||||
}
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _restoreInvoiceSuccess(
|
||||
InvoiceState invoiceState, RestoreInvoiceSuccess action) {
|
||||
return invoiceState
|
||||
.rebuild((b) => b..map[action.invoice.id] = action.invoice);
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in action.invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _restoreInvoiceFailure(
|
||||
InvoiceState invoiceState, RestoreInvoiceFailure action) {
|
||||
return invoiceState
|
||||
.rebuild((b) => b..map[action.invoice.id] = action.invoice);
|
||||
return invoiceState.rebuild((b) {
|
||||
for (final invoice in action.invoices) {
|
||||
b.map[invoice.id] = invoice;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
InvoiceState _addInvoice(InvoiceState invoiceState, AddInvoiceSuccess action) {
|
||||
|
|
|
|||
|
|
@ -143,60 +143,60 @@ class SavePaymentFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class ArchivePaymentRequest implements StartSaving {
|
||||
ArchivePaymentRequest(this.completer, this.paymentId);
|
||||
ArchivePaymentRequest(this.completer, this.paymentIds);
|
||||
|
||||
final Completer completer;
|
||||
final String paymentId;
|
||||
final List<String> paymentIds;
|
||||
}
|
||||
|
||||
class ArchivePaymentSuccess implements StopSaving, PersistData {
|
||||
ArchivePaymentSuccess(this.payment);
|
||||
ArchivePaymentSuccess(this.payments);
|
||||
|
||||
final PaymentEntity payment;
|
||||
final List<PaymentEntity> payments;
|
||||
}
|
||||
|
||||
class ArchivePaymentFailure implements StopSaving {
|
||||
ArchivePaymentFailure(this.payment);
|
||||
ArchivePaymentFailure(this.payments);
|
||||
|
||||
final PaymentEntity payment;
|
||||
final List<PaymentEntity> payments;
|
||||
}
|
||||
|
||||
class DeletePaymentRequest implements StartSaving {
|
||||
DeletePaymentRequest(this.completer, this.paymentId);
|
||||
DeletePaymentRequest(this.completer, this.paymentIds);
|
||||
|
||||
final Completer completer;
|
||||
final String paymentId;
|
||||
final List<String> paymentIds;
|
||||
}
|
||||
|
||||
class DeletePaymentSuccess implements StopSaving, PersistData {
|
||||
DeletePaymentSuccess(this.payment);
|
||||
DeletePaymentSuccess(this.payments);
|
||||
|
||||
final PaymentEntity payment;
|
||||
final List<PaymentEntity> payments;
|
||||
}
|
||||
|
||||
class DeletePaymentFailure implements StopSaving {
|
||||
DeletePaymentFailure(this.payment);
|
||||
DeletePaymentFailure(this.payments);
|
||||
|
||||
final PaymentEntity payment;
|
||||
final List<PaymentEntity> payments;
|
||||
}
|
||||
|
||||
class RestorePaymentRequest implements StartSaving {
|
||||
RestorePaymentRequest(this.completer, this.paymentId);
|
||||
RestorePaymentRequest(this.completer, this.paymentIds);
|
||||
|
||||
final Completer completer;
|
||||
final String paymentId;
|
||||
final List<String> paymentIds;
|
||||
}
|
||||
|
||||
class RestorePaymentSuccess implements StopSaving, PersistData {
|
||||
RestorePaymentSuccess(this.payment);
|
||||
RestorePaymentSuccess(this.payments);
|
||||
|
||||
final PaymentEntity payment;
|
||||
final List<PaymentEntity> payments;
|
||||
}
|
||||
|
||||
class RestorePaymentFailure implements StopSaving {
|
||||
RestorePaymentFailure(this.payment);
|
||||
RestorePaymentFailure(this.payments);
|
||||
|
||||
final PaymentEntity payment;
|
||||
final List<PaymentEntity> payments;
|
||||
}
|
||||
|
||||
class EmailPaymentRequest implements StartSaving {
|
||||
|
|
@ -265,6 +265,7 @@ void handlePaymentAction(
|
|||
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final localization = AppLocalization.of(context);
|
||||
final paymentIds = payments.map((payment) => payment.id).toList();
|
||||
final payment = payments.first;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -278,16 +279,16 @@ void handlePaymentAction(
|
|||
case EntityAction.restore:
|
||||
store.dispatch(RestorePaymentRequest(
|
||||
snackBarCompleter(context, localization.restoredPayment),
|
||||
payment.id));
|
||||
paymentIds));
|
||||
break;
|
||||
case EntityAction.archive:
|
||||
store.dispatch(ArchivePaymentRequest(
|
||||
snackBarCompleter(context, localization.archivedPayment),
|
||||
payment.id));
|
||||
paymentIds));
|
||||
break;
|
||||
case EntityAction.delete:
|
||||
store.dispatch(DeletePaymentRequest(
|
||||
snackBarCompleter(context, localization.deletedPayment), payment.id));
|
||||
snackBarCompleter(context, localization.deletedPayment), paymentIds));
|
||||
break;
|
||||
case EntityAction.toggleMultiselect:
|
||||
if (!store.state.paymentListState.isInMultiselect()) {
|
||||
|
|
|
|||
|
|
@ -111,18 +111,20 @@ Middleware<AppState> _viewPaymentList() {
|
|||
Middleware<AppState> _archivePayment(PaymentRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as ArchivePaymentRequest;
|
||||
final origPayment = store.state.paymentState.map[action.paymentId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origPayment,
|
||||
action: EntityAction.archive)
|
||||
.then((PaymentEntity payment) {
|
||||
store.dispatch(ArchivePaymentSuccess(payment));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.paymentIds, EntityAction.archive)
|
||||
.then((List<PaymentEntity> payments) {
|
||||
store.dispatch(ArchivePaymentSuccess(payments));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(ArchivePaymentFailure(origPayment));
|
||||
final payments = action.paymentIds
|
||||
.map((id) => store.state.paymentState.map[id])
|
||||
.toList();
|
||||
store.dispatch(ArchivePaymentFailure(payments));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
@ -135,19 +137,21 @@ Middleware<AppState> _archivePayment(PaymentRepository repository) {
|
|||
Middleware<AppState> _deletePayment(PaymentRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as DeletePaymentRequest;
|
||||
final origPayment = store.state.paymentState.map[action.paymentId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origPayment,
|
||||
action: EntityAction.delete)
|
||||
.then((PaymentEntity payment) {
|
||||
store.dispatch(DeletePaymentSuccess(payment));
|
||||
store.dispatch(LoadInvoice(invoiceId: payment.invoiceId));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.paymentIds, EntityAction.delete)
|
||||
.then((List<PaymentEntity> payments) {
|
||||
store.dispatch(DeletePaymentSuccess(payments));
|
||||
store.dispatch(LoadInvoice(invoiceId: payments.first.invoiceId));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(DeletePaymentFailure(origPayment));
|
||||
final payments = action.paymentIds
|
||||
.map((id) => store.state.paymentState.map[id])
|
||||
.toList();
|
||||
store.dispatch(DeletePaymentFailure(payments));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
@ -160,19 +164,21 @@ Middleware<AppState> _deletePayment(PaymentRepository repository) {
|
|||
Middleware<AppState> _restorePayment(PaymentRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as RestorePaymentRequest;
|
||||
final origPayment = store.state.paymentState.map[action.paymentId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origPayment,
|
||||
action: EntityAction.restore)
|
||||
.then((PaymentEntity payment) {
|
||||
store.dispatch(RestorePaymentSuccess(payment));
|
||||
store.dispatch(LoadInvoice(invoiceId: payment.invoiceId));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.paymentIds, EntityAction.restore)
|
||||
.then((List<PaymentEntity> payments) {
|
||||
store.dispatch(RestorePaymentSuccess(payments));
|
||||
store.dispatch(LoadInvoice(invoiceId: payments.first.invoiceId));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(RestorePaymentFailure(origPayment));
|
||||
final payments = action.paymentIds
|
||||
.map((id) => store.state.paymentState.map[id])
|
||||
.toList();
|
||||
store.dispatch(RestorePaymentFailure(payments));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,63 +150,103 @@ final paymentsReducer = combineReducers<PaymentState>([
|
|||
|
||||
PaymentState _archivePaymentRequest(
|
||||
PaymentState paymentState, ArchivePaymentRequest action) {
|
||||
final payment = paymentState.map[action.paymentId]
|
||||
.rebuild((b) => b..archivedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
final payments = action.paymentIds.map((id) => paymentState.map[id]).toList();
|
||||
|
||||
return paymentState.rebuild((b) => b..map[action.paymentId] = payment);
|
||||
for (int i = 0; i < payments.length; i++) {
|
||||
payments[i] = payments[i]
|
||||
.rebuild((b) => b..archivedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
}
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _archivePaymentSuccess(
|
||||
PaymentState paymentState, ArchivePaymentSuccess action) {
|
||||
return paymentState
|
||||
.rebuild((b) => b..map[action.payment.id] = action.payment);
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in action.payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _archivePaymentFailure(
|
||||
PaymentState paymentState, ArchivePaymentFailure action) {
|
||||
return paymentState
|
||||
.rebuild((b) => b..map[action.payment.id] = action.payment);
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in action.payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _deletePaymentRequest(
|
||||
PaymentState paymentState, DeletePaymentRequest action) {
|
||||
final payment = paymentState.map[action.paymentId].rebuild((b) => b
|
||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isDeleted = true);
|
||||
final payments = action.paymentIds.map((id) => paymentState.map[id]).toList();
|
||||
|
||||
return paymentState.rebuild((b) => b..map[action.paymentId] = payment);
|
||||
for (int i = 0; i < payments.length; i++) {
|
||||
payments[i] = payments[i].rebuild((b) => b
|
||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isDeleted = true);
|
||||
}
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _deletePaymentSuccess(
|
||||
PaymentState paymentState, DeletePaymentSuccess action) {
|
||||
return paymentState
|
||||
.rebuild((b) => b..map[action.payment.id] = action.payment);
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in action.payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _deletePaymentFailure(
|
||||
PaymentState paymentState, DeletePaymentFailure action) {
|
||||
return paymentState
|
||||
.rebuild((b) => b..map[action.payment.id] = action.payment);
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in action.payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _restorePaymentRequest(
|
||||
PaymentState paymentState, RestorePaymentRequest action) {
|
||||
final payment = paymentState.map[action.paymentId].rebuild((b) => b
|
||||
..archivedAt = null
|
||||
..isDeleted = false);
|
||||
return paymentState.rebuild((b) => b..map[action.paymentId] = payment);
|
||||
final payments = action.paymentIds.map((id) => paymentState.map[id]).toList();
|
||||
|
||||
for (int i = 0; i < payments.length; i++) {
|
||||
payments[i] = payments[i].rebuild((b) => b
|
||||
..archivedAt = null
|
||||
..isDeleted = false);
|
||||
}
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _restorePaymentSuccess(
|
||||
PaymentState paymentState, RestorePaymentSuccess action) {
|
||||
return paymentState
|
||||
.rebuild((b) => b..map[action.payment.id] = action.payment);
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in action.payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _restorePaymentFailure(
|
||||
PaymentState paymentState, RestorePaymentFailure action) {
|
||||
return paymentState
|
||||
.rebuild((b) => b..map[action.payment.id] = action.payment);
|
||||
return paymentState.rebuild((b) {
|
||||
for (final payment in action.payments) {
|
||||
b.map[payment.id] = payment;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
PaymentState _addPayment(PaymentState paymentState, AddPaymentSuccess action) {
|
||||
|
|
|
|||
|
|
@ -103,60 +103,60 @@ class SaveProductFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class ArchiveProductRequest implements StartSaving {
|
||||
ArchiveProductRequest(this.completer, this.productId);
|
||||
ArchiveProductRequest(this.completer, this.productIds);
|
||||
|
||||
final Completer completer;
|
||||
final String productId;
|
||||
final List<String> productIds;
|
||||
}
|
||||
|
||||
class ArchiveProductSuccess implements StopSaving, PersistData {
|
||||
ArchiveProductSuccess(this.product);
|
||||
ArchiveProductSuccess(this.products);
|
||||
|
||||
final ProductEntity product;
|
||||
final List<ProductEntity> products;
|
||||
}
|
||||
|
||||
class ArchiveProductFailure implements StopSaving {
|
||||
ArchiveProductFailure(this.product);
|
||||
ArchiveProductFailure(this.products);
|
||||
|
||||
final ProductEntity product;
|
||||
final List<ProductEntity> products;
|
||||
}
|
||||
|
||||
class DeleteProductRequest implements StartSaving {
|
||||
DeleteProductRequest(this.completer, this.productId);
|
||||
DeleteProductRequest(this.completer, this.productIds);
|
||||
|
||||
final Completer completer;
|
||||
final String productId;
|
||||
final List<String> productIds;
|
||||
}
|
||||
|
||||
class DeleteProductSuccess implements StopSaving, PersistData {
|
||||
DeleteProductSuccess(this.product);
|
||||
DeleteProductSuccess(this.products);
|
||||
|
||||
final ProductEntity product;
|
||||
final List<ProductEntity> products;
|
||||
}
|
||||
|
||||
class DeleteProductFailure implements StopSaving {
|
||||
DeleteProductFailure(this.product);
|
||||
DeleteProductFailure(this.products);
|
||||
|
||||
final ProductEntity product;
|
||||
final List<ProductEntity> products;
|
||||
}
|
||||
|
||||
class RestoreProductRequest implements StartSaving {
|
||||
RestoreProductRequest(this.completer, this.productId);
|
||||
RestoreProductRequest(this.completer, this.productIds);
|
||||
|
||||
final Completer completer;
|
||||
final String productId;
|
||||
final List<String> productIds;
|
||||
}
|
||||
|
||||
class RestoreProductSuccess implements StopSaving, PersistData {
|
||||
RestoreProductSuccess(this.product);
|
||||
RestoreProductSuccess(this.products);
|
||||
|
||||
final ProductEntity product;
|
||||
final List<ProductEntity> products;
|
||||
}
|
||||
|
||||
class RestoreProductFailure implements StopSaving {
|
||||
RestoreProductFailure(this.product);
|
||||
RestoreProductFailure(this.products);
|
||||
|
||||
final ProductEntity product;
|
||||
final List<ProductEntity> products;
|
||||
}
|
||||
|
||||
class FilterProducts {
|
||||
|
|
@ -209,6 +209,7 @@ void handleProductAction(
|
|||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final localization = AppLocalization.of(context);
|
||||
final productIds = products.map((product) => product.id).toList();
|
||||
final product = products.first;
|
||||
|
||||
switch (action) {
|
||||
|
|
@ -230,16 +231,16 @@ void handleProductAction(
|
|||
case EntityAction.restore:
|
||||
store.dispatch(RestoreProductRequest(
|
||||
snackBarCompleter(context, localization.restoredProduct),
|
||||
product.id));
|
||||
productIds));
|
||||
break;
|
||||
case EntityAction.archive:
|
||||
store.dispatch(ArchiveProductRequest(
|
||||
snackBarCompleter(context, localization.archivedProduct),
|
||||
product.id));
|
||||
productIds));
|
||||
break;
|
||||
case EntityAction.delete:
|
||||
store.dispatch(DeleteProductRequest(
|
||||
snackBarCompleter(context, localization.deletedProduct), product.id));
|
||||
snackBarCompleter(context, localization.deletedProduct), productIds));
|
||||
break;
|
||||
case EntityAction.toggleMultiselect:
|
||||
if (!store.state.productListState.isInMultiselect()) {
|
||||
|
|
|
|||
|
|
@ -103,17 +103,20 @@ Middleware<AppState> _viewProductList() {
|
|||
Middleware<AppState> _archiveProduct(ProductRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as ArchiveProductRequest;
|
||||
final origProduct = store.state.productState.map[action.productId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origProduct, EntityAction.archive)
|
||||
.then((ProductEntity product) {
|
||||
store.dispatch(ArchiveProductSuccess(product));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.productIds, EntityAction.archive)
|
||||
.then((List<ProductEntity> products) {
|
||||
store.dispatch(ArchiveProductSuccess(products));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((dynamic error) {
|
||||
print(error);
|
||||
store.dispatch(ArchiveProductFailure(origProduct));
|
||||
final products = action.productIds
|
||||
.map((id) => store.state.productState.map[id])
|
||||
.toList();
|
||||
store.dispatch(ArchiveProductFailure(products));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
@ -126,17 +129,20 @@ Middleware<AppState> _archiveProduct(ProductRepository repository) {
|
|||
Middleware<AppState> _deleteProduct(ProductRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as DeleteProductRequest;
|
||||
final origProduct = store.state.productState.map[action.productId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origProduct, EntityAction.delete)
|
||||
.then((ProductEntity product) {
|
||||
store.dispatch(DeleteProductSuccess(product));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.productIds, EntityAction.delete)
|
||||
.then((List<ProductEntity> products) {
|
||||
store.dispatch(DeleteProductSuccess(products));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(DeleteProductFailure(origProduct));
|
||||
final products = action.productIds
|
||||
.map((id) => store.state.productState.map[id])
|
||||
.toList();
|
||||
store.dispatch(DeleteProductFailure(products));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
@ -149,17 +155,20 @@ Middleware<AppState> _deleteProduct(ProductRepository repository) {
|
|||
Middleware<AppState> _restoreProduct(ProductRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as RestoreProductRequest;
|
||||
final origProduct = store.state.productState.map[action.productId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origProduct, EntityAction.restore)
|
||||
.then((ProductEntity product) {
|
||||
store.dispatch(RestoreProductSuccess(product));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.productIds, EntityAction.restore)
|
||||
.then((List<ProductEntity> products) {
|
||||
store.dispatch(RestoreProductSuccess(products));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(RestoreProductFailure(origProduct));
|
||||
final products = action.productIds
|
||||
.map((id) => store.state.productState.map[id])
|
||||
.toList();
|
||||
store.dispatch(RestoreProductFailure(products));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ EntityUIState productUIReducer(ProductUIState state, dynamic action) {
|
|||
}
|
||||
|
||||
Reducer<String> dropdownFilterReducer = combineReducers([
|
||||
TypedReducer<String, FilterProductDropdown>(filterClientDropdownReducer),
|
||||
TypedReducer<String, FilterProductDropdown>(filterProductDropdownReducer),
|
||||
]);
|
||||
|
||||
String filterClientDropdownReducer(
|
||||
String filterProductDropdownReducer(
|
||||
String dropdownFilter, FilterProductDropdown action) {
|
||||
return action.filter;
|
||||
}
|
||||
|
|
@ -38,11 +38,11 @@ final editingReducer = combineReducers<ProductEntity>([
|
|||
TypedReducer<ProductEntity, DiscardChanges>(_clearEditing),
|
||||
]);
|
||||
|
||||
ProductEntity _clearEditing(ProductEntity client, dynamic action) {
|
||||
ProductEntity _clearEditing(ProductEntity product, dynamic action) {
|
||||
return ProductEntity();
|
||||
}
|
||||
|
||||
ProductEntity _updateEditing(ProductEntity client, dynamic action) {
|
||||
ProductEntity _updateEditing(ProductEntity product, dynamic action) {
|
||||
return action.product;
|
||||
}
|
||||
|
||||
|
|
@ -148,63 +148,103 @@ final productsReducer = combineReducers<ProductState>([
|
|||
|
||||
ProductState _archiveProductRequest(
|
||||
ProductState productState, ArchiveProductRequest action) {
|
||||
final product = productState.map[action.productId]
|
||||
.rebuild((b) => b..archivedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
final products = action.productIds.map((id) => productState.map[id]).toList();
|
||||
|
||||
return productState.rebuild((b) => b..map[action.productId] = product);
|
||||
for (int i = 0; i < products.length; i++) {
|
||||
products[i] = products[i]
|
||||
.rebuild((b) => b..archivedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
}
|
||||
return productState.rebuild((b) {
|
||||
for (final product in products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _archiveProductSuccess(
|
||||
ProductState productState, ArchiveProductSuccess action) {
|
||||
return productState
|
||||
.rebuild((b) => b..map[action.product.id] = action.product);
|
||||
return productState.rebuild((b) {
|
||||
for (final product in action.products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _archiveProductFailure(
|
||||
ProductState productState, ArchiveProductFailure action) {
|
||||
return productState
|
||||
.rebuild((b) => b..map[action.product.id] = action.product);
|
||||
return productState.rebuild((b) {
|
||||
for (final product in action.products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _deleteProductRequest(
|
||||
ProductState productState, DeleteProductRequest action) {
|
||||
final product = productState.map[action.productId].rebuild((b) => b
|
||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isDeleted = true);
|
||||
final products = action.productIds.map((id) => productState.map[id]).toList();
|
||||
|
||||
return productState.rebuild((b) => b..map[action.productId] = product);
|
||||
for (int i = 0; i < products.length; i++) {
|
||||
products[i] = products[i].rebuild((b) => b
|
||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isDeleted = true);
|
||||
}
|
||||
return productState.rebuild((b) {
|
||||
for (final product in products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _deleteProductSuccess(
|
||||
ProductState productState, DeleteProductSuccess action) {
|
||||
return productState
|
||||
.rebuild((b) => b..map[action.product.id] = action.product);
|
||||
return productState.rebuild((b) {
|
||||
for (final product in action.products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _deleteProductFailure(
|
||||
ProductState productState, DeleteProductFailure action) {
|
||||
return productState
|
||||
.rebuild((b) => b..map[action.product.id] = action.product);
|
||||
return productState.rebuild((b) {
|
||||
for (final product in action.products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _restoreProductRequest(
|
||||
ProductState productState, RestoreProductRequest action) {
|
||||
final product = productState.map[action.productId].rebuild((b) => b
|
||||
..archivedAt = null
|
||||
..isDeleted = false);
|
||||
return productState.rebuild((b) => b..map[action.productId] = product);
|
||||
final products = action.productIds.map((id) => productState.map[id]).toList();
|
||||
|
||||
for (int i = 0; i < products.length; i++) {
|
||||
products[i] = products[i].rebuild((b) => b
|
||||
..archivedAt = null
|
||||
..isDeleted = false);
|
||||
}
|
||||
return productState.rebuild((b) {
|
||||
for (final product in products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _restoreProductSuccess(
|
||||
ProductState productState, RestoreProductSuccess action) {
|
||||
return productState
|
||||
.rebuild((b) => b..map[action.product.id] = action.product);
|
||||
return productState.rebuild((b) {
|
||||
for (final product in action.products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _restoreProductFailure(
|
||||
ProductState productState, RestoreProductFailure action) {
|
||||
return productState
|
||||
.rebuild((b) => b..map[action.product.id] = action.product);
|
||||
return productState.rebuild((b) {
|
||||
for (final product in action.products) {
|
||||
b.map[product.id] = product;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ProductState _addProduct(ProductState productState, AddProductSuccess action) {
|
||||
|
|
|
|||
|
|
@ -214,60 +214,63 @@ class MarkSentQuoteFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class ArchiveQuoteRequest implements StartSaving {
|
||||
ArchiveQuoteRequest(this.completer, this.quoteId);
|
||||
ArchiveQuoteRequest(this.completer, this.quoteIds);
|
||||
|
||||
final Completer completer;
|
||||
final String quoteId;
|
||||
|
||||
final List<String> quoteIds;
|
||||
}
|
||||
|
||||
class ArchiveQuoteSuccess implements StopSaving, PersistData {
|
||||
ArchiveQuoteSuccess(this.quote);
|
||||
ArchiveQuoteSuccess(this.quotes);
|
||||
|
||||
final InvoiceEntity quote;
|
||||
final List<InvoiceEntity> quotes;
|
||||
}
|
||||
|
||||
class ArchiveQuoteFailure implements StopSaving {
|
||||
ArchiveQuoteFailure(this.quote);
|
||||
ArchiveQuoteFailure(this.quotes);
|
||||
|
||||
final InvoiceEntity quote;
|
||||
final List<InvoiceEntity> quotes;
|
||||
}
|
||||
|
||||
class DeleteQuoteRequest implements StartSaving {
|
||||
DeleteQuoteRequest(this.completer, this.quoteId);
|
||||
DeleteQuoteRequest(this.completer, this.quoteIds);
|
||||
|
||||
final Completer completer;
|
||||
final String quoteId;
|
||||
|
||||
final List<String> quoteIds;
|
||||
}
|
||||
|
||||
class DeleteQuoteSuccess implements StopSaving, PersistData {
|
||||
DeleteQuoteSuccess(this.quote);
|
||||
DeleteQuoteSuccess(this.quotes);
|
||||
|
||||
final InvoiceEntity quote;
|
||||
final List<InvoiceEntity> quotes;
|
||||
}
|
||||
|
||||
class DeleteQuoteFailure implements StopSaving {
|
||||
DeleteQuoteFailure(this.quote);
|
||||
DeleteQuoteFailure(this.quotes);
|
||||
|
||||
final InvoiceEntity quote;
|
||||
final List<InvoiceEntity> quotes;
|
||||
}
|
||||
|
||||
class RestoreQuoteRequest implements StartSaving {
|
||||
RestoreQuoteRequest(this.completer, this.quoteId);
|
||||
RestoreQuoteRequest(this.completer, this.quoteIds);
|
||||
|
||||
final Completer completer;
|
||||
final String quoteId;
|
||||
|
||||
final List<String> quoteIds;
|
||||
}
|
||||
|
||||
class RestoreQuoteSuccess implements StopSaving, PersistData {
|
||||
RestoreQuoteSuccess(this.quote);
|
||||
RestoreQuoteSuccess(this.quotes);
|
||||
|
||||
final InvoiceEntity quote;
|
||||
final List<InvoiceEntity> quotes;
|
||||
}
|
||||
|
||||
class RestoreQuoteFailure implements StopSaving {
|
||||
RestoreQuoteFailure(this.quote);
|
||||
RestoreQuoteFailure(this.quotes);
|
||||
|
||||
final InvoiceEntity quote;
|
||||
final List<InvoiceEntity> quotes;
|
||||
}
|
||||
|
||||
class FilterQuotes {
|
||||
|
|
@ -354,6 +357,7 @@ Future handleQuoteAction(
|
|||
final store = StoreProvider.of<AppState>(context);
|
||||
final localization = AppLocalization.of(context);
|
||||
final quote = quotes.first as InvoiceEntity;
|
||||
final quoteIds = quotes.map((quote) => quote.id).toList();
|
||||
|
||||
switch (action) {
|
||||
case EntityAction.edit:
|
||||
|
|
@ -399,15 +403,15 @@ Future handleQuoteAction(
|
|||
break;
|
||||
case EntityAction.restore:
|
||||
store.dispatch(RestoreQuoteRequest(
|
||||
snackBarCompleter(context, localization.restoredQuote), quote.id));
|
||||
snackBarCompleter(context, localization.restoredQuote), quoteIds));
|
||||
break;
|
||||
case EntityAction.archive:
|
||||
store.dispatch(ArchiveQuoteRequest(
|
||||
snackBarCompleter(context, localization.archivedQuote), quote.id));
|
||||
snackBarCompleter(context, localization.archivedQuote), quoteIds));
|
||||
break;
|
||||
case EntityAction.delete:
|
||||
store.dispatch(DeleteQuoteRequest(
|
||||
snackBarCompleter(context, localization.deletedQuote), quote.id));
|
||||
snackBarCompleter(context, localization.deletedQuote), quoteIds));
|
||||
break;
|
||||
case EntityAction.toggleMultiselect:
|
||||
if (!store.state.quoteListState.isInMultiselect()) {
|
||||
|
|
|
|||
|
|
@ -136,17 +136,19 @@ Middleware<AppState> _showEmailQuote() {
|
|||
Middleware<AppState> _archiveQuote(QuoteRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as ArchiveQuoteRequest;
|
||||
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||
repository
|
||||
.saveData(store.state.credentials, origQuote, EntityAction.archive)
|
||||
.then((InvoiceEntity quote) {
|
||||
store.dispatch(ArchiveQuoteSuccess(quote));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.quoteIds, EntityAction.archive)
|
||||
.then((List<InvoiceEntity> quotes) {
|
||||
store.dispatch(ArchiveQuoteSuccess(quotes));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(ArchiveQuoteFailure(origQuote));
|
||||
final quotes =
|
||||
action.quoteIds.map((id) => store.state.quoteState.map[id]).toList();
|
||||
store.dispatch(ArchiveQuoteFailure(quotes));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
@ -159,17 +161,20 @@ Middleware<AppState> _archiveQuote(QuoteRepository repository) {
|
|||
Middleware<AppState> _deleteQuote(QuoteRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as DeleteQuoteRequest;
|
||||
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||
|
||||
repository
|
||||
.saveData(store.state.credentials, origQuote, EntityAction.delete)
|
||||
.then((InvoiceEntity quote) {
|
||||
store.dispatch(DeleteQuoteSuccess(quote));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.quoteIds, EntityAction.delete)
|
||||
.then((List<InvoiceEntity> quotes) {
|
||||
store.dispatch(DeleteQuoteSuccess(quotes));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(DeleteQuoteFailure(origQuote));
|
||||
final quotes =
|
||||
action.quoteIds.map((id) => store.state.quoteState.map[id]).toList();
|
||||
store.dispatch(DeleteQuoteFailure(quotes));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
@ -182,17 +187,20 @@ Middleware<AppState> _deleteQuote(QuoteRepository repository) {
|
|||
Middleware<AppState> _restoreQuote(QuoteRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as RestoreQuoteRequest;
|
||||
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||
|
||||
repository
|
||||
.saveData(store.state.credentials, origQuote, EntityAction.restore)
|
||||
.then((InvoiceEntity quote) {
|
||||
store.dispatch(RestoreQuoteSuccess(quote));
|
||||
.bulkAction(
|
||||
store.state.credentials, action.quoteIds, EntityAction.restore)
|
||||
.then((List<InvoiceEntity> quotes) {
|
||||
store.dispatch(RestoreQuoteSuccess(quotes));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(RestoreQuoteFailure(origQuote));
|
||||
final quotes =
|
||||
action.quoteIds.map((id) => store.state.quoteState.map[id]).toList();
|
||||
store.dispatch(RestoreQuoteFailure(quotes));
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ InvoiceItemEntity editQuoteItem(InvoiceItemEntity quoteItem, dynamic action) {
|
|||
}
|
||||
|
||||
Reducer<String> dropdownFilterReducer = combineReducers([
|
||||
TypedReducer<String, FilterQuoteDropdown>(filterClientDropdownReducer),
|
||||
TypedReducer<String, FilterQuoteDropdown>(filterquoteDropdownReducer),
|
||||
]);
|
||||
|
||||
String filterClientDropdownReducer(
|
||||
String filterquoteDropdownReducer(
|
||||
String dropdownFilter, FilterQuoteDropdown action) {
|
||||
return action.filter;
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ final editingReducer = combineReducers<InvoiceEntity>([
|
|||
TypedReducer<InvoiceEntity, DiscardChanges>(_clearEditing),
|
||||
]);
|
||||
|
||||
InvoiceEntity _clearEditing(InvoiceEntity client, dynamic action) {
|
||||
InvoiceEntity _clearEditing(InvoiceEntity quote, dynamic action) {
|
||||
return InvoiceEntity();
|
||||
}
|
||||
|
||||
|
|
@ -213,65 +213,103 @@ QuoteState _markSentQuoteSuccess(
|
|||
|
||||
QuoteState _archiveQuoteRequest(
|
||||
QuoteState quoteState, ArchiveQuoteRequest action) {
|
||||
final quote = quoteState.map[action.quoteId]
|
||||
.rebuild((b) => b..archivedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList();
|
||||
|
||||
return quoteState.rebuild((b) => b..map[action.quoteId] = quote);
|
||||
for (int i = 0; i < quotes.length; i++) {
|
||||
quotes[i] = quotes[i]
|
||||
.rebuild((b) => b..archivedAt = DateTime.now().millisecondsSinceEpoch);
|
||||
}
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _archiveQuoteSuccess(
|
||||
QuoteState quoteState, ArchiveQuoteSuccess action) {
|
||||
return quoteState.rebuild((b) => b..map[action.quote.id] = action.quote);
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in action.quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _archiveQuoteFailure(
|
||||
QuoteState quoteState, ArchiveQuoteFailure action) {
|
||||
return quoteState.rebuild((b) => b..map[action.quote.id] = action.quote);
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in action.quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _deleteQuoteRequest(
|
||||
QuoteState quoteState, DeleteQuoteRequest action) {
|
||||
if (!quoteState.map.containsKey(action.quoteId)) {
|
||||
return quoteState;
|
||||
final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList();
|
||||
|
||||
for (int i = 0; i < quotes.length; i++) {
|
||||
quotes[i] = quotes[i].rebuild((b) => b
|
||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isDeleted = true);
|
||||
}
|
||||
|
||||
final quote = quoteState.map[action.quoteId].rebuild((b) => b
|
||||
..archivedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isDeleted = true);
|
||||
|
||||
return quoteState.rebuild((b) => b..map[action.quoteId] = quote);
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _deleteQuoteSuccess(
|
||||
QuoteState quoteState, DeleteQuoteSuccess action) {
|
||||
if (!quoteState.map.containsKey(action.quote.id)) {
|
||||
return quoteState;
|
||||
}
|
||||
|
||||
return quoteState.rebuild((b) => b..map[action.quote.id] = action.quote);
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in action.quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _deleteQuoteFailure(
|
||||
QuoteState quoteState, DeleteQuoteFailure action) {
|
||||
return quoteState.rebuild((b) => b..map[action.quote.id] = action.quote);
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in action.quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _restoreQuoteRequest(
|
||||
QuoteState quoteState, RestoreQuoteRequest action) {
|
||||
final quote = quoteState.map[action.quoteId].rebuild((b) => b
|
||||
..archivedAt = null
|
||||
..isDeleted = false);
|
||||
return quoteState.rebuild((b) => b..map[action.quoteId] = quote);
|
||||
final quotes = action.quoteIds.map((id) => quoteState.map[id]).toList();
|
||||
|
||||
for (int i = 0; i < quotes.length; i++) {
|
||||
quotes[i] = quotes[i].rebuild((b) => b
|
||||
..archivedAt = null
|
||||
..isDeleted = false);
|
||||
}
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _restoreQuoteSuccess(
|
||||
QuoteState quoteState, RestoreQuoteSuccess action) {
|
||||
return quoteState.rebuild((b) => b..map[action.quote.id] = action.quote);
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in action.quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _restoreQuoteFailure(
|
||||
QuoteState quoteState, RestoreQuoteFailure action) {
|
||||
return quoteState.rebuild((b) => b..map[action.quote.id] = action.quote);
|
||||
return quoteState.rebuild((b) {
|
||||
for (final quote in action.quotes) {
|
||||
b.map[quote.id] = quote;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
QuoteState _convertQuoteSuccess(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import 'package:invoiceninja_flutter/redux/document/document_selectors.dart';
|
|||
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/help_text.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/list_divider.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||
import 'package:invoiceninja_flutter/ui/invoice/invoice_list_item.dart';
|
||||
import 'package:invoiceninja_flutter/ui/invoice/invoice_list_vm.dart';
|
||||
|
|
@ -33,36 +34,13 @@ class InvoiceList extends StatelessWidget {
|
|||
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
filteredClient != null
|
||||
? Material(
|
||||
color: Colors.orangeAccent,
|
||||
elevation: 6.0,
|
||||
child: InkWell(
|
||||
onTap: () => viewModel.onViewEntityFilterPressed(context),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
SizedBox(width: 18.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${localization.filteredByClient}: ${filteredClient.listDisplayName}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () => viewModel.onClearEntityFilterPressed(),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
if (filteredClient != null)
|
||||
ListFilterMessage(
|
||||
title:
|
||||
'${localization.filteredByGroup}: ${filteredClient.listDisplayName}',
|
||||
onPressed: viewModel.onViewEntityFilterPressed,
|
||||
onClearPressed: viewModel.onClearEntityFilterPressed,
|
||||
),
|
||||
Expanded(
|
||||
child: !viewModel.isLoaded
|
||||
? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:invoiceninja_flutter/redux/payment/payment_selectors.dart';
|
|||
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/help_text.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/list_divider.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||
import 'package:invoiceninja_flutter/ui/payment/payment_list_item.dart';
|
||||
import 'package:invoiceninja_flutter/ui/payment/payment_list_vm.dart';
|
||||
|
|
@ -49,36 +50,13 @@ class PaymentList extends StatelessWidget {
|
|||
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
filteredEntity != null
|
||||
? Material(
|
||||
color: Colors.orangeAccent,
|
||||
elevation: 6.0,
|
||||
child: InkWell(
|
||||
onTap: () => viewModel.onViewClientFilterPressed(context),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
SizedBox(width: 18.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'$label: ${filteredEntity.listDisplayName}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () => viewModel.onClearEntityFilterPressed(),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
if (filteredEntity != null)
|
||||
ListFilterMessage(
|
||||
title:
|
||||
'${localization.filteredByGroup}: ${filteredEntity.listDisplayName}',
|
||||
onPressed: viewModel.onViewEntityFilterPressed,
|
||||
onClearPressed: viewModel.onClearEntityFilterPressed,
|
||||
),
|
||||
Expanded(
|
||||
child: !viewModel.isLoaded
|
||||
? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class PaymentListVM {
|
|||
@required this.onRefreshed,
|
||||
@required this.onEntityAction,
|
||||
@required this.onClearEntityFilterPressed,
|
||||
@required this.onViewClientFilterPressed,
|
||||
@required this.onViewEntityFilterPressed,
|
||||
@required this.listState,
|
||||
});
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class PaymentListVM {
|
|||
handlePaymentAction(context, payments, action),
|
||||
onClearEntityFilterPressed: () =>
|
||||
store.dispatch(FilterPaymentsByEntity()),
|
||||
onViewClientFilterPressed: (BuildContext context) {
|
||||
onViewEntityFilterPressed: (BuildContext context) {
|
||||
switch (state.paymentListState.filterEntityType) {
|
||||
case EntityType.client:
|
||||
store.dispatch(ViewClient(
|
||||
|
|
@ -114,7 +114,7 @@ class PaymentListVM {
|
|||
final Function(BuildContext, PaymentEntity) onPaymentTap;
|
||||
final Function(BuildContext) onRefreshed;
|
||||
final Function onClearEntityFilterPressed;
|
||||
final Function(BuildContext) onViewClientFilterPressed;
|
||||
final Function(BuildContext) onViewEntityFilterPressed;
|
||||
final Function(BuildContext, List<PaymentEntity>, EntityAction)
|
||||
onEntityAction;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
|||
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/help_text.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/list_divider.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||
import 'package:invoiceninja_flutter/ui/project/project_list_item.dart';
|
||||
import 'package:invoiceninja_flutter/ui/project/project_list_vm.dart';
|
||||
|
|
@ -31,36 +32,13 @@ class ProjectList extends StatelessWidget {
|
|||
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
filteredClient != null
|
||||
? Material(
|
||||
color: Colors.orangeAccent,
|
||||
elevation: 6.0,
|
||||
child: InkWell(
|
||||
onTap: () => viewModel.onViewEntityFilterPressed(context),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
SizedBox(width: 18.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'${localization.filteredByClient}: ${filteredClient.listDisplayName}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () => viewModel.onClearEntityFilterPressed(),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
if (filteredClient != null)
|
||||
ListFilterMessage(
|
||||
title:
|
||||
'${localization.filteredByGroup}: ${filteredClient.listDisplayName}',
|
||||
onPressed: viewModel.onViewEntityFilterPressed,
|
||||
onClearPressed: viewModel.onClearEntityFilterPressed,
|
||||
),
|
||||
Expanded(
|
||||
child: !viewModel.isLoaded
|
||||
? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
|
|||
import 'package:invoiceninja_flutter/ui/app/entities/entity_actions_dialog.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/help_text.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/list_divider.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/list_filter.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||
import 'package:invoiceninja_flutter/ui/task/task_list_item.dart';
|
||||
import 'package:invoiceninja_flutter/ui/task/task_list_vm.dart';
|
||||
|
|
@ -44,36 +45,13 @@ class TaskList extends StatelessWidget {
|
|||
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
filteredEntity != null
|
||||
? Material(
|
||||
color: Colors.orangeAccent,
|
||||
elevation: 6.0,
|
||||
child: InkWell(
|
||||
onTap: () => viewModel.onViewEntityFilterPressed(context),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
SizedBox(width: 18.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'$label: ${filteredEntity.listDisplayName}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () => viewModel.onClearEntityFilterPressed(),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
if (filteredEntity != null)
|
||||
ListFilterMessage(
|
||||
title:
|
||||
'${localization.filteredByGroup}: ${filteredEntity.listDisplayName}',
|
||||
onPressed: viewModel.onViewEntityFilterPressed,
|
||||
onClearPressed: viewModel.onClearEntityFilterPressed,
|
||||
),
|
||||
Expanded(
|
||||
child: !viewModel.isLoaded
|
||||
? (viewModel.isLoading ? LoadingIndicator() : SizedBox())
|
||||
|
|
|
|||
Loading…
Reference in New Issue