Refactor
This commit is contained in:
parent
ae61539d21
commit
1acb53ff34
|
|
@ -321,8 +321,8 @@ Middleware<AppState> _createUserLoggedIn(
|
|||
authRepository.saveAuthState(state.authState);
|
||||
uiRepository.saveUIState(state.uiState);
|
||||
staticRepository.saveStaticState(state.staticState);
|
||||
for (var i = 0; i < state.companyStates.length; i++) {
|
||||
companyRepositories[i].saveCompanyState(state.companyStates[i]);
|
||||
for (var i = 0; i < state.userCompanyStates.length; i++) {
|
||||
companyRepositories[i].saveCompanyState(state.userCompanyStates[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -402,7 +402,7 @@ Middleware<AppState> _createPersistData(
|
|||
final AppState state = store.state;
|
||||
final index = state.uiState.selectedCompanyIndex;
|
||||
|
||||
companyRepositories[index].saveCompanyState(state.companyStates[index]);
|
||||
companyRepositories[index].saveCompanyState(state.userCompanyStates[index]);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ AppState appReducer(AppState state, dynamic action) {
|
|||
..authState.replace(authReducer(state.authState, action))
|
||||
..staticState.replace(staticReducer(state.staticState, action))
|
||||
..companyStates[state.uiState.selectedCompanyIndex] = companyReducer(
|
||||
state.companyStates[state.uiState.selectedCompanyIndex], action)
|
||||
state.userCompanyStates[state.uiState.selectedCompanyIndex], action)
|
||||
..uiState.replace(uiReducer(state.uiState, action)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
lastError: '',
|
||||
authState: AuthState(),
|
||||
staticState: StaticState(),
|
||||
companyStates: List<int>.generate(10, (i) => i + 1)
|
||||
userCompanyStates: List<int>.generate(10, (i) => i + 1)
|
||||
.map((index) => UserCompanyState())
|
||||
.toList(),
|
||||
uiState: uiState ?? UIState(),
|
||||
|
|
@ -83,13 +83,13 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
|
||||
UIState get uiState;
|
||||
|
||||
List<UserCompanyState> get companyStates;
|
||||
List<UserCompanyState> get userCompanyStates;
|
||||
|
||||
//factory AppState([void updates(AppStateBuilder b)]) = _$AppState;
|
||||
static Serializer<AppState> get serializer => _$appStateSerializer;
|
||||
|
||||
UserCompanyState get selectedCompanyState =>
|
||||
companyStates[uiState.selectedCompanyIndex];
|
||||
UserCompanyState get userCompanyState =>
|
||||
userCompanyStates[uiState.selectedCompanyIndex];
|
||||
|
||||
bool get isLoaded {
|
||||
return dashboardState.isLoaded &&
|
||||
|
|
@ -97,18 +97,18 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
clientState.isLoaded;
|
||||
}
|
||||
|
||||
CompanyEntity get selectedCompany => selectedCompanyState.company;
|
||||
CompanyEntity get company => userCompanyState.company;
|
||||
|
||||
DashboardState get dashboardState => selectedCompanyState.dashboardState;
|
||||
DashboardState get dashboardState => userCompanyState.dashboardState;
|
||||
|
||||
DashboardUIState get dashboardUIState => uiState.dashboardUIState;
|
||||
|
||||
UserEntity get user => selectedCompanyState.user;
|
||||
UserEntity get user => userCompanyState.user;
|
||||
|
||||
UserCompanyEntity get userCompany => selectedCompanyState.userCompany;
|
||||
UserCompanyEntity get userCompany => userCompanyState.userCompany;
|
||||
|
||||
Credentials get credentials =>
|
||||
Credentials(token: selectedCompanyState.token.token, url: authState.url);
|
||||
Credentials(token: userCompanyState.token.token, url: authState.url);
|
||||
|
||||
BuiltMap<String, SelectableEntity> getEntityMap(EntityType type) {
|
||||
switch (type) {
|
||||
|
|
@ -143,7 +143,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
return quoteState.map;
|
||||
case EntityType.expenseCategory:
|
||||
// TODO move to expenseCategoryState.map
|
||||
return selectedCompany.expenseCategoryMap;
|
||||
return company.expenseCategoryMap;
|
||||
case EntityType.paymentType:
|
||||
return staticState.paymentTypeMap;
|
||||
case EntityType.currency:
|
||||
|
|
@ -207,39 +207,39 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
return getUIState(type).listUIState;
|
||||
}
|
||||
|
||||
ProductState get productState => selectedCompanyState.productState;
|
||||
ProductState get productState => userCompanyState.productState;
|
||||
|
||||
ProductUIState get productUIState => uiState.productUIState;
|
||||
|
||||
ListUIState get productListState => uiState.productUIState.listUIState;
|
||||
|
||||
ClientState get clientState => selectedCompanyState.clientState;
|
||||
ClientState get clientState => userCompanyState.clientState;
|
||||
|
||||
ClientUIState get clientUIState => uiState.clientUIState;
|
||||
|
||||
ListUIState get clientListState => uiState.clientUIState.listUIState;
|
||||
|
||||
InvoiceState get invoiceState => selectedCompanyState.invoiceState;
|
||||
InvoiceState get invoiceState => userCompanyState.invoiceState;
|
||||
|
||||
InvoiceUIState get invoiceUIState => uiState.invoiceUIState;
|
||||
|
||||
ListUIState get invoiceListState => uiState.invoiceUIState.listUIState;
|
||||
|
||||
// STARTER: state getters - do not remove comment
|
||||
UserState get userState => selectedCompanyState.userState;
|
||||
UserState get userState => userCompanyState.userState;
|
||||
|
||||
ListUIState get userListState => uiState.userUIState.listUIState;
|
||||
|
||||
UserUIState get userUIState => uiState.userUIState;
|
||||
|
||||
TaxRateState get taxRateState => selectedCompanyState.taxRateState;
|
||||
TaxRateState get taxRateState => userCompanyState.taxRateState;
|
||||
|
||||
ListUIState get taxRateListState => uiState.taxRateUIState.listUIState;
|
||||
|
||||
TaxRateUIState get taxRateUIState => uiState.taxRateUIState;
|
||||
|
||||
CompanyGatewayState get companyGatewayState =>
|
||||
selectedCompanyState.companyGatewayState;
|
||||
userCompanyState.companyGatewayState;
|
||||
|
||||
ListUIState get companyGatewayListState =>
|
||||
uiState.companyGatewayUIState.listUIState;
|
||||
|
|
@ -247,49 +247,49 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
CompanyGatewayUIState get companyGatewayUIState =>
|
||||
uiState.companyGatewayUIState;
|
||||
|
||||
GroupState get groupState => selectedCompanyState.groupState;
|
||||
GroupState get groupState => userCompanyState.groupState;
|
||||
|
||||
ListUIState get groupListState => uiState.groupUIState.listUIState;
|
||||
|
||||
GroupUIState get groupUIState => uiState.groupUIState;
|
||||
|
||||
DocumentState get documentState => selectedCompanyState.documentState;
|
||||
DocumentState get documentState => userCompanyState.documentState;
|
||||
|
||||
ListUIState get documentListState => uiState.documentUIState.listUIState;
|
||||
|
||||
DocumentUIState get documentUIState => uiState.documentUIState;
|
||||
|
||||
ExpenseState get expenseState => selectedCompanyState.expenseState;
|
||||
ExpenseState get expenseState => userCompanyState.expenseState;
|
||||
|
||||
ListUIState get expenseListState => uiState.expenseUIState.listUIState;
|
||||
|
||||
ExpenseUIState get expenseUIState => uiState.expenseUIState;
|
||||
|
||||
VendorState get vendorState => selectedCompanyState.vendorState;
|
||||
VendorState get vendorState => userCompanyState.vendorState;
|
||||
|
||||
ListUIState get vendorListState => uiState.vendorUIState.listUIState;
|
||||
|
||||
VendorUIState get vendorUIState => uiState.vendorUIState;
|
||||
|
||||
TaskState get taskState => selectedCompanyState.taskState;
|
||||
TaskState get taskState => userCompanyState.taskState;
|
||||
|
||||
ListUIState get taskListState => uiState.taskUIState.listUIState;
|
||||
|
||||
TaskUIState get taskUIState => uiState.taskUIState;
|
||||
|
||||
ProjectState get projectState => selectedCompanyState.projectState;
|
||||
ProjectState get projectState => userCompanyState.projectState;
|
||||
|
||||
ListUIState get projectListState => uiState.projectUIState.listUIState;
|
||||
|
||||
ProjectUIState get projectUIState => uiState.projectUIState;
|
||||
|
||||
PaymentState get paymentState => selectedCompanyState.paymentState;
|
||||
PaymentState get paymentState => userCompanyState.paymentState;
|
||||
|
||||
ListUIState get paymentListState => uiState.paymentUIState.listUIState;
|
||||
|
||||
PaymentUIState get paymentUIState => uiState.paymentUIState;
|
||||
|
||||
QuoteState get quoteState => selectedCompanyState.quoteState;
|
||||
QuoteState get quoteState => userCompanyState.quoteState;
|
||||
|
||||
ListUIState get quoteListState => uiState.quoteUIState.listUIState;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class _$AppStateSerializer implements StructuredSerializer<AppState> {
|
|||
serializers.serialize(object.uiState,
|
||||
specifiedType: const FullType(UIState)),
|
||||
'companyStates',
|
||||
serializers.serialize(object.companyStates,
|
||||
serializers.serialize(object.userCompanyStates,
|
||||
specifiedType:
|
||||
const FullType(List, const [const FullType(UserCompanyState)])),
|
||||
];
|
||||
|
|
@ -116,7 +116,7 @@ class _$AppState extends AppState {
|
|||
@override
|
||||
final UIState uiState;
|
||||
@override
|
||||
final List<UserCompanyState> companyStates;
|
||||
final List<UserCompanyState> userCompanyStates;
|
||||
|
||||
factory _$AppState([void Function(AppStateBuilder) updates]) =>
|
||||
(new AppStateBuilder()..update(updates)).build();
|
||||
|
|
@ -129,7 +129,7 @@ class _$AppState extends AppState {
|
|||
this.authState,
|
||||
this.staticState,
|
||||
this.uiState,
|
||||
this.companyStates})
|
||||
this.userCompanyStates})
|
||||
: super._() {
|
||||
if (isLoading == null) {
|
||||
throw new BuiltValueNullFieldError('AppState', 'isLoading');
|
||||
|
|
@ -152,7 +152,7 @@ class _$AppState extends AppState {
|
|||
if (uiState == null) {
|
||||
throw new BuiltValueNullFieldError('AppState', 'uiState');
|
||||
}
|
||||
if (companyStates == null) {
|
||||
if (userCompanyStates == null) {
|
||||
throw new BuiltValueNullFieldError('AppState', 'companyStates');
|
||||
}
|
||||
}
|
||||
|
|
@ -175,7 +175,7 @@ class _$AppState extends AppState {
|
|||
authState == other.authState &&
|
||||
staticState == other.staticState &&
|
||||
uiState == other.uiState &&
|
||||
companyStates == other.companyStates;
|
||||
userCompanyStates == other.userCompanyStates;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -191,7 +191,7 @@ class _$AppState extends AppState {
|
|||
authState.hashCode),
|
||||
staticState.hashCode),
|
||||
uiState.hashCode),
|
||||
companyStates.hashCode));
|
||||
userCompanyStates.hashCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +246,7 @@ class AppStateBuilder implements Builder<AppState, AppStateBuilder> {
|
|||
_authState = _$v.authState?.toBuilder();
|
||||
_staticState = _$v.staticState?.toBuilder();
|
||||
_uiState = _$v.uiState?.toBuilder();
|
||||
_companyStates = _$v.companyStates;
|
||||
_companyStates = _$v.userCompanyStates;
|
||||
_$v = null;
|
||||
}
|
||||
return this;
|
||||
|
|
@ -278,7 +278,7 @@ class AppStateBuilder implements Builder<AppState, AppStateBuilder> {
|
|||
authState: authState.build(),
|
||||
staticState: staticState.build(),
|
||||
uiState: uiState.build(),
|
||||
companyStates: companyStates);
|
||||
userCompanyStates: companyStates);
|
||||
} catch (_) {
|
||||
String _$failedField;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ void handleClientAction(
|
|||
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
final localization = AppLocalization.of(context);
|
||||
final clientIds = clients.map((client) => client.id).toList();
|
||||
final client = clients[0];
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ List<BaseEntity> filteredSelector(String filter, UserCompanyState state) {
|
|||
List<CompanyEntity> companiesSelector(AppState state) {
|
||||
final List<CompanyEntity> list = [];
|
||||
|
||||
for (var companyState in state.companyStates) {
|
||||
for (var companyState in state.userCompanyStates) {
|
||||
if (companyState.company != null) {
|
||||
list.add(companyState.company);
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ List<CompanyEntity> companiesSelector(AppState state) {
|
|||
|
||||
String localeSelector(AppState state) {
|
||||
final locale = state.staticState
|
||||
?.languageMap[state.selectedCompany?.settings?.languageId]?.locale ??
|
||||
?.languageMap[state.company?.settings?.languageId]?.locale ??
|
||||
'en';
|
||||
|
||||
// https://github.com/flutter/flutter/issues/32090
|
||||
|
|
|
|||
|
|
@ -51,11 +51,8 @@ abstract class UserCompanyState
|
|||
quoteState: QuoteState(),
|
||||
// STARTER: constructor - do not remove comment
|
||||
userState: UserState(),
|
||||
|
||||
taxRateState: TaxRateState(),
|
||||
|
||||
companyGatewayState: CompanyGatewayState(),
|
||||
|
||||
groupState: GroupState(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ Middleware<AppState> _restoreDocument(DocumentRepository repository) {
|
|||
Middleware<AppState> _saveDocument(DocumentRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as SaveDocumentRequest;
|
||||
if (store.state.selectedCompany.isEnterprisePlan) {
|
||||
if (store.state.company.isEnterprisePlan) {
|
||||
repository
|
||||
.saveData(store.state.credentials, action.document)
|
||||
.then((DocumentEntity document) {
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ void handleExpenseAction(
|
|||
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
final localization = AppLocalization.of(context);
|
||||
final expense = expenses.first as ExpenseEntity;
|
||||
final expenseIds = expenses.map((expense) => expense.id).toList();
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ Middleware<AppState> _loadExpenses(ExpenseRepository repository) {
|
|||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
if (state.selectedCompany.isEnterprisePlan) {
|
||||
if (state.company.isEnterprisePlan) {
|
||||
if (state.documentState.isStale) {
|
||||
store.dispatch(LoadDocuments());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ void handleInvoiceAction(BuildContext context, List<BaseEntity> invoices,
|
|||
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
final localization = AppLocalization.of(context);
|
||||
final invoice = invoices.first as InvoiceEntity;
|
||||
final invoiceIds = invoices.map((invoice) => invoice.id).toList();
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ void handleProductAction(
|
|||
convertProductToInvoiceItem(context: context, product: product);
|
||||
store.dispatch(EditInvoice(
|
||||
context: context,
|
||||
invoice: InvoiceEntity(company: state.selectedCompany)
|
||||
invoice: InvoiceEntity(company: state.company)
|
||||
.rebuild((b) => b..lineItems.add(item))));
|
||||
break;
|
||||
case EntityAction.edit:
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ void handleProjectAction(
|
|||
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
final project = projects.first as ProjectEntity;
|
||||
final projectIds = projects.map((project) => project.id).toList();
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ Middleware<AppState> _uploadLogo(SettingsRepository settingsRepository) {
|
|||
final state = store.state;
|
||||
final settingsState = state.uiState.settingsUIState;
|
||||
final entityId = action.type == EntityType.company
|
||||
? state.selectedCompany.id
|
||||
? state.company.id
|
||||
: action.type == EntityType.group
|
||||
? settingsState.group.id
|
||||
: settingsState.client.id;
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ void handleTaskAction(
|
|||
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
final localization = AppLocalization.of(context);
|
||||
final task = tasks.first as TaskEntity;
|
||||
final taskIds = tasks.map((task) => task.id).toList();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ InvoiceItemEntity convertTaskToInvoiceItem(
|
|||
..taskId = task.id
|
||||
..notes = notes
|
||||
..cost = taskRateSelector(
|
||||
company: state.selectedCompany, project: project, client: client)
|
||||
company: state.company, project: project, client: client)
|
||||
..quantity = round(task.duration / 3600, 3));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ void handleVendorAction(
|
|||
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
final localization = AppLocalization.of(context);
|
||||
final vendor = vendors.first as VendorEntity;
|
||||
final vendorIds = vendors.map((vendor) => vendor.id).toList();
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class AppBuilderState extends State<AppBuilder> {
|
|||
void runCommand(BuildContext context) {
|
||||
print('### RUN COMMAND: $_command ###');
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final company = store.state.selectedCompany;
|
||||
final company = store.state.company;
|
||||
const force = true;
|
||||
dynamic action;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class DocumentGrid extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
|
||||
return ListView(
|
||||
children: [
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class AppDrawerVM {
|
|||
isLoading: state.isLoading,
|
||||
companies: companiesSelector(state),
|
||||
user: state.user,
|
||||
selectedCompany: state.selectedCompany,
|
||||
selectedCompany: state.company,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class ActivityListTile extends StatelessWidget {
|
|||
String title = localization.lookup('activity_${activity.activityTypeId}');
|
||||
title = activity.getDescription(
|
||||
title,
|
||||
user: state.selectedCompany.userMap[activity.userId] ?? UserEntity(),
|
||||
user: state.company.userMap[activity.userId] ?? UserEntity(),
|
||||
client: state.clientState.map[activity.clientId],
|
||||
invoice: state.invoiceState.map[activity.invoiceId],
|
||||
quote: state.quoteState.map[activity.invoiceId],
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class MenuDrawerVM {
|
|||
isLoading: state.isLoading,
|
||||
companies: companiesSelector(state),
|
||||
user: state.user,
|
||||
selectedCompany: state.selectedCompany,
|
||||
selectedCompany: state.company,
|
||||
selectedCompanyIndex: state.uiState.selectedCompanyIndex.toString(),
|
||||
onCompanyChanged:
|
||||
(BuildContext context, String companyIndex, CompanyEntity company) {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
|||
|
||||
void upgrade(BuildContext context, ProductDetails productDetails) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final company = store.state.selectedCompany;
|
||||
final company = store.state.company;
|
||||
|
||||
InAppPurchaseConnection.instance.buyNonConsumable(
|
||||
purchaseParam: PurchaseParam(
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class ClientScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.clientUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class ClientEditContactsVM {
|
|||
final client = state.clientUIState.editing;
|
||||
|
||||
return ClientEditContactsVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
client: client,
|
||||
contact: state.clientUIState.editingContact,
|
||||
onAddContactPressed: () {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class ClientEditVM {
|
|||
|
||||
return ClientEditVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
client: client,
|
||||
origClient: state.clientState.map[client.id],
|
||||
staticState: state.staticState,
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class ClientViewVM {
|
|||
isLoading: state.isLoading,
|
||||
isDirty: client.isNew,
|
||||
client: client,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onEditPressed: (BuildContext context) {
|
||||
final Completer<ClientEntity> completer = Completer<ClientEntity>();
|
||||
store.dispatch(
|
||||
|
|
@ -98,7 +98,7 @@ class ClientViewVM {
|
|||
if (longPress && client.isActive) {
|
||||
store.dispatch(EditInvoice(
|
||||
context: context,
|
||||
invoice: InvoiceEntity(company: state.selectedCompany)));
|
||||
invoice: InvoiceEntity(company: state.company)));
|
||||
store.dispatch(UpdateInvoiceClient(client: client));
|
||||
} else {
|
||||
store.dispatch(FilterInvoicesByEntity(
|
||||
|
|
@ -111,7 +111,7 @@ class ClientViewVM {
|
|||
store.dispatch(EditQuote(
|
||||
context: context,
|
||||
quote: InvoiceEntity(
|
||||
company: state.selectedCompany, isQuote: true)));
|
||||
company: state.company, isQuote: true)));
|
||||
store.dispatch(UpdateQuoteClient(client: client));
|
||||
} else {
|
||||
store.dispatch(FilterQuotesByEntity(
|
||||
|
|
@ -123,7 +123,7 @@ class ClientViewVM {
|
|||
if (longPress && client.isActive) {
|
||||
store.dispatch(EditPayment(
|
||||
context: context,
|
||||
payment: PaymentEntity(company: state.selectedCompany)
|
||||
payment: PaymentEntity(company: state.company)
|
||||
.rebuild((b) => b..clientId = client.id)));
|
||||
} else {
|
||||
store.dispatch(FilterPaymentsByEntity(
|
||||
|
|
@ -160,7 +160,7 @@ class ClientViewVM {
|
|||
store.dispatch(EditExpense(
|
||||
context: context,
|
||||
expense: ExpenseEntity(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
client: client,
|
||||
uiState: state.uiState)));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -675,7 +675,7 @@ class _FeesEditorState extends State<FeesEditor> {
|
|||
final localization = AppLocalization.of(context);
|
||||
final viewModel = widget.viewModel;
|
||||
final companyGateway = viewModel.companyGateway;
|
||||
final company = viewModel.state.selectedCompany;
|
||||
final company = viewModel.state.company;
|
||||
final settings =
|
||||
companyGateway.getSettingsForGatewayTypeId(widget.gatewayTypeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class CompanyGatewayEditVM {
|
|||
isSaving: state.isSaving,
|
||||
origCompanyGateway: state.companyGatewayState.map[companyGateway.id],
|
||||
companyGateway: companyGateway,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onChanged: (CompanyGatewayEntity companyGateway) {
|
||||
store.dispatch(UpdateCompanyGateway(companyGateway));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class CompanyGatewayViewVM {
|
|||
|
||||
return CompanyGatewayViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: companyGateway.isNew,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
Widget _header(BuildContext context) {
|
||||
final uiState = viewModel.dashboardUIState;
|
||||
final state = viewModel.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final clientMap = state.clientState.map;
|
||||
|
||||
// Add "All" if more than one currency
|
||||
|
|
@ -176,7 +176,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
title: title,
|
||||
currencyId: (settings.currencyId ?? '').isNotEmpty
|
||||
? settings.currencyId
|
||||
: state.selectedCompany.currencyId,
|
||||
: state.company.currencyId,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
final state = viewModel.state;
|
||||
final currentData = memoizedChartInvoices(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings,
|
||||
state.invoiceState.map,
|
||||
state.clientState.map);
|
||||
|
|
@ -195,7 +195,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
if (settings.enableComparison) {
|
||||
previousData = memoizedChartInvoices(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings.rebuild((b) => b..offset += 1),
|
||||
state.invoiceState.map,
|
||||
state.clientState.map);
|
||||
|
|
@ -215,7 +215,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
final state = viewModel.state;
|
||||
final currentData = memoizedChartPayments(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings,
|
||||
state.invoiceState.map,
|
||||
state.clientState.map,
|
||||
|
|
@ -225,7 +225,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
if (settings.enableComparison) {
|
||||
previousData = memoizedChartPayments(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings.rebuild((b) => b..offset += 1),
|
||||
state.invoiceState.map,
|
||||
state.clientState.map,
|
||||
|
|
@ -246,7 +246,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
final isLoaded = state.quoteState.isLoaded;
|
||||
final currentData = memoizedChartQuotes(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings,
|
||||
state.quoteState.map,
|
||||
state.clientState.map);
|
||||
|
|
@ -255,7 +255,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
if (settings.enableComparison) {
|
||||
previousData = memoizedChartQuotes(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings.rebuild((b) => b..offset += 1),
|
||||
state.quoteState.map,
|
||||
state.clientState.map);
|
||||
|
|
@ -276,7 +276,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
|
||||
final currentData = memoizedChartTasks(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings,
|
||||
state.taskState.map,
|
||||
state.invoiceState.map,
|
||||
|
|
@ -287,7 +287,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
if (settings.enableComparison) {
|
||||
previousData = memoizedChartTasks(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings.rebuild((b) => b..offset += 1),
|
||||
state.taskState.map,
|
||||
state.invoiceState.map,
|
||||
|
|
@ -309,7 +309,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
final isLoaded = state.expenseState.isLoaded;
|
||||
final currentData = memoizedChartExpenses(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings,
|
||||
state.invoiceState.map,
|
||||
state.expenseState.map);
|
||||
|
|
@ -318,7 +318,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
if (settings.enableComparison) {
|
||||
previousData = memoizedChartExpenses(
|
||||
state.staticState.currencyMap,
|
||||
state.selectedCompany,
|
||||
state.company,
|
||||
settings.rebuild((b) => b..offset += 1),
|
||||
state.invoiceState.map,
|
||||
state.expenseState.map);
|
||||
|
|
@ -335,7 +335,7 @@ class DashboardPanels extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = viewModel.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
|
||||
if (!state.staticState.isLoaded) {
|
||||
return LoadingIndicator();
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class DashboardVM {
|
|||
currencyMap: state.staticState.currencyMap,
|
||||
isLoading: state.isLoading,
|
||||
isNextEnabled:
|
||||
DateTime.parse(state.dashboardUIState.endDate(state.selectedCompany))
|
||||
DateTime.parse(state.dashboardUIState.endDate(state.company))
|
||||
.isBefore(DateTime.now()),
|
||||
onRefreshed: (context) => _handleRefresh(context),
|
||||
onSettingsChanged: (DashboardSettings settings) =>
|
||||
|
|
@ -81,7 +81,7 @@ class DashboardVM {
|
|||
store.dispatch(UpdateDashboardSettings(currencyId: currencyId)),
|
||||
filter: filter,
|
||||
filteredList:
|
||||
memoizedFilteredSelector(filter, state.selectedCompanyState),
|
||||
memoizedFilteredSelector(filter, state.userCompanyState),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class DocumentEditVM {
|
|||
isSaving: state.isSaving,
|
||||
origDocument: state.documentState.map[document.id],
|
||||
document: document,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onChanged: (DocumentEntity document) {
|
||||
store.dispatch(UpdateDocument(document));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class DocumentViewVM {
|
|||
|
||||
return DocumentViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: document.isNew,
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class ExpenseEditVM {
|
|||
isSaving: state.isSaving,
|
||||
origExpense: state.expenseState.map[expense.id],
|
||||
expense: expense,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onChanged: (ExpenseEntity expense) {
|
||||
store.dispatch(UpdateExpense(expense));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class ExpenseListItem extends StatelessWidget {
|
|||
? expense.matchesFilterValue(filter)
|
||||
: null;
|
||||
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final category = company.expenseCategoryMap[expense.categoryId];
|
||||
|
||||
String subtitle = '';
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ExpenseScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.expenseUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class _ExpenseViewState extends State<ExpenseView>
|
|||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
final viewModel = widget.viewModel;
|
||||
final company = viewModel.state.selectedCompany;
|
||||
final company = viewModel.state.company;
|
||||
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ExpenseViewVM {
|
|||
|
||||
return ExpenseViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: expense.isNew,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class GroupEditVM {
|
|||
isSaving: state.isSaving,
|
||||
origGroup: state.groupState.map[group.id],
|
||||
group: group,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onChanged: (GroupEntity group) {
|
||||
store.dispatch(UpdateGroup(group));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class GroupSettingsScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.groupUIState.listUIState;
|
||||
final isInMultiselect = listUIState.isInMultiselect();
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class GroupViewVM {
|
|||
|
||||
return GroupViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: group.isNew,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class InvoiceEditContactsVM extends EntityEditContactsVM {
|
|||
final invoice = state.invoiceUIState.editing;
|
||||
|
||||
return InvoiceEditContactsVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: invoice,
|
||||
client: state.clientState.map[invoice.clientId],
|
||||
onAddContact: (ContactEntity contact) {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class InvoiceEditDetailsVM extends EntityEditDetailsVM {
|
|||
final invoice = state.invoiceUIState.editing;
|
||||
|
||||
return InvoiceEditDetailsVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: invoice,
|
||||
onChanged: (InvoiceEntity invoice) =>
|
||||
store.dispatch(UpdateInvoice(invoice)),
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class InvoiceEditItemsVM extends EntityEditItemsVM {
|
|||
final invoice = state.invoiceUIState.editing;
|
||||
|
||||
return InvoiceEditItemsVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: invoice,
|
||||
invoiceItemIndex: state.invoiceUIState.editingItemIndex,
|
||||
onRemoveInvoiceItemPressed: (index) =>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class InvoiceEditNotesVM extends EntityEditNotesVM {
|
|||
final invoice = state.invoiceUIState.editing;
|
||||
|
||||
return InvoiceEditNotesVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: invoice,
|
||||
onChanged: (InvoiceEntity invoice) =>
|
||||
store.dispatch(UpdateInvoice(invoice)),
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class InvoiceEditVM extends EntityEditVM {
|
|||
|
||||
return InvoiceEditVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
invoice: invoice,
|
||||
invoiceItemIndex: state.invoiceUIState.editingItemIndex,
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
|||
void _onItemsSelected(BuildContext context) {
|
||||
final List<InvoiceItemEntity> items = [];
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
|
||||
_selected.forEach((entity) {
|
||||
if (entity.entityType == EntityType.product) {
|
||||
final product = entity as ProductEntity;
|
||||
if (state.selectedCompany.fillProducts ?? true) {
|
||||
if (state.company.fillProducts ?? true) {
|
||||
items.add(
|
||||
convertProductToInvoiceItem(product: product, context: context));
|
||||
} else {
|
||||
|
|
@ -119,7 +119,7 @@ class _InvoiceItemSelectorState extends State<InvoiceItemSelector>
|
|||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final showTabBar = company.isModuleEnabled(EntityType.task) ||
|
||||
company.isModuleEnabled(EntityType.expense);
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class EmailInvoiceVM extends EmailEntityVM {
|
|||
return EmailInvoiceVM(
|
||||
isLoading: state.isLoading,
|
||||
isSaving: state.isSaving,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: invoice,
|
||||
client: state.clientState.map[invoice.clientId] ??
|
||||
ClientEntity(id: invoice.clientId),
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class InvoiceScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = store.state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = store.state.uiState.invoiceUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class InvoiceViewVM extends EntityViewVM {
|
|||
|
||||
return InvoiceViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isDirty: invoice.isNew,
|
||||
invoice: invoice,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class PaymentScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.paymentUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class PaymentViewVM {
|
|||
|
||||
return PaymentViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isDirty: payment.isNew,
|
||||
isLoading: state.isLoading,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class ProductEditVM {
|
|||
|
||||
return ProductEditVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isDirty: product.isNew,
|
||||
product: product,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class ProductScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.productUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class ProductViewVM {
|
|||
isLoading: state.isLoading,
|
||||
isDirty: product.isNew,
|
||||
product: product,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onEditPressed: (BuildContext context) {
|
||||
final Completer<ProductEntity> completer = Completer<ProductEntity>();
|
||||
store.dispatch(EditProduct(
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class ProjectEditVM {
|
|||
return ProjectEditVM(
|
||||
isLoading: state.isLoading,
|
||||
isSaving: state.isSaving,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
project: project,
|
||||
state: state,
|
||||
origProject: state.projectState.map[project.id],
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class ProjectScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = store.state.selectedCompany;
|
||||
final company = store.state.company;
|
||||
final userCompany = store.state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.projectUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class ProjectViewVM {
|
|||
|
||||
return ProjectViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: project.isNew,
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class QuoteEditDetailsVM extends EntityEditDetailsVM {
|
|||
final quote = state.quoteUIState.editing;
|
||||
|
||||
return QuoteEditDetailsVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: quote,
|
||||
onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)),
|
||||
clientMap: state.clientState.map,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class QuoteEditItemsVM extends EntityEditItemsVM {
|
|||
final quote = state.quoteUIState.editing;
|
||||
|
||||
return QuoteEditItemsVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: quote,
|
||||
invoiceItemIndex: state.quoteUIState.editingItemIndex,
|
||||
onRemoveInvoiceItemPressed: (index) =>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class QuoteEditNotesVM extends EntityEditNotesVM {
|
|||
final quote = state.quoteUIState.editing;
|
||||
|
||||
return QuoteEditNotesVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: quote,
|
||||
onChanged: (InvoiceEntity quote) => store.dispatch(UpdateQuote(quote)),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class QuoteEditVM extends EntityEditVM {
|
|||
final quote = state.quoteUIState.editing;
|
||||
|
||||
return QuoteEditVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
invoice: quote,
|
||||
invoiceItemIndex: state.quoteUIState.editingItemIndex,
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class EmailQuoteVM extends EmailEntityVM {
|
|||
return EmailQuoteVM(
|
||||
isLoading: state.isLoading,
|
||||
isSaving: state.isSaving,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
invoice: quote,
|
||||
client: state.clientState.map[quote.clientId],
|
||||
onSendPressed: (context, template, subject, body) =>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class QuoteScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = store.state.selectedCompany;
|
||||
final company = store.state.company;
|
||||
final userCompany = store.state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.quoteUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class QuoteViewVM extends EntityViewVM {
|
|||
|
||||
return QuoteViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isDirty: quote.isNew,
|
||||
invoice: quote,
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ class _DeviceSettingsState extends State<DeviceSettings> {
|
|||
}
|
||||
},
|
||||
),
|
||||
viewModel.state.selectedCompany
|
||||
viewModel.state.company
|
||||
.isModuleEnabled(EntityType.task)
|
||||
? SwitchListTile(
|
||||
title:
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class TaskEditDetailsVM {
|
|||
task: task,
|
||||
taskTime: state.taskUIState.editingTime,
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onChanged: (TaskEntity task) {
|
||||
store.dispatch(UpdateTask(task));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class TaskEditTimesVM {
|
|||
final task = state.taskUIState.editing;
|
||||
|
||||
return TaskEditTimesVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
task: task,
|
||||
taskTime: state.taskUIState.editingTime,
|
||||
onRemoveTaskTimePressed: (index) => store.dispatch(DeleteTaskTime(index)),
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class TaskEditVM {
|
|||
task: task,
|
||||
taskTime: state.taskUIState.editingTime,
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onBackPressed: () {
|
||||
if (state.uiState.currentRoute.contains(TaskScreen.route)) {
|
||||
store.dispatch(UpdateCurrentRoute(TaskScreen.route));
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class TaskListItem extends StatelessWidget {
|
|||
final uiState = state.uiState;
|
||||
final taskUIState = uiState.taskUIState;
|
||||
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
final taskStatus = company.taskStatusMap[task.taskStatusId];
|
||||
|
||||
final localization = AppLocalization.of(context);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class TaskScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = store.state.selectedCompany;
|
||||
final company = store.state.company;
|
||||
final userCompany = store.state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.taskUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class TaskViewVM {
|
|||
|
||||
return TaskViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: task.isNew,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class TaxRateEditVM {
|
|||
isSaving: state.isSaving,
|
||||
origTaxRate: state.taxRateState.map[taxRate.id],
|
||||
taxRate: taxRate,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onChanged: (TaxRateEntity taxRate) {
|
||||
store.dispatch(UpdateTaxRate(taxRate));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class TaxRateViewVM {
|
|||
|
||||
return TaxRateViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: taxRate.isNew,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class UserEditVM {
|
|||
origUser: state.userState.map[user.id],
|
||||
user: user,
|
||||
userCompany: state.userCompany,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onUserChanged: (UserEntity user) {
|
||||
store.dispatch(UpdateUser(user));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class UserView extends StatelessWidget {
|
|||
final localization = AppLocalization.of(context);
|
||||
final user = viewModel.user;
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = state.userCompany;
|
||||
|
||||
return Scaffold(
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class UserViewVM {
|
|||
|
||||
return UserViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: user.isNew,
|
||||
|
|
@ -98,7 +98,7 @@ class UserViewVM {
|
|||
if (longPress && user.isActive) {
|
||||
store.dispatch(EditInvoice(
|
||||
context: context,
|
||||
invoice: InvoiceEntity(company: state.selectedCompany)));
|
||||
invoice: InvoiceEntity(company: state.company)));
|
||||
} else {
|
||||
store.dispatch(FilterInvoicesByEntity(
|
||||
entityId: user.id, entityType: EntityType.user));
|
||||
|
|
@ -110,7 +110,7 @@ class UserViewVM {
|
|||
store.dispatch(EditQuote(
|
||||
context: context,
|
||||
quote: InvoiceEntity(
|
||||
company: state.selectedCompany, isQuote: true)));
|
||||
company: state.company, isQuote: true)));
|
||||
} else {
|
||||
store.dispatch(FilterQuotesByEntity(
|
||||
entityId: user.id, entityType: EntityType.user));
|
||||
|
|
@ -121,7 +121,7 @@ class UserViewVM {
|
|||
if (longPress && user.isActive) {
|
||||
store.dispatch(EditPayment(
|
||||
context: context,
|
||||
payment: PaymentEntity(company: state.selectedCompany)));
|
||||
payment: PaymentEntity(company: state.company)));
|
||||
} else {
|
||||
store.dispatch(FilterPaymentsByEntity(
|
||||
entityId: user.id, entityType: EntityType.user));
|
||||
|
|
@ -154,7 +154,7 @@ class UserViewVM {
|
|||
store.dispatch(EditExpense(
|
||||
context: context,
|
||||
expense: ExpenseEntity(
|
||||
company: state.selectedCompany, uiState: state.uiState)));
|
||||
company: state.company, uiState: state.uiState)));
|
||||
} else {
|
||||
store.dispatch(FilterExpensesByEntity(
|
||||
entityId: user.id, entityType: EntityType.user));
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class VendorEditContactsVM {
|
|||
final vendor = state.vendorUIState.editing;
|
||||
|
||||
return VendorEditContactsVM(
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
vendor: vendor,
|
||||
contact: state.vendorUIState.editingContact,
|
||||
onAddContactPressed: () {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class VendorEditVM {
|
|||
isSaving: state.isSaving,
|
||||
origVendor: state.vendorState.map[vendor.id],
|
||||
vendor: vendor,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
onChanged: (VendorEntity vendor) {
|
||||
store.dispatch(UpdateVendor(vendor));
|
||||
},
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class VendorScreen extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final userCompany = store.state.userCompany;
|
||||
final localization = AppLocalization.of(context);
|
||||
final listUIState = state.uiState.vendorUIState.listUIState;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class VendorViewVM {
|
|||
|
||||
factory VendorViewVM.fromStore(Store<AppState> store) {
|
||||
final state = store.state;
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final vendor = state.vendorState.map[state.vendorUIState.selectedId] ??
|
||||
VendorEntity(id: state.vendorUIState.selectedId);
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ class VendorViewVM {
|
|||
|
||||
return VendorViewVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
company: state.company,
|
||||
isSaving: state.isSaving,
|
||||
isLoading: state.isLoading,
|
||||
isDirty: vendor.isNew,
|
||||
|
|
@ -96,7 +96,7 @@ class VendorViewVM {
|
|||
store.dispatch(EditExpense(
|
||||
context: context,
|
||||
expense: ExpenseEntity(
|
||||
company: state.selectedCompany, vendor: vendor)));
|
||||
company: state.company, vendor: vendor)));
|
||||
} else {
|
||||
store.dispatch(FilterExpensesByEntity(
|
||||
entityId: vendor.id, entityType: EntityType.vendor));
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ String formatNumber(
|
|||
}
|
||||
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
final ClientEntity client =
|
||||
state.selectedCompanyState.clientState.map[clientId];
|
||||
state.userCompanyState.clientState.map[clientId];
|
||||
|
||||
String countryId;
|
||||
|
||||
|
|
@ -239,7 +239,7 @@ String formatDate(String value, BuildContext context,
|
|||
}
|
||||
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final CompanyEntity company = state.selectedCompany;
|
||||
final CompanyEntity company = state.company;
|
||||
|
||||
if (state.staticState.dateFormatMap.isEmpty) {
|
||||
return '';
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ bool isHosted(BuildContext context) =>
|
|||
StoreProvider.of<AppState>(context).state.isHosted;
|
||||
|
||||
bool isPaidAccount(BuildContext context) {
|
||||
final company = StoreProvider.of<AppState>(context).state.selectedCompany;
|
||||
final company = StoreProvider.of<AppState>(context).state.company;
|
||||
|
||||
return isSelfHosted(context) || company.isProPlan || company.isEnterprisePlan;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ String processTemplate(
|
|||
|
||||
final state = StoreProvider.of<AppState>(context).state;
|
||||
final localization = AppLocalization.of(context);
|
||||
final company = state.selectedCompany;
|
||||
final company = state.company;
|
||||
final client = state.clientState.map[invoice.clientId] ??
|
||||
ClientEntity(id: invoice.clientId);
|
||||
final contact = client.contacts.first;
|
||||
|
|
|
|||
Loading…
Reference in New Issue