Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oser-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamza Touizrat
oser-frontend
Commits
4b9f56bc
Unverified
Commit
4b9f56bc
authored
3 years ago
by
ThomasBidot
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Back to no email verification
parent
f0ae1611
Branches
Branches containing commit
No related tags found
1 merge request
!75
Authorize valid profile
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/signup/student-signup/student-signup.component.ts
+73
-239
73 additions, 239 deletions
src/app/signup/student-signup/student-signup.component.ts
with
73 additions
and
239 deletions
src/app/signup/student-signup/student-signup.component.ts
+
73
−
239
View file @
4b9f56bc
...
@@ -2,10 +2,9 @@ import { Component, OnInit } from '@angular/core';
...
@@ -2,10 +2,9 @@ import { Component, OnInit } from '@angular/core';
import
{
FormGroup
,
FormBuilder
,
Validators
}
from
'
@angular/forms
'
;
import
{
FormGroup
,
FormBuilder
,
Validators
}
from
'
@angular/forms
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
MatSnackBar
}
from
'
@angular/material
'
;
import
{
MatSnackBar
}
from
'
@angular/material
'
;
//
import { Observable } from 'rxjs';
import
{
Observable
}
from
'
rxjs
'
;
import
{
tap
,
mergeMap
}
from
'
rxjs/operators
'
;
import
{
tap
,
mergeMap
}
from
'
rxjs/operators
'
;
import
{
Registration
,
RegistrationService
,
PersonnalData
,
PersonnalDataService
}
from
'
../core
'
;
import
{
Registration
,
RegistrationService
,
PasswordErrorStateMatcher
,
PersonnalData
,
PersonnalDataService
}
from
'
../core
'
;
import
{
CustomValidators
,
ConfirmValidParentMatcher
,
errorMessages
}
from
'
../core/customValidationModule
'
;
import
{
AuthService
}
from
'
app/core
'
;
import
{
AuthService
}
from
'
app/core
'
;
...
@@ -14,170 +13,19 @@ import { AuthService } from 'app/core';
...
@@ -14,170 +13,19 @@ import { AuthService } from 'app/core';
templateUrl
:
'
./student-signup.component.html
'
,
templateUrl
:
'
./student-signup.component.html
'
,
styleUrls
:
[
'
./student-signup.component.scss
'
]
styleUrls
:
[
'
./student-signup.component.scss
'
]
})
})
// export class StudentSignupComponent implements OnInit {
// registration: Registration;
// personnalData: PersonnalData
// formGroup: FormGroup;
// error: String;
// loading = false;
// public showPersonnalDataForm = false;
// public zipPattern = new RegExp(/^\d{5}(?:\d{2})?$/)
// public possibleParentsStatus = [
// { id: "maried", name: "Mariés" },
// { id: "divorced", name: "Divorcés" },
// { id: "cohabitation", name: "En concubinage" },
// { id: "monoparental", name: "Famille monoparentale" }
// ]
// public possibleParentsActivities = [
// { id: "farmer", name: "Agriculteur" },
// { id: "artisan", name: "Artisan, commerçant, chef d'entreprise" },
// { id: "executive", name: "Cadre, profession intellectuelle supérieure" },
// { id: "teacher", name: "Enseignant et assimilé" },
// { id: "intermediate", name: "Profession intermédiaire" },
// { id: "employee", name: "Employé" },
// { id: "worker", name: "Ouvrier" },
// { id: "retreated", name: "Retraité" },
// { id: "inactive", name: "Inactif" },
// { id: "other", name: "Autre" }
// ]
// public possibleScholarships = [
// { id: "echelon1", name: "Oui, échelon 1" },
// { id: "echelon2", name: "Oui, échelon 2" },
// { id: "echelon3", name: "Oui, échelon 3" },
// { id: "echelon4", name: "Oui, échelon 4" },
// { id: "echelon5", name: "Oui, échelon 5" },
// { id: "echelon6", name: "Oui, échelon 6" },
// { id: "no", name: "Non" },
// ]
// passwordMatcher = new PasswordErrorStateMatcher();
// emailMatcher = new EmailErrorStateMatcher();
// constructor(
// private registrationService: RegistrationService,
// private personnalDataService: PersonnalDataService,
// private formBuilder: FormBuilder,
// private router: Router,
// private auth: AuthService,
// private snackBar: MatSnackBar,
// ) { }
// ngOnInit() {
// this.createForm();
// }
// createForm() {
// this.formGroup = this.formBuilder.group({
// firstName: '',
// lastName: '',
// email: ['', Validators.email],
// emailConfirm: '',
// phoneNumber: '',
// gender: '',
// adressNumber: '',
// street: '',
// zipCode: ['', Validators.pattern(this.zipPattern)],
// city: '',
// personnalPhone: '',
// parentsPhone: '',
// parentsEmail: ['', Validators.email],
// school: '',
// grade: '',
// section: '',
// specialTeaching: '',
// scholarship: '',
// fatherActivity: '',
// motherActivity: '',
// parentsStatus: '',
// dependantsNumber: '',
// password: '',
// passwordConfirm: '',
// agree: [false, Validators.required],
// filledForm: false,
// acceptedConditions: false,
// }, { validator: (group) => this.checkPasswords(group) && this.checkEmails(group) })
// console.log(this.formGroup.value.agree)
// }
// private checkPasswords(group: FormGroup): null | any {
// const password = group.controls.password.value;
// const passwordConfirm = group.controls.passwordConfirm.value;
// return password === passwordConfirm ? null : { passwordsDifferent: true };
// }
// private checkEmails(group: FormGroup): null | any {
// const email = group.controls.email.value;
// const emailConfirm = group.controls.emailConfirm.value;
// return email === emailConfirm ? null : { emailsDifferent: true };
// }
// toggleShowPersonnalDataForm() {
// this.showPersonnalDataForm = !this.showPersonnalDataForm;
// }
// submit() {
// this.loading = true;
// const { email, firstName, lastName, phoneNumber } = this.formGroup.value
// //const {gender,adressNumber,street,zipCode,city,personnalPhone,parentsPhone,parentsEmail,school,grade,section,specialTeaching,scholarship,fatherActivity,motherActivity,parentsStatus,dependantsNumber} = this.formGroup.value;
// const registration: Registration = { email, firstName, lastName, phoneNumber };
// // const personnalData: PersonnalData = {gender,adressNumber,street,zipCode,city,personnalPhone,parentsPhone,parentsEmail,school,grade,section,specialTeaching,scholarship,fatherActivity,motherActivity,parentsStatus,dependantsNumber};
// const password: string = this.formGroup.controls.password.value;
// this.registrationService.create(registration, password).pipe(
// mergeMap(() => this.auth.login(registration.email, password)),
// tap(() => this.snackBar.open(
// `Ton compte a été créé ! Tu es maintenant connecté.`,
// 'OK',
// { duration: 3000 },
// )),
// tap(() => this.error = ""),
// tap(() => this.loading = false),
// tap(() => {
// setTimeout(() => {
// this.router.navigate(['./membres'])
// }, 3000)
// })
// ).subscribe(
// () => { },
// (error) => {
// this.loading = false
// if (error.error.email) {
// this.error = "Erreur, cet email est déjà utilisé !"
// }
// }
// );
// // this.personnalDataService.create(personnalData).pipe(
// // tap(() => this.loading = false),
// // tap(() => this.router.navigate(['/'])),
// // ).subscribe(
// // () => {},
// // (error) => this.loading = false,
// // );
// }
// }
export
class
StudentSignupComponent
implements
OnInit
{
export
class
StudentSignupComponent
implements
OnInit
{
registration
:
Registration
;
registration
:
Registration
;
personnalData
:
PersonnalData
;
personnalData
:
PersonnalData
formGroup
:
FormGroup
;
formGroup
:
FormGroup
;
error
:
String
;
error
:
String
;
loading
=
false
;
loading
=
false
;
public
showPersonnalDataForm
=
false
;
public
showPersonnalDataForm
=
false
;
public
zipPattern
=
new
RegExp
(
/^
\d{5}(?:\d{2})?
$/
)
public
zipPattern
=
new
RegExp
(
/^
\d{5}(?:\d{2})?
$/
)
public
possibleParentsStatus
=
[
public
possibleParentsStatus
=
[
{
id
:
"
maried
"
,
name
:
"
Mariés
"
},
{
id
:
"
maried
"
,
name
:
"
Vos parents vivent ensemble
"
},
{
id
:
"
divorced
"
,
name
:
"
Divorcés
"
},
{
id
:
"
cohabitation
"
,
name
:
"
Vos parents vivent séparément
"
},
{
id
:
"
cohabitation
"
,
name
:
"
En concubinage
"
},
{
id
:
"
monoparental
"
,
name
:
"
Vous avez un seul parent
"
}
{
id
:
"
monoparental
"
,
name
:
"
Famille monoparentale
"
}
]
]
public
possibleParentsActivities
=
[
public
possibleParentsActivities
=
[
...
@@ -202,36 +50,29 @@ export class StudentSignupComponent implements OnInit {
...
@@ -202,36 +50,29 @@ export class StudentSignupComponent implements OnInit {
{
id
:
"
echelon6
"
,
name
:
"
Oui, échelon 6
"
},
{
id
:
"
echelon6
"
,
name
:
"
Oui, échelon 6
"
},
{
id
:
"
no
"
,
name
:
"
Non
"
},
{
id
:
"
no
"
,
name
:
"
Non
"
},
]
]
confirmValidParentMatcher
=
new
ConfirmValidParentMatcher
();
//ajouté
errors
=
errorMessages
;
//ajouté
matcher
=
new
PasswordErrorStateMatcher
();
constructor
(
constructor
(
private
registrationService
:
RegistrationService
,
private
registrationService
:
RegistrationService
,
//
private personnalDataService: PersonnalDataService,
private
personnalDataService
:
PersonnalDataService
,
private
formBuilder
:
FormBuilder
,
private
formBuilder
:
FormBuilder
,
private
router
:
Router
,
private
router
:
Router
,
private
auth
:
AuthService
,
private
auth
:
AuthService
,
private
snackBar
:
MatSnackBar
,
private
snackBar
:
MatSnackBar
,
)
{
)
{
}
}
ngOnInit
()
{
ngOnInit
()
{
this
.
createForm
();
this
.
createForm
();
}
}
createForm
()
{
createForm
()
{
this
.
formGroup
=
this
.
formBuilder
.
group
({
this
.
formGroup
=
this
.
formBuilder
.
group
({
firstName
:
''
,
firstName
:
''
,
lastName
:
''
,
lastName
:
''
,
emailGroup
:
this
.
formBuilder
.
group
({
email
:
[
''
,
Validators
.
email
],
email
:
[
''
,
[
Validators
.
required
,
Validators
.
email
]],
confirmEmail
:
[
''
,
Validators
.
required
]
},
{
validator
:
CustomValidators
.
childrenEqual
}),
phoneNumber
:
''
,
phoneNumber
:
''
,
gender
:
''
,
gender
:
''
,
adressNumber
:
''
,
adressNumber
:
''
,
...
@@ -250,20 +91,20 @@ export class StudentSignupComponent implements OnInit {
...
@@ -250,20 +91,20 @@ export class StudentSignupComponent implements OnInit {
motherActivity
:
''
,
motherActivity
:
''
,
parentsStatus
:
''
,
parentsStatus
:
''
,
dependantsNumber
:
''
,
dependantsNumber
:
''
,
passwordGroup
:
this
.
formBuilder
.
group
({
password
:
''
,
password
:
[
''
,
[
passwordConfirm
:
''
,
Validators
.
required
,
// Validators.pattern(regExps.password) /si l'on veut ajouter une condition au mdp (en définissant regExps dans ../core/customValidationModule.ts)
]],
confirmPassword
:
[
''
,
Validators
.
required
]
},
{
validator
:
CustomValidators
.
childrenEqual
}),
agree
:
[
false
,
Validators
.
required
],
agree
:
[
false
,
Validators
.
required
],
filledForm
:
false
,
filledForm
:
false
,
acceptedConditions
:
false
,
acceptedConditions
:
false
,
});
},
{
validator
:
(
group
)
=>
this
.
checkPasswords
(
group
)},)
console
.
log
(
this
.
formGroup
.
value
.
agree
)
}
}
//dernières lignes ajoutées (jusqu'au register):
private
checkPasswords
(
group
:
FormGroup
):
null
|
any
{
const
password
=
group
.
controls
.
password
.
value
;
const
passwordConfirm
=
group
.
controls
.
passwordConfirm
.
value
;
return
password
===
passwordConfirm
?
null
:
{
passwordsDifferent
:
true
};
}
toggleShowPersonnalDataForm
(){
toggleShowPersonnalDataForm
(){
this
.
showPersonnalDataForm
=
!
this
.
showPersonnalDataForm
;
this
.
showPersonnalDataForm
=
!
this
.
showPersonnalDataForm
;
}
}
...
@@ -282,15 +123,13 @@ export class StudentSignupComponent implements OnInit {
...
@@ -282,15 +123,13 @@ export class StudentSignupComponent implements OnInit {
'
OK
'
,
'
OK
'
,
{
duration
:
3000
},
{
duration
:
3000
},
)),
)),
tap
(()
=>
this
.
error
=
""
),
tap
(()
=>
this
.
error
=
""
),
tap
(()
=>
this
.
loading
=
false
),
tap
(()
=>
this
.
loading
=
false
),
tap
(()
=>
{
tap
(()
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
router
.
navigate
([
'
./membres
'
])
this
.
router
.
navigate
([
'
./membres
'
])
},
3000
)
},
3000
)})
})
).
subscribe
(
).
subscribe
(
()
=>
{},
()
=>
{},
...
@@ -303,7 +142,6 @@ export class StudentSignupComponent implements OnInit {
...
@@ -303,7 +142,6 @@ export class StudentSignupComponent implements OnInit {
this
.
error
=
"
Erreur, cet email est déjà utilisé !
"
this
.
error
=
"
Erreur, cet email est déjà utilisé !
"
}
}
}
}
);
);
// this.personnalDataService.create(personnalData).pipe(
// this.personnalDataService.create(personnalData).pipe(
// tap(() => this.loading = false),
// tap(() => this.loading = false),
...
@@ -313,8 +151,4 @@ export class StudentSignupComponent implements OnInit {
...
@@ -313,8 +151,4 @@ export class StudentSignupComponent implements OnInit {
// (error) => this.loading = false,
// (error) => this.loading = false,
// );
// );
}
}
register
():
void
{
// API call to register your user
}
//ajouté (inutile?)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment