Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Σταύρος Παπαδάκης
e-epal
Commits
c3ad3f8a
Commit
c3ad3f8a
authored
Mar 28, 2017
by
Χάρης Παπαδόπουλος
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parent form: user experience stuff
parent
751176d2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
182 additions
and
40 deletions
+182
-40
drupal/modules/epal/epal.routing.yml
drupal/modules/epal/epal.routing.yml
+8
-0
drupal/modules/epal/src/Controller/CurrentUser.php
drupal/modules/epal/src/Controller/CurrentUser.php
+37
-0
drupal/modules/epaldeploysystem/config/optional/user.role.applicant.yml
.../epaldeploysystem/config/optional/user.role.applicant.yml
+54
-0
source/components/student-application-form/parent.form.html
source/components/student-application-form/parent.form.html
+26
-23
source/components/student-application-form/parent.form.ts
source/components/student-application-form/parent.form.ts
+34
-17
source/services/helper-data-service.ts
source/services/helper-data-service.ts
+23
-0
No files found.
drupal/modules/epal/epal.routing.yml
View file @
c3ad3f8a
...
...
@@ -14,6 +14,14 @@ epal.user.verify_verification_code:
_controller
:
'
\Drupal\epal\Controller\CurrentUser::verifyVerificationCode'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.user.save_profile
:
path
:
'
/epal/user/save'
options
:
_auth
:
[
'
basic_auth'
]
defaults
:
_controller
:
'
\Drupal\epal\Controller\CurrentUser::saveUserProfile'
requirements
:
_user_is_logged_in
:
'
TRUE'
epal.user.get_data
:
path
:
'
/epal/userdata'
options
:
...
...
drupal/modules/epal/src/Controller/CurrentUser.php
View file @
c3ad3f8a
...
...
@@ -214,6 +214,43 @@ class CurrentUser extends ControllerBase
}
}
public
function
saveUserProfile
(
Request
$request
)
{
if
(
!
$request
->
isMethod
(
'POST'
))
{
return
$this
->
respondWithStatus
([
"message"
=>
t
(
"Method Not Allowed"
)
],
Response
::
HTTP_METHOD_NOT_ALLOWED
);
}
$authToken
=
$request
->
headers
->
get
(
'PHP_AUTH_USER'
);
$epalUsers
=
$this
->
entityTypeManager
->
getStorage
(
'epal_users'
)
->
loadByProperties
(
array
(
'authtoken'
=>
$authToken
));
$epalUser
=
reset
(
$epalUsers
);
if
(
$epalUser
)
{
$postData
=
null
;
if
(
$content
=
$request
->
getContent
())
{
$postData
=
json_decode
(
$content
);
$epalUser
->
set
(
'name'
,
$postData
->
userProfile
->
userName
);
$epalUser
->
set
(
'surname'
,
$postData
->
userProfile
->
userSurname
);
$epalUser
->
set
(
'mothername'
,
$postData
->
userProfile
->
userMothername
);
$epalUser
->
set
(
'fathername'
,
$postData
->
userProfile
->
userFathername
);
$epalUser
->
save
();
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"profile saved"
),
],
Response
::
HTTP_OK
);
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"post with no data"
),
],
Response
::
HTTP_BAD_REQUEST
);
}
}
else
{
return
$this
->
respondWithStatus
([
'message'
=>
t
(
"EPAL user not found"
),
],
Response
::
HTTP_FORBIDDEN
);
}
}
private
function
respondWithStatus
(
$arr
,
$s
)
{
$res
=
new
JsonResponse
(
$arr
);
$res
->
setStatusCode
(
$s
);
...
...
drupal/modules/epaldeploysystem/config/optional/user.role.applicant.yml
0 → 100644
View file @
c3ad3f8a
langcode
:
el
status
:
true
dependencies
:
{
}
id
:
applicant
label
:
applicant
weight
:
3
is_admin
:
null
permissions
:
-
'
add
epal
student
class
entities'
-
'
add
epal
student
entities'
-
'
add
epal
student
course
field
entities'
-
'
add
epal
student
epal
chosen
entities'
-
'
add
epal
student
sector
field
entities'
-
'
add
epal
users
entities'
-
'
delete
epal
student
class
entities'
-
'
delete
epal
student
entities'
-
'
delete
epal
student
course
field
entities'
-
'
delete
epal
student
epal
chosen
entities'
-
'
delete
epal
student
sector
field
entities'
-
'
delete
epal
users
entities'
-
'
edit
epal
student
class
entities'
-
'
edit
epal
student
entities'
-
'
edit
epal
student
course
field
entities'
-
'
edit
epal
student
epal
chosen
entities'
-
'
edit
epal
student
sector
field
entities'
-
'
edit
epal
users
entities'
-
'
view
published
epal
student
class
entities'
-
'
view
published
epal
student
entities'
-
'
view
published
epal
student
course
field
entities'
-
'
view
published
epal
student
epal
chosen
entities'
-
'
view
published
epal
student
sector
field
entities'
-
'
view
published
epal
users
entities'
-
'
view
unpublished
epal
student
class
entities'
-
'
view
unpublished
epal
student
entities'
-
'
view
unpublished
epal
student
course
field
entities'
-
'
view
unpublished
epal
student
epal
chosen
entities'
-
'
view
unpublished
epal
student
sector
field
entities'
-
'
view
unpublished
epal
users
entities'
-
'
view
published
eepal
admin
area
entities'
-
'
view
published
eepal
prefecture
entities'
-
'
view
published
eepal
region
entities'
-
'
view
published
eepal
school
entities'
-
'
view
published
eepal
sectors
entities'
-
'
view
published
eepal
sectors
in
epal
entities'
-
'
view
published
eepal
specialties
in
epal
entities'
-
'
view
published
eepal
specialty
entities'
-
'
view
unpublished
eepal
admin
area
entities'
-
'
view
unpublished
eepal
prefecture
entities'
-
'
view
unpublished
eepal
region
entities'
-
'
view
unpublished
eepal
school
entities'
-
'
view
unpublished
eepal
sectors
entities'
-
'
view
unpublished
eepal
sectors
in
epal
entities'
-
'
view
unpublished
eepal
specialties
in
epal
entities'
-
'
view
unpublished
eepal
specialty
entities'
source/components/student-application-form/parent.form.html
View file @
c3ad3f8a
...
...
@@ -2,22 +2,31 @@
<form
[formGroup]=
"formGroup"
>
<div
class=
"form-group"
>
<label
for=
"userEmail"
>
Email Επικοινωνίας
</label><input
#userEmail
class=
"form-control"
type=
"text"
formControlName=
"userEmail"
value=
"{{ (epalUserData$ | async).userEmail }}"
>
<label
for=
"userEmail"
>
Email Επικοινωνίας
</label><input
#userEmail
class=
"form-control"
type=
"text"
formControlName=
"userEmail"
>
</div>
<div
class=
"alert alert-danger"
*ngIf=
"
formGroup.get('userEmail').touched &&
formGroup.get('userEmail').hasError('required')
"
>
<div
class=
"alert alert-danger"
*ngIf=
"formGroup.get('userEmail').hasError('required')"
>
Το πεδίο δεν μπορεί να αφεθεί κενό!
</div>
<div
class=
"alert alert-danger"
*ngIf=
"formGroup.get('userEmail').hasError('pattern')"
>
Πληκτρολογήστε ένα σωστό συντακτικά email!
</div>
<div
class=
"row"
*ngIf=
"verificationCodeVerified | async"
>
<div
class=
"row"
*ngIf=
"(userEmailEnabled | async) && formGroup.get('userEmail').valid"
style=
"margin-top: 20px; margin-bottom: 20px;"
>
<div
class=
"col-md-12"
>
<button
type=
"button"
class=
"btn-primary btn-sm pull-right"
(click)=
"sendVerificationCode()"
>
Λήψη Κωδικού Επαλήθευσης
</button>
</div>
</div>
<div
class=
"row"
style=
"margin-bottom: 20px;"
>
<div
class=
"col-md-12"
>
<div
*ngIf=
"userEmailEnabled | async"
>
<button
type=
"button"
class=
"btn-primary btn-sm pull-right"
(click)=
"
disable
UserEmail();"
>
<div
*ngIf=
"
(
userEmailEnabled | async
) && (epalUserData$ | async).userEmail !== ''
"
>
<button
type=
"button"
class=
"btn-primary btn-sm pull-right"
(click)=
"
reset
UserEmail();"
>
Ακύρωση Αλλαγής Email
</button>
</div>
<div
*ngIf=
"!(userEmailEnabled | async)"
>
<div
*ngIf=
"!(userEmailEnabled | async)"
style=
"margin-left: 10px;"
>
<button
type=
"button"
class=
"btn-primary btn-sm pull-right"
(click)=
"enableUserEmail();"
>
Αλλαγή Email
</button>
...
...
@@ -25,13 +34,7 @@
</div>
</div>
<div
class=
"row"
*ngIf=
"(showSendVerification | async) && !(verificationCodeSent | async) && !formGroup.get('userEmail').hasError('required') && !formGroup.get('userEmail').hasError('pattern')"
>
<div
class=
"col-md-12"
>
<button
type=
"button"
class=
"btn-primary btn-sm pull-right"
(click)=
"sendVerificationCode()"
>
Λήψη Κωδικού Επαλήθευσης
</button>
</div>
</div>
<div
class=
"form-group"
*ngIf=
"(verificationCodeSent | async) && !(verificationCodeVerified | async)"
>
<label
for=
"verificationCode"
>
Κωδικός επαλήθευσης
</label><input
class=
"form-control"
type=
"text"
formControlName=
"verificationCode"
>
</div>
...
...
@@ -44,8 +47,8 @@
</div>
<div
class=
"form-group"
*ngIf=
"verificationCodeVerified | async"
>
<label
for=
"userName"
>
Όνομα
</label><input
class=
"form-control"
type=
"text"
formControlName=
"userName"
value=
"{{ (epalUserData$ | async).userName }}"
>
<div
class=
"form-group"
*ngIf=
"
!(userEmailEnabled | async) && (
verificationCodeVerified | async
)
"
>
<label
for=
"userName"
>
Όνομα
</label><input
class=
"form-control"
type=
"text"
formControlName=
"userName"
>
</div>
<div
class=
"alert alert-danger"
*ngIf=
"formGroup.get('userName').touched && formGroup.get('userName').hasError('required') "
>
Το πεδίο δεν μπορεί να αφεθεί κενό!
...
...
@@ -54,8 +57,8 @@
Πληκτρολογήστε το όνομά σας!
</div>
<div
class=
"form-group"
*ngIf=
"verificationCodeVerified | async"
>
<label
for=
"userSurname"
>
Επώνυμο
</label><input
class=
"form-control"
type=
"text"
formControlName=
"userSurname"
value=
"{{ (epalUserData$ | async).userSurname }}"
>
<div
class=
"form-group"
*ngIf=
"
!(userEmailEnabled | async) && (
verificationCodeVerified | async
)
"
>
<label
for=
"userSurname"
>
Επώνυμο
</label><input
class=
"form-control"
type=
"text"
formControlName=
"userSurname"
>
</div>
<div
class=
"alert alert-danger"
*ngIf=
"formGroup.get('userSurname').touched && formGroup.get('userSurname').hasError('required') "
>
Το πεδίο δεν μπορεί να αφεθεί κενό!
...
...
@@ -64,8 +67,8 @@
Πληκτρολογήστε το επώνυμό σας!
</div>
<div
class=
"form-group"
*ngIf=
"verificationCodeVerified | async"
>
<label
for=
"userFathername"
>
Πατρώνυμο
</label><input
class=
"form-control"
type=
"text"
formControlName=
"userFathername"
value=
"{{ (epalUserData$ | async).userFathername }}"
>
<div
class=
"form-group"
*ngIf=
"
!(userEmailEnabled | async) && (
verificationCodeVerified | async
)
"
>
<label
for=
"userFathername"
>
Πατρώνυμο
</label><input
class=
"form-control"
type=
"text"
formControlName=
"userFathername"
>
</div>
<div
class=
"alert alert-danger"
*ngIf=
"formGroup.get('userFathername').touched && formGroup.get('userFathername').hasError('required') "
>
Το πεδίο δεν μπορεί να αφεθεί κενό!
...
...
@@ -74,8 +77,8 @@
Πληκτρολογήστε το όνομα του πατέρα σας!
</div>
<div
class=
"form-group"
*ngIf=
"verificationCodeVerified | async"
>
<label
for=
"userMothername"
>
Μητρώνυμο
</label><input
class=
"form-control"
type=
"text"
formControlName=
"userMothername"
value=
"{{ (epalUserData$ | async).userMothername }}"
>
<div
class=
"form-group"
*ngIf=
"
!(userEmailEnabled | async) && (
verificationCodeVerified | async
)
"
>
<label
for=
"userMothername"
>
Μητρώνυμο
</label><input
class=
"form-control"
type=
"text"
formControlName=
"userMothername"
>
</div>
<div
class=
"alert alert-danger"
*ngIf=
"formGroup.get('userMothername').touched && formGroup.get('userMothername').hasError('required') "
>
Το πεδίο δεν μπορεί να αφεθεί κενό!
...
...
@@ -84,9 +87,9 @@
Πληκτρολογήστε το όνομα της μητέρας σας!
</div>
<div
class=
"row"
*ngIf=
"!(
showSendVerification
| async) && (verificationCodeVerified | async)"
>
<div
class=
"row"
*ngIf=
"!(
userEmailEnabled
| async) && (verificationCodeVerified | async)"
>
<div
class=
"col-md-12"
>
<button
type=
"button"
class=
"btn-primary btn-
lg
pull-right"
(click)=
"
verifyCod
eAndContinue()"
>
<button
type=
"button"
class=
"btn-primary btn-
sm
pull-right"
(click)=
"
saveProfil
eAndContinue()"
[disabled]=
"((userEmailEnabled | async) && !(verificationCodeVerified | async))"
>
Αποθήκευση - Συνέχεια
<i
class=
"fa fa-forward"
></i>
</button>
</div>
...
...
source/components/student-application-form/parent.form.ts
View file @
c3ad3f8a
...
...
@@ -25,7 +25,6 @@ import {AppSettings} from '../../app.settings';
private
epalUserData$
:
BehaviorSubject
<
any
>
;
private
epalUserDataSub
:
Subscription
;
private
userEmailSub
:
Subscription
;
private
showSendVerification
:
BehaviorSubject
<
boolean
>
;
private
verificationCodeSent
:
BehaviorSubject
<
boolean
>
;
private
verificationCodeVerified
:
BehaviorSubject
<
boolean
>
;
private
userEmailEnabled
:
BehaviorSubject
<
boolean
>
;
...
...
@@ -35,7 +34,6 @@ import {AppSettings} from '../../app.settings';
private
router
:
Router
,
private
hds
:
HelperDataService
,
private
rd
:
Renderer
)
{
this
.
showSendVerification
=
new
BehaviorSubject
(
false
);
this
.
verificationCodeSent
=
new
BehaviorSubject
(
false
);
this
.
verificationCodeVerified
=
new
BehaviorSubject
(
false
);
...
...
@@ -46,32 +44,39 @@ import {AppSettings} from '../../app.settings';
userFathername
:
[
''
,
[
Validators
.
pattern
(
VALID_NAMES_PATTERN
),
Validators
.
required
]],
userMothername
:
[
''
,
[
Validators
.
pattern
(
VALID_NAMES_PATTERN
),
Validators
.
required
]],
userEmail
:
[{
value
:
''
,
disabled
:
true
},
[
Validators
.
pattern
(
VALID_EMAIL_PATTERN
),
Validators
.
required
]],
verificationCode
:
[
''
,
[
Validators
.
required
]]
verificationCode
:
[
''
,
[]]
});
this
.
epalUserData$
=
new
BehaviorSubject
({});
}
ngOnInit
()
{
// this.epalUserDataSub = this.hds.getEpalUserData().subscribe(this.epalUserData$);
this
.
epalUserDataSub
=
this
.
hds
.
getEpalUserData
().
subscribe
(
x
=>
{
this
.
epalUserData$
.
next
(
x
);
this
.
formGroup
.
get
(
'
userEmail
'
).
setValue
(
x
.
userEmail
);
this
.
formGroup
.
get
(
'
userName
'
).
setValue
(
x
.
userName
);
this
.
formGroup
.
get
(
'
userSurname
'
).
setValue
(
x
.
userSurname
);
this
.
formGroup
.
get
(
'
userFathername
'
).
setValue
(
x
.
userFathername
);
this
.
formGroup
.
get
(
'
userMothername
'
).
setValue
(
x
.
userMothername
);
if
(
typeof
(
x
.
verificationCodeVerified
)
!==
'
undefined
'
&&
x
.
verificationCodeVerified
===
"
1
"
)
{
this
.
verificationCodeVerified
.
next
(
true
);
}
else
{
this
.
verificationCodeVerified
.
next
(
false
);
}
if
(
typeof
(
x
.
userEmail
)
!==
'
undefined
'
&&
x
.
userEmail
.
length
>
0
)
this
.
userEmailEnabled
.
next
(
false
);
else
else
{
this
.
enableUserEmail
();
this
.
userEmailEnabled
.
next
(
true
);
}
}
);
this
.
userEmailSub
=
this
.
formGroup
.
controls
[
'
userEmail
'
].
valueChanges
.
subscribe
(
this
.
userEmailSub
=
this
.
formGroup
.
get
(
'
userEmail
'
).
valueChanges
.
subscribe
(
x
=>
{
if
(
this
.
formGroup
.
controls
[
'
userEmail
'
]
.
value
===
''
)
{
if
(
this
.
formGroup
.
get
(
'
userEmail
'
)
.
value
===
''
)
{
this
.
enableUserEmail
();
}
}
...
...
@@ -85,30 +90,42 @@ import {AppSettings} from '../../app.settings';
sendVerificationCode
()
{
this
.
hds
.
sendVerificationCode
(
this
.
formGroup
.
value
.
userEmail
)
.
then
(
res
=>
{
this
.
verificationCodeSent
.
next
(
true
);
this
.
showSendVerification
.
next
(
false
);})
.
then
(
res
=>
{
this
.
verificationCodeSent
.
next
(
true
);
this
.
verificationCodeVerified
.
next
(
false
);
this
.
disableUserEmail
();})
.
catch
(
err
=>
{
console
.
log
(
err
)});
}
verifyVerificationCode
()
{
this
.
hds
.
verifyVerificationCode
(
this
.
formGroup
.
value
.
verificationCode
)
.
then
(
res
=>
{
this
.
verificationCodeSent
.
next
(
true
);
this
.
showSendVerification
.
next
(
false
);
this
.
verificationCodeVerified
.
next
((
<
any
>
res
).
verificationCodeVerified
===
"
1
"
?
true
:
false
);
this
.
formGroup
.
value
.
userEmail
=
(
<
any
>
res
).
userEmail
;})
.
then
(
res
=>
{
this
.
verificationCodeVerified
.
next
((
<
any
>
res
).
verificationCodeVerified
);
this
.
formGroup
.
value
.
userEmail
=
(
<
any
>
res
).
userEmail
;})
.
catch
(
err
=>
{
console
.
log
(
err
)});
}
verifyCodeAndContinue
()
{
this
.
router
.
navigate
([
'
/epal-class-select
'
]);
saveProfileAndContinue
()
{
this
.
hds
.
saveProfile
(
this
.
formGroup
.
value
)
.
then
(
res
=>
{
this
.
router
.
navigate
([
'
/epal-class-select
'
]);})
.
catch
(
err
=>
{
console
.
log
(
err
)});
}
enableUserEmail
()
{
this
.
userEmailEnabled
.
next
(
true
);
this
.
formGroup
.
controls
[
"
userEmail
"
]
.
enable
({
emitEvent
:
false
});
this
.
formGroup
.
get
(
"
userEmail
"
)
.
enable
({
emitEvent
:
false
});
this
.
rd
.
invokeElementMethod
(
this
.
userEmail
.
nativeElement
,
'
focus
'
);
}
disableUserEmail
()
{
this
.
userEmailEnabled
.
next
(
false
);
this
.
formGroup
.
controls
[
"
userEmail
"
].
setValue
(
this
.
epalUserData$
.
getValue
().
userEmail
);
this
.
formGroup
.
controls
[
"
userEmail
"
].
disable
({
emitEvent
:
false
});
this
.
formGroup
.
get
(
"
userEmail
"
).
disable
({
emitEvent
:
false
});
}
resetUserEmail
()
{
this
.
userEmailEnabled
.
next
(
false
);
this
.
formGroup
.
get
(
"
userEmail
"
).
setValue
(
this
.
epalUserData$
.
getValue
().
userEmail
);
this
.
formGroup
.
get
(
"
userEmail
"
).
disable
({
emitEvent
:
false
});
}
}
source/services/helper-data-service.ts
View file @
c3ad3f8a
...
...
@@ -106,6 +106,29 @@ export class HelperDataService {
});
}
saveProfile
(
userProfile
)
{
this
.
loginInfo$
.
forEach
(
loginInfoToken
=>
{
this
.
authToken
=
loginInfoToken
.
get
(
0
).
auth_token
;
});
let
headers
=
new
Headers
({
"
Content-Type
"
:
"
application/json
"
,
});
this
.
createAuthorizationHeader
(
headers
);
let
options
=
new
RequestOptions
({
headers
:
headers
});
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
http
.
post
(
`
${
AppSettings
.
API_ENDPOINT
}
/epal/user/save`
,
{
userProfile
:
userProfile
},
options
)
.
map
(
response
=>
response
.
json
())
.
subscribe
(
data
=>
{
resolve
(
data
);
},
error
=>
{
console
.
log
(
"
Error Saving Profile
"
);
reject
(
"
Error Saving Profile
"
);
},
()
=>
console
.
log
(
"
Saving Profile
"
));
});
}
getCourseFields
()
{
this
.
loginInfo$
.
forEach
(
loginInfoToken
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment