Refactor
This commit is contained in:
parent
e539f6e692
commit
efc3671970
|
|
@ -43,9 +43,9 @@ class EditPayment extends AbstractNavigatorAction
|
|||
final bool force;
|
||||
}
|
||||
|
||||
class RefundPayment extends AbstractNavigatorAction
|
||||
class ViewRefundPayment extends AbstractNavigatorAction
|
||||
implements PersistUI, PersistPrefs {
|
||||
RefundPayment(
|
||||
ViewRefundPayment(
|
||||
{@required this.payment,
|
||||
@required NavigatorState navigator,
|
||||
this.completer,
|
||||
|
|
@ -297,6 +297,22 @@ class FilterPaymentsByEntity implements PersistUI {
|
|||
final EntityType entityType;
|
||||
}
|
||||
|
||||
class StartPaymentMultiselect {}
|
||||
|
||||
class AddToPaymentMultiselect {
|
||||
AddToPaymentMultiselect({@required this.entity});
|
||||
|
||||
final BaseEntity entity;
|
||||
}
|
||||
|
||||
class RemoveFromPaymentMultiselect {
|
||||
RemoveFromPaymentMultiselect({@required this.entity});
|
||||
|
||||
final BaseEntity entity;
|
||||
}
|
||||
|
||||
class ClearPaymentMultiselect {}
|
||||
|
||||
void handlePaymentAction(
|
||||
BuildContext context, List<BaseEntity> payments, EntityAction action) {
|
||||
if (payments.isEmpty) {
|
||||
|
|
@ -313,7 +329,7 @@ void handlePaymentAction(
|
|||
editEntity(context: context, entity: payment);
|
||||
break;
|
||||
case EntityAction.refund:
|
||||
store.dispatch(RefundPayment(
|
||||
store.dispatch(ViewRefundPayment(
|
||||
navigator: Navigator.of(context),
|
||||
payment: payment,
|
||||
));
|
||||
|
|
@ -357,19 +373,3 @@ void handlePaymentAction(
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
class StartPaymentMultiselect {}
|
||||
|
||||
class AddToPaymentMultiselect {
|
||||
AddToPaymentMultiselect({@required this.entity});
|
||||
|
||||
final BaseEntity entity;
|
||||
}
|
||||
|
||||
class RemoveFromPaymentMultiselect {
|
||||
RemoveFromPaymentMultiselect({@required this.entity});
|
||||
|
||||
final BaseEntity entity;
|
||||
}
|
||||
|
||||
class ClearPaymentMultiselect {}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ List<Middleware<AppState>> createStorePaymentsMiddleware([
|
|||
final viewPaymentList = _viewPaymentList();
|
||||
final viewPayment = _viewPayment();
|
||||
final editPayment = _editPayment();
|
||||
final showRefundPayment = _showRefundPayment();
|
||||
final viewRefundPayment = _viewRefundPayment();
|
||||
final loadPayments = _loadPayments(repository);
|
||||
//final loadPayment = _loadPayment(repository);
|
||||
final savePayment = _savePayment(repository);
|
||||
|
|
@ -35,7 +35,7 @@ List<Middleware<AppState>> createStorePaymentsMiddleware([
|
|||
TypedMiddleware<AppState, ViewPaymentList>(viewPaymentList),
|
||||
TypedMiddleware<AppState, ViewPayment>(viewPayment),
|
||||
TypedMiddleware<AppState, EditPayment>(editPayment),
|
||||
TypedMiddleware<AppState, RefundPayment>(showRefundPayment),
|
||||
TypedMiddleware<AppState, ViewRefundPayment>(viewRefundPayment),
|
||||
TypedMiddleware<AppState, LoadPayments>(loadPayments),
|
||||
//TypedMiddleware<AppState, LoadPayment>(loadPayment),
|
||||
TypedMiddleware<AppState, SavePaymentRequest>(savePayment),
|
||||
|
|
@ -66,9 +66,9 @@ Middleware<AppState> _editPayment() {
|
|||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _showRefundPayment() {
|
||||
Middleware<AppState> _viewRefundPayment() {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as RefundPayment;
|
||||
final action = dynamicAction as ViewRefundPayment;
|
||||
|
||||
if (!action.force &&
|
||||
hasChanges(store: store, context: action.context, action: action)) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ final editingReducer = combineReducers<PaymentEntity>([
|
|||
return action.payments[0];
|
||||
}),
|
||||
TypedReducer<PaymentEntity, EditPayment>(_updateEditing),
|
||||
TypedReducer<PaymentEntity, RefundPayment>(_updateEditing),
|
||||
TypedReducer<PaymentEntity, ViewRefundPayment>(_updateEditing),
|
||||
TypedReducer<PaymentEntity, UpdatePayment>((payment, action) {
|
||||
return action.payment.rebuild((b) => b..isChanged = true);
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in New Issue