Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Jan 30, 2022
2 parents 9855e3f + 82ec286 commit 3dd2229
Show file tree
Hide file tree
Showing 17 changed files with 497 additions and 442 deletions.
22 changes: 20 additions & 2 deletions lib/data/models/client_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,26 @@ abstract class ClientEntity extends Object
return response;
}

bool matchesName(String filter) =>
displayName.toLowerCase().contains(filter.toLowerCase());
bool matchesNameOrEmail(String filter) {
filter = filter.toLowerCase();

if (name.toLowerCase().contains(filter)) {
return true;
}

for (var i = 0; i < contacts.length; i++) {
final contact = contacts[i];
if (contact.fullName.toLowerCase().contains(filter)) {
return true;
}

if (contact.email.toLowerCase().contains(filter)) {
return true;
}
}

return false;
}

@override
bool matchesFilter(String filter) {
Expand Down
22 changes: 20 additions & 2 deletions lib/data/models/vendor_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,26 @@ abstract class VendorEntity extends Object
return response;
}

bool matchesName(String filter) =>
name.toLowerCase().contains(filter.toLowerCase());
bool matchesNameOrEmail(String filter) {
filter = filter.toLowerCase();

if (name.toLowerCase().contains(filter)) {
return true;
}

for (var i = 0; i < contacts.length; i++) {
final contact = contacts[i];
if (contact.fullName.toLowerCase().contains(filter)) {
return true;
}

if (contact.email.toLowerCase().contains(filter)) {
return true;
}
}

return false;
}

@override
bool matchesFilter(String filter) {
Expand Down
5 changes: 3 additions & 2 deletions lib/redux/app/app_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,9 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {

//bool get isEnterprisePlan => isSelfHosted || account.plan == kPlanEnterprise;

bool get isPaidAccount =>
isSelfHosted ? isWhiteLabeled : (isProPlan || isEnterprisePlan);
bool get isPaidAccount => isSelfHosted
? isWhiteLabeled
: ((isProPlan || isEnterprisePlan) && !isTrial);

bool get isUserConfirmed {
if (isSelfHosted) {
Expand Down
2 changes: 1 addition & 1 deletion lib/redux/credit/credit_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ List<String> filteredCreditsSelector(
return false;
}
if (!credit.matchesFilter(creditListState.filter) &&
!client.matchesName(creditListState.filter)) {
!client.matchesNameOrEmail(creditListState.filter)) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/redux/expense/expense_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ List<String> filteredExpensesSelector(

return expense.matchesFilter(expenseListState.filter) ||
expenseCategory.matchesFilter(expenseListState.filter) ||
client.matchesName(expenseListState.filter) ||
vendor.matchesName(expenseListState.filter);
client.matchesNameOrEmail(expenseListState.filter) ||
vendor.matchesNameOrEmail(expenseListState.filter);
}).toList();

list.sort((expenseAId, expenseBId) {
Expand Down
2 changes: 1 addition & 1 deletion lib/redux/invoice/invoice_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ List<String> filteredInvoicesSelector(
return false;
}
if (!invoice.matchesFilter(invoiceListState.filter) &&
!client.matchesName(invoiceListState.filter)) {
!client.matchesNameOrEmail(invoiceListState.filter)) {
return false;
}
if (invoiceListState.custom1Filters.isNotEmpty &&
Expand Down
2 changes: 1 addition & 1 deletion lib/redux/payment/payment_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ List<String> filteredPaymentsSelector(
}

if (!payment.matchesFilter(paymentListState.filter) &&
!client.matchesName(paymentListState.filter)) {
!client.matchesNameOrEmail(paymentListState.filter)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/redux/project/project_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ List<String> filteredProjectsSelector(
}

if (!project.matchesFilter(projectListState.filter) &&
!client.matchesName(projectListState.filter)) {
!client.matchesNameOrEmail(projectListState.filter)) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/redux/quote/quote_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ List<String> filteredQuotesSelector(
} else if (!quote.matchesStatuses(quoteListState.statusFilters)) {
return false;
} else if (!quote.matchesFilter(quoteListState.filter) &&
!client.matchesName(quoteListState.filter)) {
!client.matchesNameOrEmail(quoteListState.filter)) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/redux/recurring_expense/recurring_expense_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ List<String> filteredRecurringExpensesSelector(

return expense.matchesFilter(expenseListState.filter) ||
expenseCategory.matchesFilter(expenseListState.filter) ||
client.matchesName(expenseListState.filter) ||
vendor.matchesName(expenseListState.filter);
client.matchesNameOrEmail(expenseListState.filter) ||
vendor.matchesNameOrEmail(expenseListState.filter);
}).toList();

list.sort((expenseAId, expenseBId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ List<String> filteredRecurringInvoicesSelector(
return false;
}
if (!invoice.matchesFilter(invoiceListState.filter) &&
!client.matchesName(invoiceListState.filter)) {
!client.matchesNameOrEmail(invoiceListState.filter)) {
return false;
}
if (invoiceListState.custom1Filters.isNotEmpty &&
Expand Down
2 changes: 1 addition & 1 deletion lib/redux/task/task_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ List<String> filteredTasksSelector(
}

if (!task.matchesFilter(taskListState.filter) &&
!client.matchesName(taskListState.filter) &&
!client.matchesNameOrEmail(taskListState.filter) &&
!project.matchesName(taskListState.filter)) {
return false;
}
Expand Down
22 changes: 10 additions & 12 deletions lib/ui/app/menu_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -654,16 +654,16 @@ class _DrawerTileState extends State<DrawerTile> {
color: textColor,
),
),
title: Text(
widget.title,
key: ValueKey('menu_${widget.title}'),
overflow: TextOverflow.clip,
maxLines: 1,
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontSize: 14,
color: textColor,
title: state.isMenuCollapsed
? SizedBox()
: Text(
widget.title,
key: ValueKey('menu_${widget.title}'),
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontSize: 14,
color: textColor,
),
),
),
onTap: () {
if (widget.entityType != null) {
viewEntitiesByType(
Expand Down Expand Up @@ -825,9 +825,7 @@ class SidebarFooter extends StatelessWidget {
),
if (isHosted(context) && !isPaidAccount(context) && !isApple())
IconButton(
tooltip: isHosted(context)
? localization.upgrade
: localization.purchaseLicense,
tooltip: localization.upgrade,
icon: Icon(Icons.arrow_circle_up),
color: Colors.green,
onPressed: () async {
Expand Down
10 changes: 10 additions & 0 deletions lib/ui/app/menu_drawer_vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ class MenuDrawerVM {
});
},
onAddCompany: (BuildContext context) {
if (state.isHosted &&
!state.isPaidAccount &&
state.companies.length >= state.account.hostedCompanyCount) {
showMessageDialog(
context: context,
message: AppLocalization.of(context).requiresAPaidPlan,
);
return;
}

confirmCallback(
context: context,
message: AppLocalization.of(context).addCompany,
Expand Down
Loading

0 comments on commit 3dd2229

Please sign in to comment.