Settings
This commit is contained in:
parent
f8b695985f
commit
dc338f031c
|
|
@ -338,7 +338,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
|||
@override
|
||||
String toString() {
|
||||
//return 'showCurrencyCode: ${staticState.gatewayMap}';
|
||||
return 'gateway config: ${companyGatewayUIState.editing}';
|
||||
return 'defaultInvoiceDesignId: ${selectedCompany.settings.defaultInvoiceDesignId}';
|
||||
//return 'Routes: Current: ${uiState.currentRoute} Prev: ${uiState.previousRoute}';
|
||||
//return 'Route: ${uiState.currentRoute}, Setting Type: ${uiState.settingsUIState.entityType}, Name: ${uiState.settingsUIState.settings.name}, Updated: ${uiState.settingsUIState.updatedAt}';
|
||||
//return 'Route: ${uiState.currentRoute}, Previous: ${uiState.previousRoute}, Layout: ${uiState.layout}, Menu: ${uiState.isMenuVisible}, History: ${uiState.isHistoryVisible}';
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ import 'package:flutter/widgets.dart';
|
|||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/group/group_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||
import 'package:invoiceninja_flutter/ui/settings/client_portal.dart';
|
||||
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||
|
|
@ -31,8 +34,10 @@ class ClientPortalScreen extends StatelessWidget {
|
|||
class ClientPortalVM {
|
||||
ClientPortalVM({
|
||||
@required this.state,
|
||||
@required this.settings,
|
||||
@required this.company,
|
||||
@required this.onChanged,
|
||||
@required this.onCompanyChanged,
|
||||
@required this.onSettingsChanged,
|
||||
@required this.onSavePressed,
|
||||
@required this.onCancelPressed,
|
||||
});
|
||||
|
|
@ -41,24 +46,42 @@ class ClientPortalVM {
|
|||
final state = store.state;
|
||||
|
||||
return ClientPortalVM(
|
||||
state: state,
|
||||
company: state.selectedCompany,
|
||||
onChanged: (company) {
|
||||
store.dispatch(UpdateCompany(company: state.selectedCompany));
|
||||
},
|
||||
onCancelPressed: (context) {},
|
||||
onSavePressed: (context) {
|
||||
final completer = snackBarCompleter(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
store.dispatch(SaveCompanyRequest(
|
||||
completer: completer,
|
||||
company: state.uiState.settingsUIState.userCompany.company));
|
||||
});
|
||||
state: state,
|
||||
settings: state.uiState.settingsUIState.settings,
|
||||
company: state.uiState.settingsUIState.userCompany.company,
|
||||
onSettingsChanged: (settings) =>
|
||||
store.dispatch(UpdateSettings(settings: settings)),
|
||||
onCompanyChanged: (company) =>
|
||||
store.dispatch(UpdateCompany(company: company)),
|
||||
onCancelPressed: (context) => store.dispatch(ResetSettings()),
|
||||
onSavePressed: (context) {
|
||||
final settingsUIState = state.uiState.settingsUIState;
|
||||
final completer = snackBarCompleter(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
switch (settingsUIState.entityType) {
|
||||
case EntityType.company:
|
||||
store.dispatch(SaveCompanyRequest(
|
||||
completer: completer,
|
||||
company: settingsUIState.userCompany.company));
|
||||
break;
|
||||
case EntityType.group:
|
||||
store.dispatch(SaveGroupRequest(
|
||||
completer: completer, group: settingsUIState.group));
|
||||
break;
|
||||
case EntityType.client:
|
||||
store.dispatch(SaveClientRequest(
|
||||
completer: completer, client: settingsUIState.client));
|
||||
break;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
final AppState state;
|
||||
final CompanyEntity company;
|
||||
final Function(CompanyEntity) onChanged;
|
||||
final SettingsEntity settings;
|
||||
final Function(BuildContext) onSavePressed;
|
||||
final Function(BuildContext) onCancelPressed;
|
||||
final Function(CompanyEntity) onCompanyChanged;
|
||||
final Function(SettingsEntity) onSettingsChanged;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,6 @@ class _EmailSettingsState extends State<EmailSettings>
|
|||
final localization = AppLocalization.of(context);
|
||||
final viewModel = widget.viewModel;
|
||||
final state = viewModel.state;
|
||||
final settings = viewModel.settings;
|
||||
|
||||
return SettingsScaffold(
|
||||
title: localization.emailSettings,
|
||||
|
|
|
|||
|
|
@ -131,12 +131,13 @@ class SettingsList extends StatelessWidget {
|
|||
viewModel: viewModel,
|
||||
icon: FontAwesomeIcons.paintBrush,
|
||||
),
|
||||
if (showAll)
|
||||
SettingsListTile(
|
||||
section: kSettingsClientPortal,
|
||||
viewModel: viewModel,
|
||||
icon: FontAwesomeIcons.cloud,
|
||||
),
|
||||
*/
|
||||
SettingsListTile(
|
||||
section: kSettingsClientPortal,
|
||||
viewModel: viewModel,
|
||||
icon: FontAwesomeIcons.cloud,
|
||||
),
|
||||
/*
|
||||
if (showAll)
|
||||
SettingsListTile(
|
||||
section: kSettingsBuyNowButtons,
|
||||
|
|
@ -185,7 +186,7 @@ class SettingsListTile extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
final company = viewModel.state.selectedCompany;
|
||||
final state = viewModel.state;
|
||||
|
||||
return SelectedIndicator(
|
||||
isSelected: viewModel.state.uiState.containsRoute('/$section'),
|
||||
|
|
@ -197,14 +198,13 @@ class SettingsListTile extends StatelessWidget {
|
|||
title: Text(localization.lookup(section)),
|
||||
onTap: () {
|
||||
if (section == kSettingsOnlinePayments &&
|
||||
(company.companyGateways == null ||
|
||||
company.companyGateways.isEmpty)) {
|
||||
state.companyGatewayState.list.isEmpty) {
|
||||
viewModel.loadSection(context, kSettingsOnlinePaymentsEdit);
|
||||
} else if (section == kSettingsTaxRates &&
|
||||
(company.taxRates == null || company.taxRates.isEmpty)) {
|
||||
state.taxRateState.list.isEmpty) {
|
||||
viewModel.loadSection(context, kSettingsTaxRatesEdit);
|
||||
} else if (section == kSettingsGroupSettings &&
|
||||
(company.groups == null || company.groups.isEmpty)) {
|
||||
state.groupState.list.isEmpty) {
|
||||
viewModel.loadSection(context, kSettingsGroupSettingsEdit);
|
||||
} else {
|
||||
viewModel.loadSection(context, section);
|
||||
|
|
|
|||
Loading…
Reference in New Issue