Feature Request: Filter Payments #542
This commit is contained in:
parent
45cc0a3ccd
commit
92bda9742e
|
|
@ -358,6 +358,21 @@ abstract class PaymentEntity extends Object
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool matchesStatuses(BuiltList<EntityStatus> statuses) {
|
||||||
|
if (statuses.isEmpty) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final status in statuses) {
|
||||||
|
if (status.id == statusId || status.id == calculatedStatusId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool matchesFilter(String filter) {
|
bool matchesFilter(String filter) {
|
||||||
return matchesStrings(
|
return matchesStrings(
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ Reducer<String> selectedIdReducer = combineReducers([
|
||||||
TypedReducer<String, SortPayments>((selectedId, action) => ''),
|
TypedReducer<String, SortPayments>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterPayments>((selectedId, action) => ''),
|
TypedReducer<String, FilterPayments>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterPaymentsByState>((selectedId, action) => ''),
|
TypedReducer<String, FilterPaymentsByState>((selectedId, action) => ''),
|
||||||
|
TypedReducer<String, FilterPaymentsByStatus>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterPaymentsByCustom1>((selectedId, action) => ''),
|
TypedReducer<String, FilterPaymentsByCustom1>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterPaymentsByCustom2>((selectedId, action) => ''),
|
TypedReducer<String, FilterPaymentsByCustom2>((selectedId, action) => ''),
|
||||||
TypedReducer<String, FilterPaymentsByCustom3>((selectedId, action) => ''),
|
TypedReducer<String, FilterPaymentsByCustom3>((selectedId, action) => ''),
|
||||||
|
|
@ -100,6 +101,7 @@ PaymentEntity _updateEditing(PaymentEntity payment, dynamic action) {
|
||||||
final paymentListReducer = combineReducers<ListUIState>([
|
final paymentListReducer = combineReducers<ListUIState>([
|
||||||
TypedReducer<ListUIState, SortPayments>(_sortPayments),
|
TypedReducer<ListUIState, SortPayments>(_sortPayments),
|
||||||
TypedReducer<ListUIState, FilterPaymentsByState>(_filterPaymentsByState),
|
TypedReducer<ListUIState, FilterPaymentsByState>(_filterPaymentsByState),
|
||||||
|
TypedReducer<ListUIState, FilterPaymentsByStatus>(_filterPaymentsByStatus),
|
||||||
TypedReducer<ListUIState, FilterPayments>(_filterPayments),
|
TypedReducer<ListUIState, FilterPayments>(_filterPayments),
|
||||||
TypedReducer<ListUIState, FilterPaymentsByCustom1>(_filterPaymentsByCustom1),
|
TypedReducer<ListUIState, FilterPaymentsByCustom1>(_filterPaymentsByCustom1),
|
||||||
TypedReducer<ListUIState, FilterPaymentsByCustom2>(_filterPaymentsByCustom2),
|
TypedReducer<ListUIState, FilterPaymentsByCustom2>(_filterPaymentsByCustom2),
|
||||||
|
|
@ -171,6 +173,16 @@ ListUIState _filterPaymentsByState(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ListUIState _filterPaymentsByStatus(
|
||||||
|
ListUIState paymentListState, FilterPaymentsByStatus action) {
|
||||||
|
if (paymentListState.statusFilters.contains(action.status)) {
|
||||||
|
return paymentListState
|
||||||
|
.rebuild((b) => b..statusFilters.remove(action.status));
|
||||||
|
} else {
|
||||||
|
return paymentListState.rebuild((b) => b..statusFilters.add(action.status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ListUIState _filterPayments(
|
ListUIState _filterPayments(
|
||||||
ListUIState paymentListState, FilterPayments action) {
|
ListUIState paymentListState, FilterPayments action) {
|
||||||
return paymentListState.rebuild((b) => b
|
return paymentListState.rebuild((b) => b
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,10 @@ List<String> filteredPaymentsSelector(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!payment.matchesStatuses(paymentListState.statusFilters)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final client =
|
final client =
|
||||||
clientMap[payment.clientId] ?? ClientEntity(id: payment.clientId);
|
clientMap[payment.clientId] ?? ClientEntity(id: payment.clientId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,8 @@ class PaymentScreen extends StatelessWidget {
|
||||||
final statuses = [
|
final statuses = [
|
||||||
PaymentStatusEntity().rebuild(
|
PaymentStatusEntity().rebuild(
|
||||||
(b) => b
|
(b) => b
|
||||||
..id = kPaymentStatusPartiallyUnapplied
|
..id = kPaymentStatusCompleted
|
||||||
..name = localization.partiallyUnapplied,
|
..name = localization.completed,
|
||||||
),
|
|
||||||
PaymentStatusEntity().rebuild(
|
|
||||||
(b) => b
|
|
||||||
..id = kPaymentStatusUnapplied
|
|
||||||
..name = localization.unapplied,
|
|
||||||
),
|
),
|
||||||
PaymentStatusEntity().rebuild(
|
PaymentStatusEntity().rebuild(
|
||||||
(b) => b
|
(b) => b
|
||||||
|
|
@ -61,11 +56,6 @@ class PaymentScreen extends StatelessWidget {
|
||||||
..id = kPaymentStatusFailed
|
..id = kPaymentStatusFailed
|
||||||
..name = localization.failed,
|
..name = localization.failed,
|
||||||
),
|
),
|
||||||
PaymentStatusEntity().rebuild(
|
|
||||||
(b) => b
|
|
||||||
..id = kPaymentStatusCompleted
|
|
||||||
..name = localization.completed,
|
|
||||||
),
|
|
||||||
PaymentStatusEntity().rebuild(
|
PaymentStatusEntity().rebuild(
|
||||||
(b) => b
|
(b) => b
|
||||||
..id = kPaymentStatusPartiallyRefunded
|
..id = kPaymentStatusPartiallyRefunded
|
||||||
|
|
@ -76,6 +66,16 @@ class PaymentScreen extends StatelessWidget {
|
||||||
..id = kPaymentStatusRefunded
|
..id = kPaymentStatusRefunded
|
||||||
..name = localization.refunded,
|
..name = localization.refunded,
|
||||||
),
|
),
|
||||||
|
PaymentStatusEntity().rebuild(
|
||||||
|
(b) => b
|
||||||
|
..id = kPaymentStatusUnapplied
|
||||||
|
..name = localization.unapplied,
|
||||||
|
),
|
||||||
|
PaymentStatusEntity().rebuild(
|
||||||
|
(b) => b
|
||||||
|
..id = kPaymentStatusPartiallyUnapplied
|
||||||
|
..name = localization.partiallyUnapplied,
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
return ListScaffold(
|
return ListScaffold(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue