From df8105410443943feb0d53126585645b2926a9de Mon Sep 17 00:00:00 2001 From: Jeremie BRISON <ext.sopra.jbrison@grandlyon.com> Date: Mon, 1 Feb 2021 16:41:11 +0100 Subject: [PATCH] fix(form) : add route form --- src/app/app-routing.module.ts | 5 ++++ src/app/form/form.component.scss | 2 +- src/app/form/form.component.ts | 42 +++----------------------------- src/assets/scss/_z-index.scss | 2 +- 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index e28cd3efb..9f1d05bcf 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -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', diff --git a/src/app/form/form.component.scss b/src/app/form/form.component.scss index 3f8400e30..20530c214 100644 --- a/src/app/form/form.component.scss +++ b/src/app/form/form.component.scss @@ -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; } diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index cafe0f037..2b3cbecc9 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -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; diff --git a/src/assets/scss/_z-index.scss b/src/assets/scss/_z-index.scss index adcaa8f7a..18c12fc2c 100644 --- a/src/assets/scss/_z-index.scss +++ b/src/assets/scss/_z-index.scss @@ -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; -- GitLab