This commit is contained in:
Hillel Coren 2019-10-17 15:35:48 +03:00
parent 22f41f3d84
commit 263c053c86
7 changed files with 141 additions and 23 deletions

View File

@ -57,6 +57,7 @@ abstract class CompanyGatewayEntity extends Object
updateDetails: true, updateDetails: true,
customValue1: '', customValue1: '',
customValue2: '', customValue2: '',
config: '',
); );
} }
@ -82,12 +83,16 @@ abstract class CompanyGatewayEntity extends Object
@BuiltValueField(wireName: 'update_details') @BuiltValueField(wireName: 'update_details')
bool get updateDetails; bool get updateDetails;
@nullable
@BuiltValueField(wireName: 'custom_value1') @BuiltValueField(wireName: 'custom_value1')
String get customValue1; String get customValue1;
@nullable
@BuiltValueField(wireName: 'custom_value2') @BuiltValueField(wireName: 'custom_value2')
String get customValue2; String get customValue2;
String get config;
@override @override
String get listDisplayName { String get listDisplayName {
return gateway.name; return gateway.name;

View File

@ -136,11 +136,8 @@ class _$CompanyGatewayEntitySerializer
'update_details', 'update_details',
serializers.serialize(object.updateDetails, serializers.serialize(object.updateDetails,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'custom_value1', 'config',
serializers.serialize(object.customValue1, serializers.serialize(object.config,
specifiedType: const FullType(String)),
'custom_value2',
serializers.serialize(object.customValue2,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
]; ];
if (object.gatewayId != null) { if (object.gatewayId != null) {
@ -149,6 +146,18 @@ class _$CompanyGatewayEntitySerializer
..add(serializers.serialize(object.gatewayId, ..add(serializers.serialize(object.gatewayId,
specifiedType: const FullType(String))); specifiedType: const FullType(String)));
} }
if (object.customValue1 != null) {
result
..add('custom_value1')
..add(serializers.serialize(object.customValue1,
specifiedType: const FullType(String)));
}
if (object.customValue2 != null) {
result
..add('custom_value2')
..add(serializers.serialize(object.customValue2,
specifiedType: const FullType(String)));
}
if (object.isChanged != null) { if (object.isChanged != null) {
result result
..add('isChanged') ..add('isChanged')
@ -234,6 +243,10 @@ class _$CompanyGatewayEntitySerializer
result.customValue2 = serializers.deserialize(value, result.customValue2 = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
break; break;
case 'config':
result.config = serializers.deserialize(value,
specifiedType: const FullType(String)) as String;
break;
case 'isChanged': case 'isChanged':
result.isChanged = serializers.deserialize(value, result.isChanged = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
@ -477,6 +490,8 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
@override @override
final String customValue2; final String customValue2;
@override @override
final String config;
@override
final bool isChanged; final bool isChanged;
@override @override
final int createdAt; final int createdAt;
@ -503,6 +518,7 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
this.updateDetails, this.updateDetails,
this.customValue1, this.customValue1,
this.customValue2, this.customValue2,
this.config,
this.isChanged, this.isChanged,
this.createdAt, this.createdAt,
this.updatedAt, this.updatedAt,
@ -526,13 +542,8 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
throw new BuiltValueNullFieldError( throw new BuiltValueNullFieldError(
'CompanyGatewayEntity', 'updateDetails'); 'CompanyGatewayEntity', 'updateDetails');
} }
if (customValue1 == null) { if (config == null) {
throw new BuiltValueNullFieldError( throw new BuiltValueNullFieldError('CompanyGatewayEntity', 'config');
'CompanyGatewayEntity', 'customValue1');
}
if (customValue2 == null) {
throw new BuiltValueNullFieldError(
'CompanyGatewayEntity', 'customValue2');
} }
} }
@ -556,6 +567,7 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
updateDetails == other.updateDetails && updateDetails == other.updateDetails &&
customValue1 == other.customValue1 && customValue1 == other.customValue1 &&
customValue2 == other.customValue2 && customValue2 == other.customValue2 &&
config == other.config &&
isChanged == other.isChanged && isChanged == other.isChanged &&
createdAt == other.createdAt && createdAt == other.createdAt &&
updatedAt == other.updatedAt && updatedAt == other.updatedAt &&
@ -580,15 +592,20 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc(0, $jc(
gateway.hashCode), $jc(
gatewayId.hashCode), 0,
showBillingAddress gateway
.hashCode),
gatewayId.hashCode),
showBillingAddress
.hashCode),
showShippingAddress
.hashCode), .hashCode),
showShippingAddress.hashCode), updateDetails.hashCode),
updateDetails.hashCode), customValue1.hashCode),
customValue1.hashCode), customValue2.hashCode),
customValue2.hashCode), config.hashCode),
isChanged.hashCode), isChanged.hashCode),
createdAt.hashCode), createdAt.hashCode),
updatedAt.hashCode), updatedAt.hashCode),
@ -608,6 +625,7 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity {
..add('updateDetails', updateDetails) ..add('updateDetails', updateDetails)
..add('customValue1', customValue1) ..add('customValue1', customValue1)
..add('customValue2', customValue2) ..add('customValue2', customValue2)
..add('config', config)
..add('isChanged', isChanged) ..add('isChanged', isChanged)
..add('createdAt', createdAt) ..add('createdAt', createdAt)
..add('updatedAt', updatedAt) ..add('updatedAt', updatedAt)
@ -655,6 +673,10 @@ class CompanyGatewayEntityBuilder
String get customValue2 => _$this._customValue2; String get customValue2 => _$this._customValue2;
set customValue2(String customValue2) => _$this._customValue2 = customValue2; set customValue2(String customValue2) => _$this._customValue2 = customValue2;
String _config;
String get config => _$this._config;
set config(String config) => _$this._config = config;
bool _isChanged; bool _isChanged;
bool get isChanged => _$this._isChanged; bool get isChanged => _$this._isChanged;
set isChanged(bool isChanged) => _$this._isChanged = isChanged; set isChanged(bool isChanged) => _$this._isChanged = isChanged;
@ -694,6 +716,7 @@ class CompanyGatewayEntityBuilder
_updateDetails = _$v.updateDetails; _updateDetails = _$v.updateDetails;
_customValue1 = _$v.customValue1; _customValue1 = _$v.customValue1;
_customValue2 = _$v.customValue2; _customValue2 = _$v.customValue2;
_config = _$v.config;
_isChanged = _$v.isChanged; _isChanged = _$v.isChanged;
_createdAt = _$v.createdAt; _createdAt = _$v.createdAt;
_updatedAt = _$v.updatedAt; _updatedAt = _$v.updatedAt;
@ -732,6 +755,7 @@ class CompanyGatewayEntityBuilder
updateDetails: updateDetails, updateDetails: updateDetails,
customValue1: customValue1, customValue1: customValue1,
customValue2: customValue2, customValue2: customValue2,
config: config,
isChanged: isChanged, isChanged: isChanged,
createdAt: createdAt, createdAt: createdAt,
updatedAt: updatedAt, updatedAt: updatedAt,

View File

@ -32,6 +32,7 @@ import 'package:invoiceninja_flutter/ui/app/screen_imports.dart';
import 'package:invoiceninja_flutter/ui/client/edit/client_edit_vm.dart'; import 'package:invoiceninja_flutter/ui/client/edit/client_edit_vm.dart';
import 'package:invoiceninja_flutter/ui/group/edit/group_edit_vm.dart'; import 'package:invoiceninja_flutter/ui/group/edit/group_edit_vm.dart';
import 'package:invoiceninja_flutter/ui/product/edit/product_edit_vm.dart'; import 'package:invoiceninja_flutter/ui/product/edit/product_edit_vm.dart';
// STARTER: import - do not remove comment // STARTER: import - do not remove comment
import 'package:invoiceninja_flutter/redux/tax_rate/tax_rate_state.dart'; import 'package:invoiceninja_flutter/redux/tax_rate/tax_rate_state.dart';
@ -199,13 +200,17 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
// STARTER: state getters - do not remove comment // STARTER: state getters - do not remove comment
TaxRateState get taxRateState => selectedCompanyState.taxRateState; TaxRateState get taxRateState => selectedCompanyState.taxRateState;
ListUIState get taxRateListState => uiState.taxRateUIState.listUIState; ListUIState get taxRateListState => uiState.taxRateUIState.listUIState;
TaxRateUIState get taxRateUIState => uiState.taxRateUIState; TaxRateUIState get taxRateUIState => uiState.taxRateUIState;
CompanyGatewayState get companyGatewayState => CompanyGatewayState get companyGatewayState =>
selectedCompanyState.companyGatewayState; selectedCompanyState.companyGatewayState;
ListUIState get companyGatewayListState => ListUIState get companyGatewayListState =>
uiState.companyGatewayUIState.listUIState; uiState.companyGatewayUIState.listUIState;
CompanyGatewayUIState get companyGatewayUIState => CompanyGatewayUIState get companyGatewayUIState =>
uiState.companyGatewayUIState; uiState.companyGatewayUIState;
@ -324,9 +329,9 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
@override @override
String toString() { String toString() {
//return 'showCurrencyCode: ${uiState.settingsUIState.settings.showCurrencyCode}'; //return 'showCurrencyCode: ${uiState.settingsUIState.settings.showCurrencyCode}';
//return 'gateways : ${staticState.gatewayMap}'; return 'gateways : ${selectedCompany.companyGateways}';
//return 'URL: ${userCompany.token.token}'; //return 'URL: ${userCompany.token.token}';
return 'Route: ${uiState.currentRoute}, Setting Type: ${uiState.settingsUIState.entityType}, Name: ${uiState.settingsUIState.settings.name}, Updated: ${uiState.settingsUIState.updatedAt}'; //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}'; //return 'Route: ${uiState.currentRoute}, Previous: ${uiState.previousRoute}, Layout: ${uiState.layout}, Menu: ${uiState.isMenuVisible}, History: ${uiState.isHistoryVisible}';
} }
} }

View File

@ -1,4 +1,5 @@
import 'package:invoiceninja_flutter/data/models/company_gateway_model.dart'; import 'package:invoiceninja_flutter/data/models/company_gateway_model.dart';
import 'package:invoiceninja_flutter/redux/group/group_state.dart';
import 'package:redux/redux.dart'; import 'package:redux/redux.dart';
import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
import 'package:invoiceninja_flutter/redux/company/company_actions.dart'; import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
@ -130,6 +131,8 @@ final companyGatewaysReducer = combineReducers<CompanyGatewayState>([
_setLoadedCompanyGateways), _setLoadedCompanyGateways),
TypedReducer<CompanyGatewayState, LoadCompanyGatewaySuccess>( TypedReducer<CompanyGatewayState, LoadCompanyGatewaySuccess>(
_setLoadedCompanyGateway), _setLoadedCompanyGateway),
TypedReducer<CompanyGatewayState, LoadCompanySuccess>(
_setLoadedCompany),
TypedReducer<CompanyGatewayState, ArchiveCompanyGatewayRequest>( TypedReducer<CompanyGatewayState, ArchiveCompanyGatewayRequest>(
_archiveCompanyGatewayRequest), _archiveCompanyGatewayRequest),
TypedReducer<CompanyGatewayState, ArchiveCompanyGatewaySuccess>( TypedReducer<CompanyGatewayState, ArchiveCompanyGatewaySuccess>(
@ -244,6 +247,18 @@ CompanyGatewayState _setLoadedCompanyGateway(
.rebuild((b) => b..map[action.companyGateway.id] = action.companyGateway); .rebuild((b) => b..map[action.companyGateway.id] = action.companyGateway);
} }
CompanyGatewayState _setLoadedCompany(CompanyGatewayState companyGatewayState, LoadCompanySuccess action) {
final state = companyGatewayState.rebuild((b) => b
..lastUpdated = DateTime.now().millisecondsSinceEpoch
..map.addAll(Map.fromIterable(
action.userCompany.company.companyGateways,
key: (dynamic item) => item.id,
value: (dynamic item) => item,
)));
return state.rebuild((b) => b..list.replace(state.map.keys));
}
CompanyGatewayState _setLoadedCompanyGateways( CompanyGatewayState _setLoadedCompanyGateways(
CompanyGatewayState companyGatewayState, CompanyGatewayState companyGatewayState,
LoadCompanyGatewaysSuccess action) { LoadCompanyGatewaysSuccess action) {

View File

@ -34,6 +34,7 @@ class CompanyGatewayListBuilder extends StatelessWidget {
class CompanyGatewayListVM { class CompanyGatewayListVM {
CompanyGatewayListVM({ CompanyGatewayListVM({
@required this.state,
@required this.userCompany, @required this.userCompany,
@required this.companyGatewayList, @required this.companyGatewayList,
@required this.companyGatewayMap, @required this.companyGatewayMap,
@ -89,6 +90,7 @@ class CompanyGatewayListVM {
); );
} }
final AppState state;
final UserCompanyEntity userCompany; final UserCompanyEntity userCompany;
final List<String> companyGatewayList; final List<String> companyGatewayList;
final BuiltMap<String, CompanyGatewayEntity> companyGatewayMap; final BuiltMap<String, CompanyGatewayEntity> companyGatewayMap;

View File

@ -35,7 +35,7 @@ class _CompanyGatewayEditState extends State<CompanyGatewayEdit>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_controller = TabController(vsync: this, length: 3); _controller = TabController(vsync: this, length: 4);
} }
@override @override
@ -88,6 +88,9 @@ class _CompanyGatewayEditState extends State<CompanyGatewayEdit>
key: ValueKey(state.settingsUIState.updatedAt), key: ValueKey(state.settingsUIState.updatedAt),
controller: _controller, controller: _controller,
tabs: [ tabs: [
Tab(
text: localization.credentials,
),
Tab( Tab(
text: localization.settings, text: localization.settings,
), ),
@ -132,6 +135,48 @@ class _CompanyGatewayEditState extends State<CompanyGatewayEdit>
), ),
], ],
), ),
ListView(
children: <Widget>[
FormCard(
children: <Widget>[
SwitchListTile(
activeColor: Theme.of(context).accentColor,
title: Text(localization.billingAddress),
subtitle: Text(localization.requireBillingAddressHelp),
value: companyGateway.showBillingAddress,
onChanged: (value) => viewModel.onChanged(companyGateway
.rebuild((b) => b..showBillingAddress = value)),
),
SwitchListTile(
activeColor: Theme.of(context).accentColor,
title: Text(localization.shippingAddress),
subtitle: Text(localization.requireShippingAddressHelp),
value: companyGateway.showShippingAddress,
onChanged: (value) => viewModel.onChanged(companyGateway
.rebuild((b) => b..showShippingAddress = value)),
),
SwitchListTile(
activeColor: Theme.of(context).accentColor,
title: Text(localization.updateAddress),
subtitle: Text(localization.updateAddressHelp),
value: companyGateway.updateDetails,
onChanged: (value) => viewModel.onChanged(companyGateway
.rebuild((b) => b..updateDetails = value)),
),
],
),
FormCard(
children: <Widget>[
SwitchListTile(
activeColor: Theme.of(context).accentColor,
//title: Text(),
value: false,
//onChanged: (value) => viewModel.onChanged(companyGateway.rebuild((b) => b..)),
)
],
)
],
),
ListView( ListView(
children: <Widget>[], children: <Widget>[],
), ),

View File

@ -14,6 +14,13 @@ abstract class LocaleCodeAware {
mixin LocalizationsProvider on LocaleCodeAware { mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = { static final Map<String, Map<String, String>> _localizedValues = {
'en': { 'en': {
'credentials': 'Credentials',
'require_billing_address_help':
'Require client to provide their billing address',
'require_shipping_address_help':
'Require client to provide their shipping address',
'update_address': 'Update address',
'update_address_help': 'Update client\'s address with provided details',
'rate': 'Rate', 'rate': 'Rate',
'tax_rate': 'Tax Rate', 'tax_rate': 'Tax Rate',
'new_tax_rate': 'New Tax Rate', 'new_tax_rate': 'New Tax Rate',
@ -14942,6 +14949,21 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get rate => _localizedValues[localeCode]['rate']; String get rate => _localizedValues[localeCode]['rate'];
String get requireBillingAddressHelp =>
_localizedValues[localeCode]['require_billing_address_help'];
String get requireShippingAddressHelp =>
_localizedValues[localeCode]['require_shipping_address_help'];
String get updateAddress => _localizedValues[localeCode]['update_address'];
String get updateAddressHelp =>
_localizedValues[localeCode]['update_address_help'];
String get credentials =>
_localizedValues[localeCode]['credentials'];
String lookup(String key) { String lookup(String key) {
final lookupKey = toSnakeCase(key); final lookupKey = toSnakeCase(key);
return _localizedValues[localeCode][lookupKey] ?? return _localizedValues[localeCode][lookupKey] ??