From 9eacdabc1533ceb9b81c5ee69e436cbba8e1b17f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 12 Nov 2019 11:08:34 +0200 Subject: [PATCH] Settings --- lib/data/models/entities.dart | 19 ++--- lib/redux/app/app_actions.dart | 72 +++++++++++++++++++ lib/ui/client/client_list_vm.dart | 9 ++- .../company_gateway_list_vm.dart | 9 +-- lib/ui/document/document_list_vm.dart | 9 +-- lib/ui/expense/expense_list_vm.dart | 19 ++--- lib/ui/group/group_list_vm.dart | 8 ++- lib/ui/invoice/invoice_list_vm.dart | 15 ++-- lib/ui/payment/payment_list_vm.dart | 20 ++---- lib/ui/project/project_list_vm.dart | 9 +-- lib/ui/quote/quote_list_vm.dart | 9 ++- lib/ui/task/task_list_vm.dart | 20 ++---- lib/ui/tax_rate/tax_rate_list_vm.dart | 9 +-- lib/ui/user/user_list_vm.dart | 8 ++- lib/ui/vendor/vendor_list_vm.dart | 9 +-- stubs/ui/stub/stub_list_vm | 9 +-- 16 files changed, 156 insertions(+), 97 deletions(-) diff --git a/lib/data/models/entities.dart b/lib/data/models/entities.dart index fc4cd2916..68177860f 100644 --- a/lib/data/models/entities.dart +++ b/lib/data/models/entities.dart @@ -12,27 +12,30 @@ class EntityType extends EnumClass { static Serializer get serializer => _$entityTypeSerializer; - static const EntityType company = _$company; static const EntityType taxRate = _$taxRate; static const EntityType companyGateway = _$companyGateway; - static const EntityType gateway = _$gateway; - static const EntityType gatewayToken = _$gatewayToken; static const EntityType invoice = _$invoice; static const EntityType recurringInvoice = _$recurringInvoice; - static const EntityType invoiceItem = _$invoiceItem; static const EntityType quote = _$quote; - static const EntityType quoteItem = _$quoteItem; static const EntityType product = _$product; static const EntityType client = _$client; - static const EntityType contact = _$contact; static const EntityType task = _$task; static const EntityType project = _$project; static const EntityType expense = _$expense; static const EntityType expenseCategory = _$expenseCategory; static const EntityType vendor = _$vendor; - static const EntityType vendorContact = _$vendorContact; static const EntityType credit = _$credit; static const EntityType payment = _$payment; + static const EntityType group = _$group; + static const EntityType user = _$user; + + static const EntityType company = _$company; + static const EntityType gateway = _$gateway; + static const EntityType gatewayToken = _$gatewayToken; + static const EntityType invoiceItem = _$invoiceItem; + static const EntityType quoteItem = _$quoteItem; + static const EntityType contact = _$contact; + static const EntityType vendorContact = _$vendorContact; static const EntityType country = _$country; static const EntityType currency = _$currency; static const EntityType language = _$language; @@ -41,11 +44,9 @@ class EntityType extends EnumClass { static const EntityType paymentType = _$paymentType; static const EntityType taskStatus = _$taskStatus; static const EntityType document = _$document; - static const EntityType group = _$group; static const EntityType timezone = _$timezone; static const EntityType dateFormat = _$dateFormat; static const EntityType font = _$font; - static const EntityType user = _$user; String get plural { return toString() + 's'; diff --git a/lib/redux/app/app_actions.dart b/lib/redux/app/app_actions.dart index 6ebbc7528..a85150469 100644 --- a/lib/redux/app/app_actions.dart +++ b/lib/redux/app/app_actions.dart @@ -1,8 +1,23 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/entities.dart'; import 'package:invoiceninja_flutter/data/models/static/static_data_model.dart'; +import 'package:invoiceninja_flutter/redux/app/app_state.dart'; +import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; +import 'package:invoiceninja_flutter/redux/company_gateway/company_gateway_actions.dart'; +import 'package:invoiceninja_flutter/redux/expense/expense_actions.dart'; +import 'package:invoiceninja_flutter/redux/group/group_actions.dart'; +import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart'; +import 'package:invoiceninja_flutter/redux/payment/payment_actions.dart'; +import 'package:invoiceninja_flutter/redux/product/product_actions.dart'; +import 'package:invoiceninja_flutter/redux/project/project_actions.dart'; +import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart'; +import 'package:invoiceninja_flutter/redux/task/task_actions.dart'; +import 'package:invoiceninja_flutter/redux/tax_rate/tax_rate_actions.dart'; import 'package:invoiceninja_flutter/redux/ui/ui_state.dart'; +import 'package:invoiceninja_flutter/redux/user/user_actions.dart'; +import 'package:invoiceninja_flutter/redux/vendor/vendor_actions.dart'; class PersistUI {} @@ -94,3 +109,60 @@ class FilterCompany { final String filter; } + +void viewEntityById( + {BuildContext context, String entityId, EntityType entityType}) { + final store = StoreProvider.of(context); + switch (entityType) { + case EntityType.client: + store.dispatch(ViewClient(clientId: entityId, context: context)); + break; + case EntityType.user: + store.dispatch(ViewUser(userId: entityId, context: context)); + break; + case EntityType.project: + store.dispatch(ViewProject(projectId: entityId, context: context)); + break; + case EntityType.taxRate: + store.dispatch(ViewTaxRate(taxRateId: entityId, context: context)); + break; + case EntityType.companyGateway: + store.dispatch( + ViewCompanyGateway(companyGatewayId: entityId, context: context)); + break; + case EntityType.invoice: + store.dispatch(ViewInvoice(invoiceId: entityId, context: context)); + break; + //case EntityType.recurringInvoice: + //store.dispatch(ViewRecurringInvoice(recurringInvoiceId: entityId, context: context)); + //break; + case EntityType.quote: + store.dispatch(ViewQuote(quoteId: entityId, context: context)); + break; + case EntityType.vendor: + store.dispatch(ViewVendor(vendorId: entityId, context: context)); + break; + case EntityType.product: + store.dispatch(ViewProduct(productId: entityId, context: context)); + break; + case EntityType.task: + store.dispatch(ViewTask(taskId: entityId, context: context)); + break; + case EntityType.expense: + store.dispatch(ViewExpense(expenseId: entityId, context: context)); + break; + //case EntityType.expenseCategory: + //store.dispatch(ViewExpenseCategory(taxRateId: entityId, context: context)); + //break; + //case EntityType.credit: + //store.dispatch(ViewCredit(creditId: entityId, context: context)); + //break; + case EntityType.payment: + store.dispatch(ViewPayment(paymentId: entityId, context: context)); + break; + case EntityType.group: + store.dispatch(ViewGroup(groupId: entityId, context: context)); + break; + // TODO Add to starter + } +} diff --git a/lib/ui/client/client_list_vm.dart b/lib/ui/client/client_list_vm.dart index 36da1321b..b140588c8 100644 --- a/lib/ui/client/client_list_vm.dart +++ b/lib/ui/client/client_list_vm.dart @@ -6,10 +6,12 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/client/client_selectors.dart'; import 'package:invoiceninja_flutter/redux/group/group_actions.dart'; +import 'package:invoiceninja_flutter/redux/user/user_actions.dart'; import 'package:invoiceninja_flutter/ui/client/client_list.dart'; import 'package:invoiceninja_flutter/utils/completers.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; @@ -88,9 +90,10 @@ class ClientListVM { EntityAction action) => handleClientAction(context, client, action), onClearEntityFilterPressed: () => store.dispatch(FilterClientsByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewGroup( - groupId: state.clientListState.filterEntityId, context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.clientListState.filterEntityId, + entityType: state.clientListState.filterEntityType), ); } } diff --git a/lib/ui/company_gateway/company_gateway_list_vm.dart b/lib/ui/company_gateway/company_gateway_list_vm.dart index e9581e8e1..cb6568902 100644 --- a/lib/ui/company_gateway/company_gateway_list_vm.dart +++ b/lib/ui/company_gateway/company_gateway_list_vm.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:invoiceninja_flutter/data/models/company_gateway_model.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart'; import 'package:redux/redux.dart'; import 'package:flutter/material.dart'; @@ -84,10 +85,10 @@ class CompanyGatewayListVM { filter: state.companyGatewayUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterCompanyGatewaysByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.companyGatewayListState.filterEntityId, - context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.companyGatewayListState.filterEntityId, + entityType: state.companyGatewayListState.filterEntityType), onCompanyGatewayTap: (context, companyGateway) { store.dispatch(ViewCompanyGateway( companyGatewayId: companyGateway.id, context: context)); diff --git a/lib/ui/document/document_list_vm.dart b/lib/ui/document/document_list_vm.dart index 055aa8cbc..263c9b4cb 100644 --- a/lib/ui/document/document_list_vm.dart +++ b/lib/ui/document/document_list_vm.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/document/document_actions.dart'; @@ -72,10 +73,10 @@ class DocumentListVM { filter: state.documentUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterDocumentsByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.documentListState.filterEntityId, - context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.documentListState.filterEntityId, + entityType: state.documentListState.filterEntityType), onDocumentTap: (context, document) { store.dispatch(ViewDocument(documentId: document.id, context: context)); }, diff --git a/lib/ui/expense/expense_list_vm.dart b/lib/ui/expense/expense_list_vm.dart index bd077bcec..8a1e293fd 100644 --- a/lib/ui/expense/expense_list_vm.dart +++ b/lib/ui/expense/expense_list_vm.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/expense/expense_actions.dart'; @@ -79,20 +80,10 @@ class ExpenseListVM { filter: state.expenseUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterExpensesByEntity()), - onViewEntityFilterPressed: (BuildContext context) { - switch (state.expenseListState.filterEntityType) { - case EntityType.client: - store.dispatch(ViewClient( - clientId: state.expenseListState.filterEntityId, - context: context)); - break; - case EntityType.vendor: - store.dispatch(ViewVendor( - vendorId: state.expenseListState.filterEntityId, - context: context)); - break; - } - }, + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.expenseListState.filterEntityId, + entityType: state.expenseListState.filterEntityType), onExpenseTap: (context, expense) { store.dispatch(ViewExpense(expenseId: expense.id, context: context)); }, diff --git a/lib/ui/group/group_list_vm.dart b/lib/ui/group/group_list_vm.dart index 3bb6bf174..c5980bce8 100644 --- a/lib/ui/group/group_list_vm.dart +++ b/lib/ui/group/group_list_vm.dart @@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/group_model.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/group/group_actions.dart'; @@ -72,9 +73,10 @@ class GroupListVM { isLoaded: state.groupState.isLoaded, filter: state.groupUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterGroupsByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.groupListState.filterEntityId, context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.groupListState.filterEntityId, + entityType: state.groupListState.filterEntityType), onGroupTap: (context, group) { store.dispatch(ViewGroup(groupId: group.id, context: context)); }, diff --git a/lib/ui/invoice/invoice_list_vm.dart b/lib/ui/invoice/invoice_list_vm.dart index c864a0702..abe77df35 100644 --- a/lib/ui/invoice/invoice_list_vm.dart +++ b/lib/ui/invoice/invoice_list_vm.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart'; @@ -136,16 +137,10 @@ class InvoiceListVM extends EntityListVM { onRefreshed: (context) => _handleRefresh(context), onClearEntityFilterPressed: () => store.dispatch(FilterInvoicesByEntity()), - onViewEntityFilterPressed: (BuildContext context) { - if (state.invoiceListState.filterEntityType == EntityType.client) { - store.dispatch(ViewClient( - clientId: state.invoiceListState.filterEntityId, - context: context)); - } else if (state.invoiceListState.filterEntityType == EntityType.user) { - store.dispatch(ViewUser( - userId: state.invoiceListState.filterEntityId, context: context)); - } - }, + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.invoiceListState.filterEntityId, + entityType: state.invoiceListState.filterEntityType), onEntityAction: (BuildContext context, List invoices, EntityAction action) => handleInvoiceAction(context, invoices, action), diff --git a/lib/ui/payment/payment_list_vm.dart b/lib/ui/payment/payment_list_vm.dart index 5903c55da..5b52990ac 100644 --- a/lib/ui/payment/payment_list_vm.dart +++ b/lib/ui/payment/payment_list_vm.dart @@ -6,12 +6,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart'; import 'package:invoiceninja_flutter/redux/payment/payment_actions.dart'; import 'package:invoiceninja_flutter/redux/payment/payment_selectors.dart'; import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart'; +import 'package:invoiceninja_flutter/redux/user/user_actions.dart'; import 'package:invoiceninja_flutter/ui/payment/payment_list.dart'; import 'package:invoiceninja_flutter/utils/completers.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; @@ -85,20 +87,10 @@ class PaymentListVM { handlePaymentAction(context, payments, action), onClearEntityFilterPressed: () => store.dispatch(FilterPaymentsByEntity()), - onViewEntityFilterPressed: (BuildContext context) { - switch (state.paymentListState.filterEntityType) { - case EntityType.client: - store.dispatch(ViewClient( - clientId: state.paymentListState.filterEntityId, - context: context)); - break; - case EntityType.invoice: - store.dispatch(ViewInvoice( - invoiceId: state.paymentListState.filterEntityId, - context: context)); - break; - } - }, + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.paymentListState.filterEntityId, + entityType: state.paymentListState.filterEntityType), onRefreshed: (context) => _handleRefresh(context), ); } diff --git a/lib/ui/project/project_list_vm.dart b/lib/ui/project/project_list_vm.dart index 428610d2d..7872bb906 100644 --- a/lib/ui/project/project_list_vm.dart +++ b/lib/ui/project/project_list_vm.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/project/project_actions.dart'; @@ -77,10 +78,10 @@ class ProjectListVM { filter: state.projectUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterProjectsByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.projectListState.filterEntityId, - context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.projectListState.filterEntityId, + entityType: state.projectListState.filterEntityType), onProjectTap: (context, project) { store.dispatch(ViewProject(projectId: project.id, context: context)); }, diff --git a/lib/ui/quote/quote_list_vm.dart b/lib/ui/quote/quote_list_vm.dart index 9898c495f..9f5d06d6f 100644 --- a/lib/ui/quote/quote_list_vm.dart +++ b/lib/ui/quote/quote_list_vm.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:built_collection/built_collection.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart'; import 'package:invoiceninja_flutter/redux/quote/quote_selectors.dart'; @@ -8,6 +9,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart'; +import 'package:invoiceninja_flutter/redux/user/user_actions.dart'; import 'package:invoiceninja_flutter/ui/invoice/invoice_list.dart'; import 'package:invoiceninja_flutter/ui/invoice/invoice_list_vm.dart'; import 'package:invoiceninja_flutter/utils/completers.dart'; @@ -96,9 +98,10 @@ class QuoteListVM extends EntityListVM { }, onRefreshed: (context) => _handleRefresh(context), onClearEntityFilterPressed: () => store.dispatch(FilterQuotesByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.quoteListState.filterEntityId, context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.quoteListState.filterEntityId, + entityType: state.quoteListState.filterEntityType), onEntityAction: (BuildContext context, List quotes, EntityAction action) => handleQuoteAction(context, quotes, action), diff --git a/lib/ui/task/task_list_vm.dart b/lib/ui/task/task_list_vm.dart index 6d0a721ab..dc8860691 100644 --- a/lib/ui/task/task_list_vm.dart +++ b/lib/ui/task/task_list_vm.dart @@ -6,12 +6,14 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/project/project_actions.dart'; import 'package:invoiceninja_flutter/redux/task/task_actions.dart'; import 'package:invoiceninja_flutter/redux/task/task_selectors.dart'; import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart'; +import 'package:invoiceninja_flutter/redux/user/user_actions.dart'; import 'package:invoiceninja_flutter/ui/task/task_list.dart'; import 'package:invoiceninja_flutter/utils/completers.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; @@ -80,20 +82,10 @@ class TaskListVM { isLoaded: state.taskState.isLoaded, filter: state.taskUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterTasksByEntity()), - onViewEntityFilterPressed: (BuildContext context) { - switch (state.taskListState.filterEntityType) { - case EntityType.client: - store.dispatch(ViewClient( - clientId: state.taskListState.filterEntityId, - context: context)); - break; - case EntityType.project: - store.dispatch(ViewProject( - projectId: state.taskListState.filterEntityId, - context: context)); - break; - } - }, + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.taskListState.filterEntityId, + entityType: state.taskListState.filterEntityType), onTaskTap: (context, task) { store.dispatch(ViewTask(taskId: task.id, context: context)); }, diff --git a/lib/ui/tax_rate/tax_rate_list_vm.dart b/lib/ui/tax_rate/tax_rate_list_vm.dart index 2e1819fed..0db56b7ba 100644 --- a/lib/ui/tax_rate/tax_rate_list_vm.dart +++ b/lib/ui/tax_rate/tax_rate_list_vm.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:invoiceninja_flutter/data/models/tax_rate_model.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:redux/redux.dart'; import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; @@ -72,10 +73,10 @@ class TaxRateListVM { filter: state.taxRateUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterTaxRatesByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.taxRateListState.filterEntityId, - context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.taxRateListState.filterEntityId, + entityType: state.taxRateListState.filterEntityType), onTaxRateTap: (context, taxRate) { store.dispatch(ViewTaxRate(taxRateId: taxRate.id, context: context)); }, diff --git a/lib/ui/user/user_list_vm.dart b/lib/ui/user/user_list_vm.dart index 1192048a3..54904d1f5 100644 --- a/lib/ui/user/user_list_vm.dart +++ b/lib/ui/user/user_list_vm.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:invoiceninja_flutter/data/models/user_model.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:redux/redux.dart'; import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; @@ -71,9 +72,10 @@ class UserListVM { isLoaded: state.userState.isLoaded, filter: state.userUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterUsersByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.userListState.filterEntityId, context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.userListState.filterEntityId, + entityType: state.userListState.filterEntityType), onUserTap: (context, user) { store.dispatch(ViewUser(userId: user.id, context: context)); }, diff --git a/lib/ui/vendor/vendor_list_vm.dart b/lib/ui/vendor/vendor_list_vm.dart index 2f328713f..d88c75184 100644 --- a/lib/ui/vendor/vendor_list_vm.dart +++ b/lib/ui/vendor/vendor_list_vm.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:invoiceninja_flutter/data/models/models.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/client/client_actions.dart'; import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart'; @@ -71,10 +72,10 @@ class VendorListVM { isLoaded: state.vendorState.isLoaded, filter: state.vendorUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterVendorsByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.vendorListState.filterEntityId, - context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.vendorListState.filterEntityId, + entityType: state.vendorListState.filterEntityType), onVendorTap: (context, vendor) { store.dispatch(ViewVendor(vendorId: vendor.id, context: context)); }, diff --git a/stubs/ui/stub/stub_list_vm b/stubs/ui/stub/stub_list_vm index ff17e57a8..b4a06a620 100644 --- a/stubs/ui/stub/stub_list_vm +++ b/stubs/ui/stub/stub_list_vm @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:invoiceninja_flutter/data/models/stub_model.dart'; import 'package:redux/redux.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; @@ -72,10 +73,10 @@ class StubListVM { filter: state.stubUIState.listUIState.filter, onClearEntityFilterPressed: () => store.dispatch(FilterStubsByEntity()), - onViewEntityFilterPressed: (BuildContext context) => store.dispatch( - ViewClient( - clientId: state.stubListState.filterEntityId, - context: context)), + onViewEntityFilterPressed: (BuildContext context) => viewEntityById( + context: context, + entityId: state.stubListState.filterEntityId, + entityType: state.stubListState.filterEntityType), onStubTap: (context, stub) { store.dispatch(ViewStub(stubId: stub.id, context: context)); },