Skip to content
Snippets Groups Projects
Commit df810541 authored by Jérémie BRISON's avatar Jérémie BRISON
Browse files

fix(form) : add route form

parent 69a55821
No related branches found
No related tags found
3 merge requests!68Recette,!67Dev,!66Fix/form design create structure
......@@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AboutComponent } from './about/about.component';
import { PanelComponent } from './admin/components/panel/panel.component';
import { FormComponent } from './form/form.component';
import { AdminGuard } from './guards/admin.guard';
import { AuthGuard } from './guards/auth.guard';
import { HomeComponent } from './home/home.component';
......@@ -65,6 +66,10 @@ const routes: Routes = [
canActivate: [AdminGuard],
component: PanelComponent,
},
{
path: 'create-structure',
component: FormComponent,
},
{
path: '**',
redirectTo: 'home',
......
......@@ -8,13 +8,13 @@
$progressBar-height: 50px;
.form {
position: fixed;
background: white;
width: 100vw;
height: calc(100vh - #{$header-height} - #{$footer-height});
top: #{$header-height};
z-index: $structure-details-z-index;
@media #{$tablet} {
position: fixed; //Hide default header app.
height: calc(100vh);
top: 0;
}
......
......@@ -25,7 +25,6 @@ export class FormComponent implements OnInit {
@Input() public idStructure?: string;
@Input() public isEditMode: boolean = true;
@Input() public profile?: User;
@Output() closeEvent = new EventEmitter<Structure>();
public structureForm: FormGroup;
public labelsQualifications: Category;
......@@ -272,34 +271,6 @@ export class FormComponent implements OnInit {
}
return false;
}
public onSubmitClaim(accountForm: FormGroup): void {
if (!this.structureForm.invalid && accountForm.valid) {
this.profileService.createUserandLinkStructure(this.structureId, accountForm.value).subscribe((user) => {
this.closeEvent.emit(this.structureForm.value);
});
}
}
public onSubmitClaimWithAccount(): void {
this.structureService.claimStructureWithAccount(this.structureId, this.profile).subscribe((structuresLinked) => {
this.profile.pendingStructuresLink = structuresLinked;
this.profileService.setProfile(this.profile);
this.closeEvent.emit(this.structureForm.value);
});
}
public onSubmit(structureForm: FormGroup): void {
if (structureForm.valid) {
if (this.structureId) {
this.structureService.editStructure(this.structureId, structureForm.value).subscribe((structure: Structure) => {
this.closeEvent.emit(structure);
});
} else {
this.structureService.createStructure(structureForm.value, this.profile).subscribe((structure: Structure) => {
this.closeEvent.emit(structure);
});
}
}
}
public setValidationsForm(): void {
this.pagesValidation[0] = { valid: true };
......@@ -523,18 +494,18 @@ export class FormComponent implements OnInit {
() => {
this.structureService.createStructure(structure, user).subscribe(
(structure: Structure) => {
this.closeEvent.emit(structure);
this.router.navigateByUrl('/home');
},
(err) => {
this.closeEvent.emit(null);
this.router.navigateByUrl('/home');
}
);
},
(error) => {
if (error.error.statusCode === 400) {
console.log('Compte déjà créé');
this.closeEvent.emit(null);
console.log('Email déjà utilisé');
}
this.router.navigateByUrl('/home');
}
);
} else {
......@@ -543,11 +514,6 @@ export class FormComponent implements OnInit {
console.log(this.hoursForm);
console.log('invalid');
}
/*if (!this.structureForm.invalid && accountForm.valid) {
this.profileService.createUserandLinkStructure(this.structureId, accountForm.value).subscribe((user) => {
this.closeEvent.emit(this.structureForm.value);
});
}*/
}
public toggleMenu(): void {
this.showMenu = !this.showMenu;
......
......@@ -7,4 +7,4 @@ $structure-details-z-index: 1001;
// Modals (filters/confirmationPopup/authen/...)
$modal-z-index: 1002;
$modal-confirmation-z-index: 1003;
$modal-confirmation-z-index: 1004;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment