1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| private creatSimpleForm() {
this.form = this.formBuilder.group({
city: new FormControl ('', Validators.compose([
Validators.minLength(3),
Validators.maxLength(40),
Validators.pattern('^[a-zA-Zéèàç_.-]+$'),
Validators.required
])),
department: new FormControl ('', Validators.compose([
Validators.minLength(2),
Validators.maxLength(10),
Validators.pattern('^((0[1-9])|([1-8][0-9])|(9[0-8])|(2A)|(2B))[0-9]+$'), // Seuls les lettres A et B sont autorisés (pour les codes postaux de Corse)
])),
creationDate: new FormControl('', Validators.compose([
Validators.minLength(1),
Validators.maxLength(4),
Validators.pattern('-?[0-9]+$'),
])),
destructionDate: new FormControl('', Validators.compose([
Validators.minLength(1),
Validators.maxLength(4),
Validators.pattern('-?[0-9]+$'),
])),
street: new FormControl ('', Validators.compose([
Validators.minLength(1),
Validators.maxLength(255),
Validators.pattern('[0-9]+(?:[A-Za-z0-Zéèçûü9.,\'-]+[ ]?)+') //Exige à l'utilisateur de commencer par le numéro de la voie
])),
lat: new FormControl ('', Validators.compose([
Validators.minLength(0),
Validators.maxLength(255),
Validators.required
])),
lng: new FormControl ('', Validators.compose([
Validators.minLength(0),
Validators.maxLength(255),
Validators.required
])),
comments: new FormControl(''),
mediaDate: new FormControl(this.mediaDate, [Validators.required]),
category: new FormControl(this.category)
});
public onSubmitSimpleForm() {
if (this.files) {
this.uploadService.toBlobFile(this.files).then((result) => {
this.postHouse(this.form.value.city, this.form.value.creationDate, this.form.value.destructionDate,
this.form.value.street, this.form.value.department, {lat: this.lat, lng: this.lng}, this.form.value.comments, result);
});
} else {
this.postHouse(this.form.value.city, this.form.value.creationDate, this.form.value.destructionDate,
this.form.value.street, this.form.value.department, {lat: this.lat, lng: this.lng}, this.form.value.comments);
}
} |