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