Show archived/deleted records when filtered by client
This commit is contained in:
parent
e98405a1ad
commit
ca188d0753
|
|
@ -41,15 +41,42 @@ List<int> dropdownExpensesSelector(BuiltMap<int, ExpenseEntity> expenseMap,
|
|||
return list;
|
||||
}
|
||||
|
||||
var memoizedFilteredExpenseList = memo3(
|
||||
(BuiltMap<int, ExpenseEntity> expenseMap, BuiltList<int> expenseList,
|
||||
var memoizedFilteredExpenseList = memo5(
|
||||
(BuiltMap<int, ExpenseEntity> expenseMap,
|
||||
BuiltMap<int, ClientEntity> clientMap,
|
||||
BuiltMap<int, VendorEntity> vendorMap,
|
||||
BuiltList<int> expenseList,
|
||||
ListUIState expenseListState) =>
|
||||
filteredExpensesSelector(expenseMap, expenseList, expenseListState));
|
||||
filteredExpensesSelector(
|
||||
expenseMap, clientMap, vendorMap, expenseList, expenseListState));
|
||||
|
||||
List<int> filteredExpensesSelector(BuiltMap<int, ExpenseEntity> expenseMap,
|
||||
BuiltList<int> expenseList, ListUIState expenseListState) {
|
||||
List<int> filteredExpensesSelector(
|
||||
BuiltMap<int, ExpenseEntity> expenseMap,
|
||||
BuiltMap<int, ClientEntity> clientMap,
|
||||
BuiltMap<int, VendorEntity> vendorMap,
|
||||
BuiltList<int> expenseList,
|
||||
ListUIState expenseListState) {
|
||||
final list = expenseList.where((expenseId) {
|
||||
final expense = expenseMap[expenseId];
|
||||
final vendor =
|
||||
vendorMap[expense.vendorId] ?? VendorEntity(id: expense.vendorId);
|
||||
final client =
|
||||
clientMap[expense.clientId] ?? ClientEntity(id: expense.clientId);
|
||||
|
||||
if (expenseListState.filterEntityType != null) {
|
||||
if (expenseListState.filterEntityType == EntityType.client &&
|
||||
expense.clientId != expenseListState.filterEntityId) {
|
||||
return false;
|
||||
} else if (expenseListState.filterEntityType == EntityType.vendor &&
|
||||
expense.vendorId != expenseListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
} else if (expense.vendorId != null && !vendor.isActive) {
|
||||
return false;
|
||||
} else if (expense.clientId != null && !client.isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!expense.matchesStates(expenseListState.stateFilters)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -57,18 +84,6 @@ List<int> filteredExpensesSelector(BuiltMap<int, ExpenseEntity> expenseMap,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (expenseListState.filterEntityId != null &&
|
||||
expenseListState.filterEntityType == EntityType.client &&
|
||||
expense.clientId != expenseListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expenseListState.filterEntityId != null &&
|
||||
expenseListState.filterEntityType == EntityType.vendor &&
|
||||
expense.vendorId != expenseListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expenseListState.custom1Filters.isNotEmpty &&
|
||||
!expenseListState.custom1Filters.contains(expense.customValue1)) {
|
||||
return false;
|
||||
|
|
@ -77,12 +92,6 @@ List<int> filteredExpensesSelector(BuiltMap<int, ExpenseEntity> expenseMap,
|
|||
!expenseListState.custom2Filters.contains(expense.customValue2)) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (expenseListState.filterEntityId != null &&
|
||||
expense.entityId != expenseListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return expense.matchesFilter(expenseListState.filter);
|
||||
}).toList();
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,15 @@ List<int> filteredInvoicesSelector(
|
|||
final invoice = invoiceMap[invoiceId];
|
||||
final client =
|
||||
clientMap[invoice.clientId] ?? ClientEntity(id: invoice.clientId);
|
||||
if (client == null || !client.isActive) {
|
||||
|
||||
if (invoiceListState.filterEntityId != null) {
|
||||
if (!invoiceListState.entityMatchesFilter(client)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!client.isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!invoice.matchesStates(invoiceListState.stateFilters)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -71,10 +77,6 @@ List<int> filteredInvoicesSelector(
|
|||
!client.matchesFilter(invoiceListState.filter)) {
|
||||
return false;
|
||||
}
|
||||
if (invoiceListState.filterEntityId != null &&
|
||||
invoice.clientId != invoiceListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
if (invoiceListState.custom1Filters.isNotEmpty &&
|
||||
!invoiceListState.custom1Filters.contains(invoice.customTextValue1)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -72,20 +72,19 @@ List<int> filteredPaymentsSelector(
|
|||
invoiceMap[payment.invoiceId] ?? InvoiceEntity(id: payment.invoiceId);
|
||||
final client =
|
||||
clientMap[invoice.clientId] ?? ClientEntity(id: invoice.clientId);
|
||||
if (invoice.isDeleted || !client.isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (paymentListState.filterEntityId != null) {
|
||||
if (paymentListState.filterEntityType == EntityType.client &&
|
||||
invoiceMap[payment.invoiceId].clientId !=
|
||||
paymentListState.filterEntityId) {
|
||||
invoice.clientId != paymentListState.filterEntityId) {
|
||||
return false;
|
||||
} else if (paymentListState.filterEntityType == EntityType.invoice &&
|
||||
payment.invoiceId != paymentListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
} else if (invoice.isDeleted || !client.isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return payment.matchesFilter(paymentListState.filter);
|
||||
}).toList();
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,11 @@ List<int> filteredProjectsSelector(
|
|||
final client =
|
||||
clientMap[project.clientId] ?? ClientEntity(id: project.clientId);
|
||||
|
||||
if (!client.isActive) {
|
||||
if (projectListState.filterEntityId != null) {
|
||||
if (!projectListState.entityMatchesFilter(client)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!client.isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -83,14 +87,12 @@ List<int> filteredProjectsSelector(
|
|||
if (!project.matchesStates(projectListState.stateFilters)) {
|
||||
return false;
|
||||
}
|
||||
if (projectListState.filterEntityId != null &&
|
||||
project.clientId != projectListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (projectListState.custom1Filters.isNotEmpty &&
|
||||
!projectListState.custom1Filters.contains(project.customValue1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (projectListState.custom2Filters.isNotEmpty &&
|
||||
!projectListState.custom2Filters.contains(project.customValue2)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -22,9 +22,15 @@ List<int> filteredQuotesSelector(
|
|||
final list = quoteList.where((quoteId) {
|
||||
final quote = quoteMap[quoteId];
|
||||
final client = clientMap[quote.clientId];
|
||||
if (client == null || !client.isActive) {
|
||||
|
||||
if (quoteListState.filterEntityId != null) {
|
||||
if (!quoteListState.entityMatchesFilter(client)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!client.isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!quote.matchesStates(quoteListState.stateFilters)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -35,10 +41,6 @@ List<int> filteredQuotesSelector(
|
|||
!client.matchesFilter(quoteListState.filter)) {
|
||||
return false;
|
||||
}
|
||||
if (quoteListState.filterEntityId != null &&
|
||||
quote.clientId != quoteListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
if (quoteListState.custom1Filters.isNotEmpty &&
|
||||
!quoteListState.custom1Filters.contains(quote.customTextValue1)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,12 @@ List<int> filteredTasksSelector(
|
|||
task.projectId != taskListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
} else if (task.clientId != null && !client.isActive) {
|
||||
return false;
|
||||
} else if (task.projectId != null && !project.isActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (taskListState.custom1Filters.isNotEmpty &&
|
||||
!taskListState.custom1Filters.contains(task.customValue1)) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ abstract class ListUIState implements Built<ListUIState, ListUIStateBuilder> {
|
|||
custom2Filters: BuiltList<String>(),
|
||||
);
|
||||
}
|
||||
|
||||
ListUIState._();
|
||||
|
||||
@nullable
|
||||
|
|
@ -32,17 +33,29 @@ abstract class ListUIState implements Built<ListUIState, ListUIStateBuilder> {
|
|||
@nullable
|
||||
EntityType get filterEntityType;
|
||||
|
||||
bool entityMatchesFilter(BaseEntity entity) {
|
||||
return filterEntityId == entity.id && filterEntityType == entity.entityType;
|
||||
}
|
||||
|
||||
String get sortField;
|
||||
|
||||
bool get sortAscending;
|
||||
|
||||
BuiltList<EntityState> get stateFilters;
|
||||
|
||||
BuiltList<EntityStatus> get statusFilters;
|
||||
|
||||
BuiltList<String> get custom1Filters;
|
||||
|
||||
BuiltList<String> get custom2Filters;
|
||||
|
||||
bool get hasStateFilters =>
|
||||
stateFilters.length != 1 || stateFilters.first != EntityState.active;
|
||||
|
||||
bool get hasStatusFilters => statusFilters.isNotEmpty;
|
||||
|
||||
bool get hasCustom1Filters => custom1Filters.isNotEmpty;
|
||||
|
||||
bool get hasCustom2Filters => custom2Filters.isNotEmpty;
|
||||
|
||||
//factory EntityUIState([void updates(EntityUIStateBuilder b)]) = _$listUIState;
|
||||
|
|
|
|||
|
|
@ -31,29 +31,21 @@ List<int> filteredVendorsSelector(BuiltMap<int, VendorEntity> vendorMap,
|
|||
BuiltList<int> vendorList, ListUIState vendorListState) {
|
||||
final list = vendorList.where((vendorId) {
|
||||
final vendor = vendorMap[vendorId];
|
||||
|
||||
if (!vendor.matchesStates(vendorListState.stateFilters)) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (vendorListState.filterEntityId != null &&
|
||||
vendor.clientId != vendorListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
if (vendorListState.custom1Filters.isNotEmpty &&
|
||||
!vendorListState.custom1Filters.contains(vendor.customValue1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vendorListState.custom2Filters.isNotEmpty &&
|
||||
!vendorListState.custom2Filters.contains(vendor.customValue2)) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (vendorListState.filterEntityId != null &&
|
||||
vendor.entityId != vendorListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
return vendor.matchesFilter(vendorListState.filter);
|
||||
}).toList();
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ class ExpenseListVM {
|
|||
user: state.user,
|
||||
listState: state.expenseListState,
|
||||
expenseList: memoizedFilteredExpenseList(state.expenseState.map,
|
||||
state.clientState.map, state.vendorState.map,
|
||||
state.expenseState.list, state.expenseListState),
|
||||
expenseMap: state.expenseState.map,
|
||||
isLoading: state.isLoading,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class VendorListItem extends StatelessWidget {
|
|||
final Function(EntityAction) onEntityAction;
|
||||
final GestureTapCallback onTap;
|
||||
final GestureTapCallback onLongPress;
|
||||
|
||||
//final ValueChanged<bool> onCheckboxChanged;
|
||||
final VendorEntity vendor;
|
||||
final String filter;
|
||||
|
|
@ -70,11 +71,12 @@ class VendorListItem extends StatelessWidget {
|
|||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
filterMatch,
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (filterMatch != null)
|
||||
Text(
|
||||
filterMatch,
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
EntityStateLabel(vendor),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class _VendorViewState extends State<VendorView>
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = TabController(vsync: this, length: 3);
|
||||
_controller = TabController(vsync: this, length: 2);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -37,15 +37,16 @@ List<int> filteredStubsSelector(BuiltMap<int, StubEntity> stubMap,
|
|||
BuiltList<int> stubList, ListUIState stubListState) {
|
||||
final list = stubList.where((stubId) {
|
||||
final stub = stubMap[stubId];
|
||||
if (stubListState.filterEntityId != null &&
|
||||
stub.entityId != stubListState.filterEntityId) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
if (!stub.matchesStates(stubListState.stateFilters)) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (stubListState.filterEntityId != null &&
|
||||
stub.clientId != stubListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
if (stubListState.custom1Filters.isNotEmpty &&
|
||||
!stubListState.custom1Filters.contains(stub.customValue1)) {
|
||||
return false;
|
||||
|
|
@ -54,12 +55,6 @@ List<int> filteredStubsSelector(BuiltMap<int, StubEntity> stubMap,
|
|||
!stubListState.custom2Filters.contains(stub.customValue2)) {
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (stubListState.filterEntityId != null &&
|
||||
stub.entityId != stubListState.filterEntityId) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
return stub.matchesFilter(stubListState.filter);
|
||||
}).toList();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue