From ffb3e97890968f2f32df77fd3af6b5a0d10c4ad7 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 26 Oct 2023 12:49:43 +0300 Subject: [PATCH] Add password UI for vendor contacts --- lib/data/models/vendor_model.dart | 4 +++ lib/data/models/vendor_model.g.dart | 29 +++++++++++++++++--- lib/ui/vendor/edit/vendor_edit_contacts.dart | 18 ++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/lib/data/models/vendor_model.dart b/lib/data/models/vendor_model.dart index be4549e44..2e3c2c143 100644 --- a/lib/data/models/vendor_model.dart +++ b/lib/data/models/vendor_model.dart @@ -555,6 +555,7 @@ abstract class VendorContactEntity extends Object customValue3: '', customValue4: '', link: '', + password: '', ); } @@ -585,6 +586,8 @@ abstract class VendorContactEntity extends Object String get phone; + String get password; + @BuiltValueField(wireName: 'custom_value1') String get customValue1; @@ -665,6 +668,7 @@ abstract class VendorContactEntity extends Object static void _initializeBuilder(VendorContactEntityBuilder builder) => builder ..sendEmail = true ..link = '' + ..password = '' ..customValue1 = '' ..customValue2 = '' ..customValue3 = '' diff --git a/lib/data/models/vendor_model.g.dart b/lib/data/models/vendor_model.g.dart index 3f0df4550..fe79c68f0 100644 --- a/lib/data/models/vendor_model.g.dart +++ b/lib/data/models/vendor_model.g.dart @@ -441,6 +441,9 @@ class _$VendorContactEntitySerializer 'phone', serializers.serialize(object.phone, specifiedType: const FullType(String)), + 'password', + serializers.serialize(object.password, + specifiedType: const FullType(String)), 'custom_value1', serializers.serialize(object.customValue1, specifiedType: const FullType(String)), @@ -535,6 +538,10 @@ class _$VendorContactEntitySerializer result.phone = serializers.deserialize(value, specifiedType: const FullType(String))! as String; break; + case 'password': + result.password = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; case 'custom_value1': result.customValue1 = serializers.deserialize(value, specifiedType: const FullType(String))! as String; @@ -1387,6 +1394,8 @@ class _$VendorContactEntity extends VendorContactEntity { @override final String phone; @override + final String password; + @override final String customValue1; @override final String customValue2; @@ -1424,6 +1433,7 @@ class _$VendorContactEntity extends VendorContactEntity { required this.isPrimary, required this.sendEmail, required this.phone, + required this.password, required this.customValue1, required this.customValue2, required this.customValue3, @@ -1450,6 +1460,8 @@ class _$VendorContactEntity extends VendorContactEntity { sendEmail, r'VendorContactEntity', 'sendEmail'); BuiltValueNullFieldError.checkNotNull( phone, r'VendorContactEntity', 'phone'); + BuiltValueNullFieldError.checkNotNull( + password, r'VendorContactEntity', 'password'); BuiltValueNullFieldError.checkNotNull( customValue1, r'VendorContactEntity', 'customValue1'); BuiltValueNullFieldError.checkNotNull( @@ -1487,6 +1499,7 @@ class _$VendorContactEntity extends VendorContactEntity { isPrimary == other.isPrimary && sendEmail == other.sendEmail && phone == other.phone && + password == other.password && customValue1 == other.customValue1 && customValue2 == other.customValue2 && customValue3 == other.customValue3 && @@ -1513,6 +1526,7 @@ class _$VendorContactEntity extends VendorContactEntity { _$hash = $jc(_$hash, isPrimary.hashCode); _$hash = $jc(_$hash, sendEmail.hashCode); _$hash = $jc(_$hash, phone.hashCode); + _$hash = $jc(_$hash, password.hashCode); _$hash = $jc(_$hash, customValue1.hashCode); _$hash = $jc(_$hash, customValue2.hashCode); _$hash = $jc(_$hash, customValue3.hashCode); @@ -1539,6 +1553,7 @@ class _$VendorContactEntity extends VendorContactEntity { ..add('isPrimary', isPrimary) ..add('sendEmail', sendEmail) ..add('phone', phone) + ..add('password', password) ..add('customValue1', customValue1) ..add('customValue2', customValue2) ..add('customValue3', customValue3) @@ -1584,6 +1599,10 @@ class VendorContactEntityBuilder String? get phone => _$this._phone; set phone(String? phone) => _$this._phone = phone; + String? _password; + String? get password => _$this._password; + set password(String? password) => _$this._password = password; + String? _customValue1; String? get customValue1 => _$this._customValue1; set customValue1(String? customValue1) => _$this._customValue1 = customValue1; @@ -1651,6 +1670,7 @@ class VendorContactEntityBuilder _isPrimary = $v.isPrimary; _sendEmail = $v.sendEmail; _phone = $v.phone; + _password = $v.password; _customValue1 = $v.customValue1; _customValue2 = $v.customValue2; _customValue3 = $v.customValue3; @@ -1698,12 +1718,13 @@ class VendorContactEntityBuilder sendEmail, r'VendorContactEntity', 'sendEmail'), phone: BuiltValueNullFieldError.checkNotNull( phone, r'VendorContactEntity', 'phone'), + password: BuiltValueNullFieldError.checkNotNull( + password, r'VendorContactEntity', 'password'), customValue1: BuiltValueNullFieldError.checkNotNull( customValue1, r'VendorContactEntity', 'customValue1'), - customValue2: BuiltValueNullFieldError.checkNotNull( - customValue2, r'VendorContactEntity', 'customValue2'), - customValue3: - BuiltValueNullFieldError.checkNotNull(customValue3, r'VendorContactEntity', 'customValue3'), + customValue2: + BuiltValueNullFieldError.checkNotNull(customValue2, r'VendorContactEntity', 'customValue2'), + customValue3: BuiltValueNullFieldError.checkNotNull(customValue3, r'VendorContactEntity', 'customValue3'), customValue4: BuiltValueNullFieldError.checkNotNull(customValue4, r'VendorContactEntity', 'customValue4'), link: BuiltValueNullFieldError.checkNotNull(link, r'VendorContactEntity', 'link'), isChanged: isChanged, diff --git a/lib/ui/vendor/edit/vendor_edit_contacts.dart b/lib/ui/vendor/edit/vendor_edit_contacts.dart index d71d6d449..4e022bbd0 100644 --- a/lib/ui/vendor/edit/vendor_edit_contacts.dart +++ b/lib/ui/vendor/edit/vendor_edit_contacts.dart @@ -186,6 +186,7 @@ class VendorContactEditDetailsState extends State { final _firstNameController = TextEditingController(); final _lastNameController = TextEditingController(); final _emailController = TextEditingController(); + final _passwordController = TextEditingController(); final _phoneController = TextEditingController(); final _custom1Controller = TextEditingController(); final _custom2Controller = TextEditingController(); @@ -216,6 +217,7 @@ class VendorContactEditDetailsState extends State { _firstNameController, _lastNameController, _emailController, + _passwordController, _phoneController, _custom1Controller, _custom2Controller, @@ -230,6 +232,7 @@ class VendorContactEditDetailsState extends State { _firstNameController.text = contact.firstName; _lastNameController.text = contact.lastName; _emailController.text = contact.email; + _passwordController.text = contact.password; _phoneController.text = contact.phone; _custom1Controller.text = contact.customValue1; _custom2Controller.text = contact.customValue2; @@ -258,6 +261,7 @@ class VendorContactEditDetailsState extends State { ..lastName = _lastNameController.text.trim() ..email = _emailController.text.trim() ..phone = _phoneController.text.trim() + ..password = _passwordController.text.trim() ..customValue1 = _custom1Controller.text.trim() ..customValue2 = _custom2Controller.text.trim() ..customValue3 = _custom3Controller.text.trim() @@ -274,6 +278,7 @@ class VendorContactEditDetailsState extends State { final localization = AppLocalization.of(context)!; final viewModel = widget.viewModel; final state = widget.vendorViewModel.state; + final company = viewModel.company!; final isFullscreen = state.prefState.isEditorFullScreen(EntityType.vendor); final column = Column( @@ -299,6 +304,19 @@ class VendorContactEditDetailsState extends State { ? localization.emailIsInvalid : null, ), + company.settings.enablePortalPassword ?? false + ? DecoratedFormField( + autocorrect: false, + controller: _passwordController, + label: localization.password, + obscureText: true, + keyboardType: TextInputType.visiblePassword, + validator: (value) => value.isNotEmpty && value.length < 8 + ? localization.passwordIsTooShort + : null, + onSavePressed: (_) => _onDoneContactPressed(), + ) + : SizedBox(), DecoratedFormField( controller: _phoneController, onSavePressed: (_) => _onDoneContactPressed(),