Add password UI for vendor contacts

This commit is contained in:
Hillel Coren 2023-10-26 12:49:43 +03:00
parent ab10e4835d
commit ffb3e97890
3 changed files with 47 additions and 4 deletions

View File

@ -555,6 +555,7 @@ abstract class VendorContactEntity extends Object
customValue3: '', customValue3: '',
customValue4: '', customValue4: '',
link: '', link: '',
password: '',
); );
} }
@ -585,6 +586,8 @@ abstract class VendorContactEntity extends Object
String get phone; String get phone;
String get password;
@BuiltValueField(wireName: 'custom_value1') @BuiltValueField(wireName: 'custom_value1')
String get customValue1; String get customValue1;
@ -665,6 +668,7 @@ abstract class VendorContactEntity extends Object
static void _initializeBuilder(VendorContactEntityBuilder builder) => builder static void _initializeBuilder(VendorContactEntityBuilder builder) => builder
..sendEmail = true ..sendEmail = true
..link = '' ..link = ''
..password = ''
..customValue1 = '' ..customValue1 = ''
..customValue2 = '' ..customValue2 = ''
..customValue3 = '' ..customValue3 = ''

View File

@ -441,6 +441,9 @@ class _$VendorContactEntitySerializer
'phone', 'phone',
serializers.serialize(object.phone, serializers.serialize(object.phone,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
'password',
serializers.serialize(object.password,
specifiedType: const FullType(String)),
'custom_value1', 'custom_value1',
serializers.serialize(object.customValue1, serializers.serialize(object.customValue1,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
@ -535,6 +538,10 @@ class _$VendorContactEntitySerializer
result.phone = serializers.deserialize(value, result.phone = serializers.deserialize(value,
specifiedType: const FullType(String))! as String; specifiedType: const FullType(String))! as String;
break; break;
case 'password':
result.password = serializers.deserialize(value,
specifiedType: const FullType(String))! as String;
break;
case 'custom_value1': case 'custom_value1':
result.customValue1 = serializers.deserialize(value, result.customValue1 = serializers.deserialize(value,
specifiedType: const FullType(String))! as String; specifiedType: const FullType(String))! as String;
@ -1387,6 +1394,8 @@ class _$VendorContactEntity extends VendorContactEntity {
@override @override
final String phone; final String phone;
@override @override
final String password;
@override
final String customValue1; final String customValue1;
@override @override
final String customValue2; final String customValue2;
@ -1424,6 +1433,7 @@ class _$VendorContactEntity extends VendorContactEntity {
required this.isPrimary, required this.isPrimary,
required this.sendEmail, required this.sendEmail,
required this.phone, required this.phone,
required this.password,
required this.customValue1, required this.customValue1,
required this.customValue2, required this.customValue2,
required this.customValue3, required this.customValue3,
@ -1450,6 +1460,8 @@ class _$VendorContactEntity extends VendorContactEntity {
sendEmail, r'VendorContactEntity', 'sendEmail'); sendEmail, r'VendorContactEntity', 'sendEmail');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
phone, r'VendorContactEntity', 'phone'); phone, r'VendorContactEntity', 'phone');
BuiltValueNullFieldError.checkNotNull(
password, r'VendorContactEntity', 'password');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
customValue1, r'VendorContactEntity', 'customValue1'); customValue1, r'VendorContactEntity', 'customValue1');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -1487,6 +1499,7 @@ class _$VendorContactEntity extends VendorContactEntity {
isPrimary == other.isPrimary && isPrimary == other.isPrimary &&
sendEmail == other.sendEmail && sendEmail == other.sendEmail &&
phone == other.phone && phone == other.phone &&
password == other.password &&
customValue1 == other.customValue1 && customValue1 == other.customValue1 &&
customValue2 == other.customValue2 && customValue2 == other.customValue2 &&
customValue3 == other.customValue3 && customValue3 == other.customValue3 &&
@ -1513,6 +1526,7 @@ class _$VendorContactEntity extends VendorContactEntity {
_$hash = $jc(_$hash, isPrimary.hashCode); _$hash = $jc(_$hash, isPrimary.hashCode);
_$hash = $jc(_$hash, sendEmail.hashCode); _$hash = $jc(_$hash, sendEmail.hashCode);
_$hash = $jc(_$hash, phone.hashCode); _$hash = $jc(_$hash, phone.hashCode);
_$hash = $jc(_$hash, password.hashCode);
_$hash = $jc(_$hash, customValue1.hashCode); _$hash = $jc(_$hash, customValue1.hashCode);
_$hash = $jc(_$hash, customValue2.hashCode); _$hash = $jc(_$hash, customValue2.hashCode);
_$hash = $jc(_$hash, customValue3.hashCode); _$hash = $jc(_$hash, customValue3.hashCode);
@ -1539,6 +1553,7 @@ class _$VendorContactEntity extends VendorContactEntity {
..add('isPrimary', isPrimary) ..add('isPrimary', isPrimary)
..add('sendEmail', sendEmail) ..add('sendEmail', sendEmail)
..add('phone', phone) ..add('phone', phone)
..add('password', password)
..add('customValue1', customValue1) ..add('customValue1', customValue1)
..add('customValue2', customValue2) ..add('customValue2', customValue2)
..add('customValue3', customValue3) ..add('customValue3', customValue3)
@ -1584,6 +1599,10 @@ class VendorContactEntityBuilder
String? get phone => _$this._phone; String? get phone => _$this._phone;
set phone(String? phone) => _$this._phone = 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? _customValue1;
String? get customValue1 => _$this._customValue1; String? get customValue1 => _$this._customValue1;
set customValue1(String? customValue1) => _$this._customValue1 = customValue1; set customValue1(String? customValue1) => _$this._customValue1 = customValue1;
@ -1651,6 +1670,7 @@ class VendorContactEntityBuilder
_isPrimary = $v.isPrimary; _isPrimary = $v.isPrimary;
_sendEmail = $v.sendEmail; _sendEmail = $v.sendEmail;
_phone = $v.phone; _phone = $v.phone;
_password = $v.password;
_customValue1 = $v.customValue1; _customValue1 = $v.customValue1;
_customValue2 = $v.customValue2; _customValue2 = $v.customValue2;
_customValue3 = $v.customValue3; _customValue3 = $v.customValue3;
@ -1698,12 +1718,13 @@ class VendorContactEntityBuilder
sendEmail, r'VendorContactEntity', 'sendEmail'), sendEmail, r'VendorContactEntity', 'sendEmail'),
phone: BuiltValueNullFieldError.checkNotNull( phone: BuiltValueNullFieldError.checkNotNull(
phone, r'VendorContactEntity', 'phone'), phone, r'VendorContactEntity', 'phone'),
password: BuiltValueNullFieldError.checkNotNull(
password, r'VendorContactEntity', 'password'),
customValue1: BuiltValueNullFieldError.checkNotNull( customValue1: BuiltValueNullFieldError.checkNotNull(
customValue1, r'VendorContactEntity', 'customValue1'), customValue1, r'VendorContactEntity', 'customValue1'),
customValue2: BuiltValueNullFieldError.checkNotNull( customValue2:
customValue2, r'VendorContactEntity', 'customValue2'), BuiltValueNullFieldError.checkNotNull(customValue2, r'VendorContactEntity', 'customValue2'),
customValue3: customValue3: BuiltValueNullFieldError.checkNotNull(customValue3, r'VendorContactEntity', 'customValue3'),
BuiltValueNullFieldError.checkNotNull(customValue3, r'VendorContactEntity', 'customValue3'),
customValue4: BuiltValueNullFieldError.checkNotNull(customValue4, r'VendorContactEntity', 'customValue4'), customValue4: BuiltValueNullFieldError.checkNotNull(customValue4, r'VendorContactEntity', 'customValue4'),
link: BuiltValueNullFieldError.checkNotNull(link, r'VendorContactEntity', 'link'), link: BuiltValueNullFieldError.checkNotNull(link, r'VendorContactEntity', 'link'),
isChanged: isChanged, isChanged: isChanged,

View File

@ -186,6 +186,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
final _firstNameController = TextEditingController(); final _firstNameController = TextEditingController();
final _lastNameController = TextEditingController(); final _lastNameController = TextEditingController();
final _emailController = TextEditingController(); final _emailController = TextEditingController();
final _passwordController = TextEditingController();
final _phoneController = TextEditingController(); final _phoneController = TextEditingController();
final _custom1Controller = TextEditingController(); final _custom1Controller = TextEditingController();
final _custom2Controller = TextEditingController(); final _custom2Controller = TextEditingController();
@ -216,6 +217,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
_firstNameController, _firstNameController,
_lastNameController, _lastNameController,
_emailController, _emailController,
_passwordController,
_phoneController, _phoneController,
_custom1Controller, _custom1Controller,
_custom2Controller, _custom2Controller,
@ -230,6 +232,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
_firstNameController.text = contact.firstName; _firstNameController.text = contact.firstName;
_lastNameController.text = contact.lastName; _lastNameController.text = contact.lastName;
_emailController.text = contact.email; _emailController.text = contact.email;
_passwordController.text = contact.password;
_phoneController.text = contact.phone; _phoneController.text = contact.phone;
_custom1Controller.text = contact.customValue1; _custom1Controller.text = contact.customValue1;
_custom2Controller.text = contact.customValue2; _custom2Controller.text = contact.customValue2;
@ -258,6 +261,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
..lastName = _lastNameController.text.trim() ..lastName = _lastNameController.text.trim()
..email = _emailController.text.trim() ..email = _emailController.text.trim()
..phone = _phoneController.text.trim() ..phone = _phoneController.text.trim()
..password = _passwordController.text.trim()
..customValue1 = _custom1Controller.text.trim() ..customValue1 = _custom1Controller.text.trim()
..customValue2 = _custom2Controller.text.trim() ..customValue2 = _custom2Controller.text.trim()
..customValue3 = _custom3Controller.text.trim() ..customValue3 = _custom3Controller.text.trim()
@ -274,6 +278,7 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
final localization = AppLocalization.of(context)!; final localization = AppLocalization.of(context)!;
final viewModel = widget.viewModel; final viewModel = widget.viewModel;
final state = widget.vendorViewModel.state; final state = widget.vendorViewModel.state;
final company = viewModel.company!;
final isFullscreen = state.prefState.isEditorFullScreen(EntityType.vendor); final isFullscreen = state.prefState.isEditorFullScreen(EntityType.vendor);
final column = Column( final column = Column(
@ -299,6 +304,19 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
? localization.emailIsInvalid ? localization.emailIsInvalid
: null, : 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( DecoratedFormField(
controller: _phoneController, controller: _phoneController,
onSavePressed: (_) => _onDoneContactPressed(), onSavePressed: (_) => _onDoneContactPressed(),