[Pharo] Personal fitness tracker web app.
User form error management.
src/MyFitnessTracker-Components/MFTUserForm.class.st
@@ -2,7 +2,9 @@
2
2
#name : 'MFTUserForm',
3
3
#superclass : 'MFTForm',
4
4
#instVars : [
5
Removed:
'user'
5
Added:
'user',
6
Added:
'password',
7
Added:
'passwordConfirmation'
6
8
],
7
9
#category : 'MyFitnessTracker-Components-Forms',
8
10
#package : 'MyFitnessTracker-Components',
@@ -39,9 +41,12 @@
39
41
html dateInput5 formControl
40
42
placeholder: 'RequiredEntry-PutItAndDoNotUse';
41
43
callback: [ :input |
42
Removed:
user dateOfBirth: (Date readFrom: input pattern: 'yyyy-mm-dd') ];
44
Added:
input
45
Added:
ifNotEmpty: [
46
Added:
user dateOfBirth: (Date readFrom: input pattern: 'yyyy-mm-dd') ]
47
Added:
ifEmpty: [ user dateOfBirth: nil ] ];
43
48
value: user dateOfBirth yyyymmdd.
44
Removed:
html label: 'Date' ] ]
49
Added:
html label: 'Date of birth' ] ]
45
50
]
46
51
47
52
{ #category : 'rendering' }
@@ -50,13 +55,21 @@
50
55
html formGroup: [
51
56
html div
52
57
class: 'form-floating';
58
Added:
with: [
59
Added:
html formPasswordInput
60
Added:
placeholder: 'RequiredEntry-PutItAndDoNotUse';
61
Added:
callback: [ :input | input ifNotEmpty: [ password := input ] ].
62
Added:
html label: 'Change password' ] ].
63
Added:
html formGroup: [
64
Added:
html div
65
Added:
class: 'form-floating';
53
66
marginBottom: 3;
54
67
with: [
55
68
html formPasswordInput
56
69
placeholder: 'RequiredEntry-PutItAndDoNotUse';
57
70
callback: [ :input |
58
Removed:
input ifNotEmpty: [ user passwordHashFromString: input ] ].
59
Removed:
html label: 'Change password' ] ]
71
Added:
input ifNotEmpty: [ passwordConfirmation := input ] ].
72
Added:
html label: 'Confirm new password' ] ]
60
73
]
61
74
62
75
{ #category : 'rendering' }
@@ -107,7 +120,20 @@
107
120
{ #category : 'as yet unclassified' }
108
121
MFTUserForm >> submitForm [
109
122
110
Removed:
self answer: user
123
Added:
| errors |
124
Added:
errors := OrderedCollection new.
125
Added:
user username ifEmpty: [ errors add: 'Username is empty' ].
126
Added:
password = passwordConfirmation ifFalse: [
127
Added:
errors add: 'Password and confirmation don''t match' ].
128
Added:
129
Added:
errors
130
Added:
ifNotEmpty: [
131
Added:
| abort |
132
Added:
abort := self call: (MFTErrorsForm new errors: errors).
133
Added:
abort ifTrue: [ self answer: nil ] ]
134
Added:
ifEmpty: [
135
Added:
password ifNotNil: [ user passwordHashFromString: password ].
136
Added:
self answer: user ]
111
137
]
112
138
113
139
{ #category : 'accessing' }