From 04d55dabc31b3d9079cae947bc6206e8ac8b44c2 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 23 Aug 2020 17:53:43 +0300 Subject: [PATCH] Company gateway settings --- lib/data/models/company_gateway_model.dart | 11 +++ lib/data/models/company_gateway_model.g.dart | 76 +++++++++++++------ lib/redux/app/app_state.dart | 2 +- .../edit/company_gateway_edit.dart | 27 ++++++- lib/utils/i18n.dart | 3 + lib/utils/web.dart | 2 + pubspec.lock | 35 +++++---- 7 files changed, 118 insertions(+), 38 deletions(-) diff --git a/lib/data/models/company_gateway_model.dart b/lib/data/models/company_gateway_model.dart index 8254b4e54..fade93aca 100644 --- a/lib/data/models/company_gateway_model.dart +++ b/lib/data/models/company_gateway_model.dart @@ -86,6 +86,11 @@ abstract class CompanyGatewayEntity extends Object CompanyGatewayEntity._(); + static const AUTO_BILL_ALWAYS = 'always'; + static const AUTO_BILL_OPT_IN = 'optin'; + static const AUTO_BILL_OPT_OUT = 'optout'; + static const AUTO_BILL_DISABLED = 'disabled'; + @override @memoized int get hashCode; @@ -129,6 +134,12 @@ abstract class CompanyGatewayEntity extends Object String get config; + @nullable + String get autobill; + + @nullable + String get label; + Map get parsedConfig => config.isEmpty ? {} : jsonDecode(config); diff --git a/lib/data/models/company_gateway_model.g.dart b/lib/data/models/company_gateway_model.g.dart index 98d5b01e3..e3f4ba134 100644 --- a/lib/data/models/company_gateway_model.g.dart +++ b/lib/data/models/company_gateway_model.g.dart @@ -177,6 +177,18 @@ class _$CompanyGatewayEntitySerializer 'id', serializers.serialize(object.id, specifiedType: const FullType(String)), ]; + if (object.autobill != null) { + result + ..add('autobill') + ..add(serializers.serialize(object.autobill, + specifiedType: const FullType(String))); + } + if (object.label != null) { + result + ..add('label') + ..add(serializers.serialize(object.label, + specifiedType: const FullType(String))); + } if (object.isChanged != null) { result ..add('isChanged') @@ -267,6 +279,14 @@ class _$CompanyGatewayEntitySerializer result.config = serializers.deserialize(value, specifiedType: const FullType(String)) as String; break; + case 'autobill': + result.autobill = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; + case 'label': + result.label = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; case 'isChanged': result.isChanged = serializers.deserialize(value, specifiedType: const FullType(bool)) as bool; @@ -649,6 +669,10 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity { @override final String config; @override + final String autobill; + @override + final String label; + @override final bool isChanged; @override final int createdAt; @@ -682,6 +706,8 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity { this.customValue3, this.customValue4, this.config, + this.autobill, + this.label, this.isChanged, this.createdAt, this.updatedAt, @@ -775,6 +801,8 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity { customValue3 == other.customValue3 && customValue4 == other.customValue4 && config == other.config && + autobill == other.autobill && + label == other.label && isChanged == other.isChanged && createdAt == other.createdAt && updatedAt == other.updatedAt && @@ -806,28 +834,18 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity { $jc( $jc( $jc( - $jc( - $jc( - 0, - gateway - .hashCode), - gatewayId - .hashCode), - acceptedCreditCards - .hashCode), - showBillingAddress - .hashCode), - showShippingAddress - .hashCode), - updateDetails - .hashCode), - feesAndLimitsMap - .hashCode), - customValue1.hashCode), - customValue2.hashCode), - customValue3.hashCode), - customValue4.hashCode), - config.hashCode), + $jc($jc($jc($jc(0, gateway.hashCode), gatewayId.hashCode), acceptedCreditCards.hashCode), + showBillingAddress.hashCode), + showShippingAddress.hashCode), + updateDetails.hashCode), + feesAndLimitsMap.hashCode), + customValue1.hashCode), + customValue2.hashCode), + customValue3.hashCode), + customValue4.hashCode), + config.hashCode), + autobill.hashCode), + label.hashCode), isChanged.hashCode), createdAt.hashCode), updatedAt.hashCode), @@ -853,6 +871,8 @@ class _$CompanyGatewayEntity extends CompanyGatewayEntity { ..add('customValue3', customValue3) ..add('customValue4', customValue4) ..add('config', config) + ..add('autobill', autobill) + ..add('label', label) ..add('isChanged', isChanged) ..add('createdAt', createdAt) ..add('updatedAt', updatedAt) @@ -926,6 +946,14 @@ class CompanyGatewayEntityBuilder String get config => _$this._config; set config(String config) => _$this._config = config; + String _autobill; + String get autobill => _$this._autobill; + set autobill(String autobill) => _$this._autobill = autobill; + + String _label; + String get label => _$this._label; + set label(String label) => _$this._label = label; + bool _isChanged; bool get isChanged => _$this._isChanged; set isChanged(bool isChanged) => _$this._isChanged = isChanged; @@ -976,6 +1004,8 @@ class CompanyGatewayEntityBuilder _customValue3 = _$v.customValue3; _customValue4 = _$v.customValue4; _config = _$v.config; + _autobill = _$v.autobill; + _label = _$v.label; _isChanged = _$v.isChanged; _createdAt = _$v.createdAt; _updatedAt = _$v.updatedAt; @@ -1020,6 +1050,8 @@ class CompanyGatewayEntityBuilder customValue3: customValue3, customValue4: customValue4, config: config, + autobill: autobill, + label: label, isChanged: isChanged, createdAt: createdAt, updatedAt: updatedAt, diff --git a/lib/redux/app/app_state.dart b/lib/redux/app/app_state.dart index ac9242573..92a7b75e7 100644 --- a/lib/redux/app/app_state.dart +++ b/lib/redux/app/app_state.dart @@ -629,7 +629,7 @@ abstract class AppState implements Built { //return 'Last Updated: ${userCompanyStates.map((state) => state.lastUpdated).join(',')}'; //return 'Names: ${userCompanyStates.map((state) => state.company.id).join(',')}'; //return 'Client Count: ${userCompanyState.clientState.list.length}, Last Updated: ${userCompanyState.lastUpdated}'; - //return 'Token: ${credentials.token} - ${userCompanyStates.map((state) => state?.token?.token ?? '').where((name) => name.isNotEmpty).join(',')}'; + return 'Token: ${credentials.token} - ${userCompanyStates.map((state) => state?.token?.token ?? '').where((name) => name.isNotEmpty).join(',')}'; //return 'Payment Terms: ${company.settings.defaultPaymentTerms}'; //return 'Invitations: ${uiState.invoiceUIState.editing.invitations}'; //return 'Selection: ${clientUIState.selectedId}'; diff --git a/lib/ui/company_gateway/edit/company_gateway_edit.dart b/lib/ui/company_gateway/edit/company_gateway_edit.dart index 4d04fb963..0cc64e854 100644 --- a/lib/ui/company_gateway/edit/company_gateway_edit.dart +++ b/lib/ui/company_gateway/edit/company_gateway_edit.dart @@ -129,8 +129,33 @@ class _CompanyGatewayEditState extends State ), ListView( children: [ + FormCard(children: [ + DecoratedFormField( + label: localization.label, + initialValue: companyGateway.label, + onChanged: (String value) => viewModel.onChanged( + companyGateway.rebuild((b) => b..label = value.trim())), + ), + if (state.staticState.gatewayMap[companyGateway.gatewayId] + .supportsTokenBilling) + AppDropdownButton( + labelText: localization.autoBill, + value: companyGateway.autobill, + onChanged: (dynamic value) => null, + items: [ + CompanyGatewayEntity.AUTO_BILL_ALWAYS, + CompanyGatewayEntity.AUTO_BILL_OPT_IN, + CompanyGatewayEntity.AUTO_BILL_OPT_OUT, + CompanyGatewayEntity.AUTO_BILL_DISABLED + ] + .map((value) => DropdownMenuItem( + child: Text(value), + value: value, + )) + .toList()) + ]), FormCard( - children: [ + children: [ SwitchListTile( activeColor: Theme.of(context).accentColor, title: Text(localization.updateAddress), diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index 70ef7bf96..8d83a5334 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -15,6 +15,7 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'label': 'Label', 'client_number': 'Client Number', 'auto_convert': 'Auto Convert', 'company_name': 'Company Name', @@ -4393,6 +4394,8 @@ mixin LocalizationsProvider on LocaleCodeAware { String get autoConvert => _localizedValues[localeCode]['auto_convert'] ?? ''; + String get label => _localizedValues[localeCode]['label'] ?? ''; + String lookup(String key) { final lookupKey = toSnakeCase(key); diff --git a/lib/utils/web.dart b/lib/utils/web.dart index f5e9926af..25ddfeb15 100644 --- a/lib/utils/web.dart +++ b/lib/utils/web.dart @@ -49,11 +49,13 @@ class WebUtils { static void registerWebView(String html) { // ignore: undefined_prefixed_name + /* ui.platformViewRegistry.registerViewFactory( html, (int viewId) => IFrameElement() ..src = html ..style.border = 'none'); + */ } static void warnChanges(Store store) { diff --git a/pubspec.lock b/pubspec.lock index 7c3a7bcbe..a2e23e84b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -217,21 +217,28 @@ packages: name: device_info url: "https://pub.dartlang.org" source: hosted - version: "0.4.2+6" + version: "0.4.2+7" + device_info_platform_interface: + dependency: transitive + description: + name: device_info_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" extended_image: dependency: transitive description: name: extended_image url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" extended_image_library: dependency: transitive description: name: extended_image_library url: "https://pub.dartlang.org" source: hosted - version: "0.2.3" + version: "0.3.0" extension: dependency: transitive description: @@ -431,7 +438,7 @@ packages: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.5.1" + version: "4.5.3" google_sign_in_platform_interface: dependency: transitive description: @@ -501,7 +508,7 @@ packages: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.6.7+4" + version: "0.6.7+6" image_picker_platform_interface: dependency: transitive description: @@ -515,7 +522,7 @@ packages: name: in_app_purchase url: "https://pub.dartlang.org" source: hosted - version: "0.3.4+3" + version: "0.3.4+4" intl: dependency: "direct main" description: @@ -557,7 +564,7 @@ packages: name: local_auth url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.3+1" logging: dependency: transitive description: @@ -648,7 +655,7 @@ packages: name: package_info url: "https://pub.dartlang.org" source: hosted - version: "0.4.1" + version: "0.4.3" path: dependency: transitive description: @@ -662,7 +669,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "1.6.11" + version: "1.6.14" path_provider_linux: dependency: transitive description: @@ -795,21 +802,21 @@ packages: name: share url: "https://pub.dartlang.org" source: hosted - version: "0.6.4+3" + version: "0.6.4+5" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.8" + version: "0.5.10" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "0.0.2+1" + version: "0.0.2+2" shared_preferences_macos: dependency: transitive description: @@ -982,7 +989,7 @@ packages: name: timeago url: "https://pub.dartlang.org" source: hosted - version: "2.0.26" + version: "2.0.27" timing: dependency: transitive description: @@ -1115,7 +1122,7 @@ packages: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.1" + version: "0.1.2" xml: dependency: transitive description: