Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client
1 result
Show changes
Commits on Source (11)
Showing
with 175 additions and 76 deletions
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
[userList]="userList" [userList]="userList"
[totalUserResult]="totalUserResult" [totalUserResult]="totalUserResult"
[isLogged]="true" [isLogged]="true"
[filterActive]="filterActive"
(resetEvent)="shouldResetFilters()" (resetEvent)="shouldResetFilters()"
(showMoreEvent)="showMore($event)" (showMoreEvent)="showMore($event)"
></app-result-list> ></app-result-list>
......
...@@ -16,12 +16,18 @@ export class AnnuaireComponent implements OnInit { ...@@ -16,12 +16,18 @@ export class AnnuaireComponent implements OnInit {
public totalUserResult: number; public totalUserResult: number;
public resetFilters: number = 0; public resetFilters: number = 0;
public nextPage: number = 1; public nextPage: number = 1;
public filterActive: boolean = false;
ngOnInit(): void { ngOnInit(): void {
this.getUsers({ queryParam: '', page: 1, jobFilters: [], employerFilter: [] }); this.getUsers({ queryParam: '', page: 1, jobFilters: [], employerFilter: [] });
} }
public getUsers(params: SearchQuery): void { public getUsers(params: SearchQuery): void {
if (this.userIsLoggedIn()) { if (this.userIsLoggedIn()) {
if (params.employerFilter?.length || params.jobFilters.length) {
this.filterActive = true;
} else {
this.filterActive = false;
}
this.searchService this.searchService
.searchUserRegistry(params.queryParam, params.page, params.jobFilters, params.employerFilter) .searchUserRegistry(params.queryParam, params.page, params.jobFilters, params.employerFilter)
.subscribe((res: SearchResults) => { .subscribe((res: SearchResults) => {
......
<div class="results notEmpty" *ngIf="isLogged && userList.length"> <div class="results notEmpty" *ngIf="isLogged && userList.length" [ngClass]="{ filterActive: filterActive }">
<div class="userNumber"> <div class="userNumber">
{{ userList.length }} <span *ngIf="showPagination"> sur {{ totalUserResult }} </span> utilisateurs trouvés {{ userList.length }} <span *ngIf="showPagination"> sur {{ totalUserResult }} </span> utilisateurs trouvés
</div> </div>
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
&.notEmpty { &.notEmpty {
//make sure it fits the correct height no matter the content lengtj and screen height //make sure it fits the correct height no matter the content lengtj and screen height
max-height: calc(100vh - $footer-height - $header-height - $header-height - 2rem); max-height: calc(100vh - $footer-height - $header-height - $header-height - 2rem);
&.filterActive {
max-height: calc(100vh - $footer-height - $header-height - $header-height - 5rem);
}
@media #{$large-phone} { @media #{$large-phone} {
height: 100%; height: 100%;
} }
......
...@@ -13,6 +13,7 @@ export class ResultListComponent implements OnInit, OnChanges { ...@@ -13,6 +13,7 @@ export class ResultListComponent implements OnInit, OnChanges {
@Input() userList: UserAnnuary[]; @Input() userList: UserAnnuary[];
@Input() totalUserResult: number; @Input() totalUserResult: number;
@Input() isLogged: boolean; @Input() isLogged: boolean;
@Input() filterActive: boolean;
@Output() resetEvent = new EventEmitter<any>(); @Output() resetEvent = new EventEmitter<any>();
@Output() showMoreEvent = new EventEmitter<any>(); @Output() showMoreEvent = new EventEmitter<any>();
public maxPerPage: number = 20; public maxPerPage: number = 20;
......
...@@ -17,8 +17,7 @@ ...@@ -17,8 +17,7 @@
.content { .content {
display: flex; display: flex;
align-items: center; align-items: center;
max-width: 980px; margin-bottom: 0.5rem;
margin: 0 auto 0.5rem auto;
input { input {
@include lato-regular-13; @include lato-regular-13;
@include input-search; @include input-search;
...@@ -188,7 +187,7 @@ a { ...@@ -188,7 +187,7 @@ a {
} }
} }
.filterTags { .filterTags {
margin: 0.5rem 0 0 0; margin-top: 0.5rem;
.title { .title {
margin-top: 5px; margin-top: 5px;
color: $grey-3; color: $grey-3;
......
...@@ -171,9 +171,9 @@ export class SearchBarComponent implements OnInit, OnChanges { ...@@ -171,9 +171,9 @@ export class SearchBarComponent implements OnInit, OnChanges {
this.splitFilters(this.checkedFilterList); this.splitFilters(this.checkedFilterList);
this.countCheckedFilters(); this.countCheckedFilters();
this.searchEvent.emit({ this.searchEvent.emit({
queryParam: inputTerm, queryParam: inputTerm || '',
jobFilters: this.jobFilterChecked, jobFilters: this.checkedFilterList.length ? this.jobFilterChecked : [],
employerFilter: this.employerFilterChecked, employerFilter: this.checkedFilterList.length ? this.employerFilterChecked : [],
}); });
} }
} }
...@@ -9,20 +9,18 @@ import { OrientationFormComponent } from './form/orientation-form/orientation-fo ...@@ -9,20 +9,18 @@ import { OrientationFormComponent } from './form/orientation-form/orientation-fo
import { AdminGuard } from './guards/admin.guard'; import { AdminGuard } from './guards/admin.guard';
import { AuthGuard } from './guards/auth.guard'; import { AuthGuard } from './guards/auth.guard';
import { LoginGuard } from './guards/login.guard'; import { LoginGuard } from './guards/login.guard';
import { DeactivateGuard } from './guards/deactivate.guard';
import { LegalNoticeComponent } from './legal-notice/legal-notice.component'; import { LegalNoticeComponent } from './legal-notice/legal-notice.component';
import { LoginComponent } from './login/login.component'; import { LoginComponent } from './login/login.component';
import { NewsletterSubscriptionComponent } from './newsletter-subscription/newsletter-subscription.component'; import { NewsletterSubscriptionComponent } from './newsletter-subscription/newsletter-subscription.component';
import { PageComponent } from './page/page.component'; import { PageComponent } from './page/page.component';
import { EditComponent } from './profile/edit/edit.component';
import { ResetEmailComponent } from './reset-email/reset-email.component'; import { ResetEmailComponent } from './reset-email/reset-email.component';
import { ResetPasswordComponent } from './reset-password/reset-password.component'; import { ResetPasswordComponent } from './reset-password/reset-password.component';
import { StructureResolver } from './resolvers/structure.resolver'; import { StructureResolver } from './resolvers/structure.resolver';
import { PasswordFormComponent } from './shared/components'; import { PasswordFormComponent } from './shared/components';
import { StructureJoinComponent } from './structure/structure-join/structure-join.component';
import { StructureDetailsComponent } from './structure-list/components/structure-details/structure-details.component'; import { StructureDetailsComponent } from './structure-list/components/structure-details/structure-details.component';
import { StructureListComponent } from './structure-list/structure-list.component'; import { StructureListComponent } from './structure-list/structure-list.component';
import { StructureExcludeComponent } from './structure/structure-exclude/structure-exclude.component'; import { StructureExcludeComponent } from './structure/structure-exclude/structure-exclude.component';
import { StructureJoinComponent } from './structure/structure-join/structure-join.component';
const footerOutletRoute: Route = { const footerOutletRoute: Route = {
path: '', path: '',
...@@ -143,12 +141,6 @@ const routes: Routes = [ ...@@ -143,12 +141,6 @@ const routes: Routes = [
canActivate: [AuthGuard], canActivate: [AuthGuard],
loadChildren: () => import('./profile/profile.module').then((m) => m.ProfileModule), loadChildren: () => import('./profile/profile.module').then((m) => m.ProfileModule),
}, },
{
path: 'edit',
canActivate: [AuthGuard],
component: EditComponent,
},
footerOutletRoute,
{ {
path: '', path: '',
outlet: 'left-pane', outlet: 'left-pane',
......
...@@ -17,13 +17,12 @@ import { stepType } from '../step.type'; ...@@ -17,13 +17,12 @@ import { stepType } from '../step.type';
@Component({ @Component({
selector: 'app-footer-form', selector: 'app-footer-form',
templateUrl: './footer-form.component.html', templateUrl: './footer-form.component.html',
styleUrls: ['./footer-form.component.scss'] styleUrls: ['./footer-form.component.scss'],
}) })
export class FooterFormComponent implements OnChanges { export class FooterFormComponent implements OnChanges {
@Input() currentForm: formType; @Input() currentForm: formType;
@Input() isValid: boolean; @Input() isValid: boolean;
@Input() isClaimMode: boolean; @Input() isClaimMode: boolean;
@Input() isAccountMode: boolean;
@Input() btnName: string[]; @Input() btnName: string[];
@Input() nbPagesForm: number; @Input() nbPagesForm: number;
@Input() form: UntypedFormGroup; @Input() form: UntypedFormGroup;
...@@ -74,7 +73,8 @@ export class FooterFormComponent implements OnChanges { ...@@ -74,7 +73,8 @@ export class FooterFormComponent implements OnChanges {
} }
if ( if (
this.currentForm === formType.structure && this.currentForm === formType.structure &&
(this.currentStep === structureFormStep.noStructure || this.currentStep === structureFormStep.StructureInfoUnknown) (this.currentStep === structureFormStep.noStructure ||
this.currentStep === structureFormStep.StructureInfoUnknown)
) { ) {
this.isLastFormStep = true; this.isLastFormStep = true;
} }
...@@ -134,8 +134,11 @@ export class FooterFormComponent implements OnChanges { ...@@ -134,8 +134,11 @@ export class FooterFormComponent implements OnChanges {
const user = new User(this.form.value); const user = new User(this.form.value);
// Create user with structure // Create user with structure
user.structuresLink = this.linkedStructureId; user.structuresLink = this.linkedStructureId;
this.authService.register(user).subscribe(() => {}); this.authService.register(user).subscribe(() => {
this.newsletterService.newsletterSubscribe(user.email).subscribe(() => {}); if (this.acceptNewsletter) {
this.newsletterService.newsletterSubscribe(user.email).subscribe();
}
});
document.getElementsByClassName('page')[0].scrollTo(0, 0); document.getElementsByClassName('page')[0].scrollTo(0, 0);
} }
if (this.isProfileLastPage()) { if (this.isProfileLastPage()) {
...@@ -195,7 +198,9 @@ export class FooterFormComponent implements OnChanges { ...@@ -195,7 +198,9 @@ export class FooterFormComponent implements OnChanges {
private isStructureChoiceValid(): boolean { private isStructureChoiceValid(): boolean {
return ( return (
this.currentForm === formType.structure && this.currentStep === structureFormStep.structureChoice && this.form.value._id this.currentForm === formType.structure &&
this.currentStep === structureFormStep.structureChoice &&
this.form.value._id
); );
} }
...@@ -215,7 +220,8 @@ export class FooterFormComponent implements OnChanges { ...@@ -215,7 +220,8 @@ export class FooterFormComponent implements OnChanges {
private isPersonalOfferpage(): boolean { private isPersonalOfferpage(): boolean {
return ( return (
this.currentForm === formType.personaloffer && this.currentStep === personalOfferFormStep.personalOfferStructureChoice this.currentForm === formType.personaloffer &&
this.currentStep === personalOfferFormStep.personalOfferStructureChoice
); );
} }
public isPersonalOfferFirstPage(): boolean { public isPersonalOfferFirstPage(): boolean {
......
@import '../../../../../assets/scss/color'; @import '../../../../../assets/scss/color';
@import '../../../../../assets/scss/typography'; @import '../../../../../assets/scss/typography';
.disabled {
opacity: 0.4;
cursor: not-allowed;
}
p.special { p.special {
@include lato-regular-14; @include lato-regular-14;
color: $grey-3; color: $grey-3;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<app-account-credentials <app-account-credentials
[accountForm]="accountForm" [accountForm]="accountForm"
[profile]="profile" [profile]="profile"
[isAccountMode]="isAccountMode"
(validateForm)="setValidationsForm($event)" (validateForm)="setValidationsForm($event)"
(userExists)="verifyUserExist($event)" (userExists)="verifyUserExist($event)"
></app-account-credentials> ></app-account-credentials>
......
...@@ -14,8 +14,8 @@ export class AccountFormComponent implements OnChanges { ...@@ -14,8 +14,8 @@ export class AccountFormComponent implements OnChanges {
@Input() nbSteps: number; @Input() nbSteps: number;
@Input() currentStep: accountFormStep; @Input() currentStep: accountFormStep;
@Input() accountForm: UntypedFormGroup; @Input() accountForm: UntypedFormGroup;
@Input() isAccountMode: boolean;
public isClaimMode = false; public isClaimMode = false;
public isAccountMode = false;
public pagesValidation = []; public pagesValidation = [];
public userAcceptSavedDate = false; public userAcceptSavedDate = false;
public isPageValid: boolean; public isPageValid: boolean;
......
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { AuthGuard } from '../../guards/auth.guard'; import { AuthGuard } from '../../guards/auth.guard';
import { DeactivateGuard } from '../../guards/deactivate.guard';
import { RoleGuard } from '../../guards/role.guard'; import { RoleGuard } from '../../guards/role.guard';
import { StructureResolver } from '../../resolvers/structure.resolver'; import { StructureResolver } from '../../resolvers/structure.resolver';
import { TempUserResolver } from '../../resolvers/temp-user.resolver';
import { RouteRole } from '../../shared/enum/routeRole.enum'; import { RouteRole } from '../../shared/enum/routeRole.enum';
import { AccountFormComponent } from './account-form/account-form.component'; import { AccountFormComponent } from './account-form/account-form.component';
import { FormViewComponent } from './form-view.component'; import { FormViewComponent } from './form-view.component';
...@@ -21,9 +23,18 @@ const routes: Routes = [ ...@@ -21,9 +23,18 @@ const routes: Routes = [
structure: StructureResolver, structure: StructureResolver,
}, },
}, },
{
path: 'register/:id',
component: FormViewComponent,
canDeactivate: [DeactivateGuard],
resolve: {
user: TempUserResolver,
},
},
{ {
path: '', path: '',
component: FormViewComponent, component: FormViewComponent,
canDeactivate: [DeactivateGuard],
children: [ children: [
{ {
path: 'structure', path: 'structure',
......
<div class="formView"> <div class="formView">
<app-modal-confirmation
[openned]="showConfirmationModal"
[content]="'Il vous faudra de nouveau remplir le formulaire si vous quittez'"
(closed)="hasRedirectionAccepted($event)"
></app-modal-confirmation>
<app-progress-bar <app-progress-bar
[formType]="formType[routeParam]" [formType]="formType[routeParam]"
[isEditMode]="isEditMode" [isEditMode]="isEditMode"
...@@ -6,12 +11,13 @@ ...@@ -6,12 +11,13 @@
[nbSteps]="nbSteps" [nbSteps]="nbSteps"
></app-progress-bar> ></app-progress-bar>
<div class="page"> <div class="page">
<ng-container *ngIf="formType[routeParam] === formType.account"> <ng-container *ngIf="formType[routeParam] === formType.account || formType[this.routeParam] === formType.register">
<app-account-form <app-account-form
[nbSteps]="nbSteps" [nbSteps]="nbSteps"
[accountForm]="accountForm" [accountForm]="accountForm"
[hoursForm]="hoursForm" [hoursForm]="hoursForm"
[currentStep]="currentPage" [currentStep]="currentPage"
[isAccountMode]="isAccountMode"
(goNext)="nextPage()" (goNext)="nextPage()"
(pageValid)="validatePage($event)" (pageValid)="validatePage($event)"
(acceptNewsletter)="acceptReceiveNewsletter($event)" (acceptNewsletter)="acceptReceiveNewsletter($event)"
...@@ -57,6 +63,7 @@ ...@@ -57,6 +63,7 @@
[currentStep]="currentPage" [currentStep]="currentPage"
[currentForm]="currentFormType" [currentForm]="currentFormType"
[form]="currentForm" [form]="currentForm"
[linkedStructureId]="linkedStructureId"
[btnName]="['Précédent', 'Suivant']" [btnName]="['Précédent', 'Suivant']"
[isValid]="isPageValid" [isValid]="isPageValid"
[acceptNewsletter]="userAcceptNewsletter" [acceptNewsletter]="userAcceptNewsletter"
......
...@@ -24,7 +24,7 @@ import { structureFormStep } from './structure-form/structureFormStep.enum'; ...@@ -24,7 +24,7 @@ import { structureFormStep } from './structure-form/structureFormStep.enum';
@Component({ @Component({
selector: 'app-form-view', selector: 'app-form-view',
templateUrl: './form-view.component.html', templateUrl: './form-view.component.html',
styleUrls: ['./form-view.component.scss'] styleUrls: ['./form-view.component.scss'],
}) })
export class FormViewComponent implements OnInit { export class FormViewComponent implements OnInit {
public routeParam: string; public routeParam: string;
...@@ -62,6 +62,10 @@ export class FormViewComponent implements OnInit { ...@@ -62,6 +62,10 @@ export class FormViewComponent implements OnInit {
public showWebsite: boolean; public showWebsite: boolean;
public showSocialNetwork: boolean; public showSocialNetwork: boolean;
// Modal canExit var
public showConfirmationModal = false;
private resolve: Function;
public profile: User; public profile: User;
public isAccountMode: boolean = false; public isAccountMode: boolean = false;
public isClaimMode: boolean = false; public isClaimMode: boolean = false;
...@@ -71,6 +75,7 @@ export class FormViewComponent implements OnInit { ...@@ -71,6 +75,7 @@ export class FormViewComponent implements OnInit {
public structureWithOwners: StructureWithOwners; public structureWithOwners: StructureWithOwners;
public isPageValid: boolean = false; public isPageValid: boolean = false;
public hoursForm: UntypedFormGroup; public hoursForm: UntypedFormGroup;
public isRegisterNewMember: boolean = false;
constructor( constructor(
private router: Router, private router: Router,
...@@ -87,26 +92,19 @@ export class FormViewComponent implements OnInit { ...@@ -87,26 +92,19 @@ export class FormViewComponent implements OnInit {
this.initPage(); this.initPage();
this.profileService.getProfile().then((user: User) => { this.profileService.getProfile().then((user: User) => {
this.profile = user; this.profile = user;
if (!this.isEditMode && this.profile) {
if (this.profile.structuresLink.length) {
// if register a new user as a new member structure, no structure to choose
this.isRegisterNewMember = true;
this.structureService.getStructure(this.profile.structuresLink[0]).subscribe((structure) => {
this.structure = new Structure(structure);
});
}
}
}); });
// Check if it's a new structure or edit structure // Check if it's a new structure or edit structure
// this.isLoading = false;
if (history.state.newUser) {
this.isClaimMode = true;
// Handle join structure, the case is very similar to claim
if (history.state.isJoin) {
this.isJoinMode = true;
}
this.createAccountForm();
this.claimStructure = history.state.newUser;
}
// Handle account creation when pre-register
this.route.data.subscribe((data) => { this.route.data.subscribe((data) => {
if (data.user) {
this.isAccountMode = true;
this.createAccountForm(data.user.email);
this.linkedStructureId = data.user.pendingStructuresLink;
this.currentPage = accountFormStep.accountInfo;
}
if (data.structure) { if (data.structure) {
this.isEditMode = true; this.isEditMode = true;
this.structure = data.structure; this.structure = data.structure;
...@@ -138,6 +136,19 @@ export class FormViewComponent implements OnInit { ...@@ -138,6 +136,19 @@ export class FormViewComponent implements OnInit {
this.createAccountForm(); this.createAccountForm();
this.currentForm = this.accountForm; this.currentForm = this.accountForm;
} }
if (formType[this.routeParam] === formType.register) {
this.nbSteps = 3;
this.currentPage = accountFormStep.accountInfo;
this.currentFormType = formType.account;
this.route.data.subscribe((data) => {
if (data.user) {
this.createAccountForm(data.user.email);
this.linkedStructureId = data.user.pendingStructuresLink;
this.currentForm = this.accountForm;
this.isAccountMode = true;
}
});
}
if (formType[this.routeParam] === formType.profile) { if (formType[this.routeParam] === formType.profile) {
this.nbSteps = totalFormSteps; this.nbSteps = totalFormSteps;
this.currentPage = profileFormStep.profileBeginningInfo; this.currentPage = profileFormStep.profileBeginningInfo;
...@@ -175,15 +186,21 @@ export class FormViewComponent implements OnInit { ...@@ -175,15 +186,21 @@ export class FormViewComponent implements OnInit {
private createAccountForm(email?: string): void { private createAccountForm(email?: string): void {
this.accountForm = new UntypedFormGroup( this.accountForm = new UntypedFormGroup(
{ {
email: new UntypedFormControl(email ? email : '', [Validators.required, Validators.pattern(CustomRegExp.EMAIL)]), email: new UntypedFormControl(email ? email : '', [
Validators.required,
Validators.pattern(CustomRegExp.EMAIL),
]),
name: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.TEXT_WITHOUT_NUMBER)]), name: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.TEXT_WITHOUT_NUMBER)]),
surname: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.TEXT_WITHOUT_NUMBER)]), surname: new UntypedFormControl('', [
Validators.required,
Validators.pattern(CustomRegExp.TEXT_WITHOUT_NUMBER),
]),
phone: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.PHONE)]), phone: new UntypedFormControl('', [Validators.required, Validators.pattern(CustomRegExp.PHONE)]),
password: new UntypedFormControl('', [ password: new UntypedFormControl('', [
Validators.required, Validators.required,
Validators.pattern(CustomRegExp.PASSWORD) //NOSONAR Validators.pattern(CustomRegExp.PASSWORD), //NOSONAR
]), ]),
confirmPassword: new UntypedFormControl('') confirmPassword: new UntypedFormControl(''),
}, },
[MustMatch('password', 'confirmPassword')] [MustMatch('password', 'confirmPassword')]
); );
...@@ -193,14 +210,14 @@ export class FormViewComponent implements OnInit { ...@@ -193,14 +210,14 @@ export class FormViewComponent implements OnInit {
this.profileForm = new UntypedFormGroup({ this.profileForm = new UntypedFormGroup({
employer: new UntypedFormGroup({ employer: new UntypedFormGroup({
name: new UntypedFormControl('', [Validators.required]), name: new UntypedFormControl('', [Validators.required]),
validated: new UntypedFormControl(false, [Validators.required]) validated: new UntypedFormControl(false, [Validators.required]),
}), }),
job: new UntypedFormGroup({ job: new UntypedFormGroup({
name: new UntypedFormControl('', [Validators.required]), name: new UntypedFormControl('', [Validators.required]),
validated: new UntypedFormControl(true, [Validators.required]), validated: new UntypedFormControl(true, [Validators.required]),
hasPersonalOffer: new UntypedFormControl(true, [Validators.required]) hasPersonalOffer: new UntypedFormControl(true, [Validators.required]),
}), }),
structure: new UntypedFormControl('', [Validators.required]) structure: new UntypedFormControl('', [Validators.required]),
}); });
} }
...@@ -216,7 +233,7 @@ export class FormViewComponent implements OnInit { ...@@ -216,7 +233,7 @@ export class FormViewComponent implements OnInit {
accessRight: new UntypedFormControl(personalOffer.accessRight), accessRight: new UntypedFormControl(personalOffer.accessRight),
digitalCultureSecurity: new UntypedFormControl(personalOffer.digitalCultureSecurity), digitalCultureSecurity: new UntypedFormControl(personalOffer.digitalCultureSecurity),
socialAndProfessional: new UntypedFormControl(personalOffer.socialAndProfessional), socialAndProfessional: new UntypedFormControl(personalOffer.socialAndProfessional),
parentingHelp: new UntypedFormControl(personalOffer.parentingHelp) parentingHelp: new UntypedFormControl(personalOffer.parentingHelp),
}); });
} }
...@@ -316,11 +333,20 @@ export class FormViewComponent implements OnInit { ...@@ -316,11 +333,20 @@ export class FormViewComponent implements OnInit {
profile: this.profileService profile: this.profileService
.updateProfile(this.profileForm.get('employer').value.name, this.profileForm.get('job').value.name) .updateProfile(this.profileForm.get('employer').value.name, this.profileForm.get('job').value.name)
.pipe( .pipe(
map((res) => res), map((res) => (this.profile = res)),
catchError((_e) => of()) catchError((_e) => of())
) ),
}).subscribe(() => { }).subscribe(async () => {
this.router.navigateByUrl('form/structure'); // if register a new user as a new member structure, no structure to choose
if (this.isRegisterNewMember) {
if (this.profile.job && this.profile.job.hasPersonalOffer) {
this.router.navigateByUrl('form/personaloffer');
} else {
this.router.navigateByUrl('/profile');
}
} else {
this.router.navigateByUrl('form/structure');
}
}); });
} }
...@@ -337,8 +363,11 @@ export class FormViewComponent implements OnInit { ...@@ -337,8 +363,11 @@ export class FormViewComponent implements OnInit {
const user = await this.profileService.getProfile(); const user = await this.profileService.getProfile();
const newStructure = new Structure(this.structureForm.value); const newStructure = new Structure(this.structureForm.value);
newStructure.hours = this.hoursForm.value; newStructure.hours = this.hoursForm.value;
if (!this.structureForm.value.freeWorkShop) {
newStructure.freeWorkShop = true;
}
this.structureService.createStructure(newStructure, this.profile).subscribe((struct) => { this.structureService.createStructure(newStructure, this.profile).subscribe((struct) => {
if (user.job.hasPersonalOffer) { if (user.job && user.job.hasPersonalOffer) {
this.structure = struct; this.structure = struct;
this.router.navigateByUrl('form/personaloffer'); this.router.navigateByUrl('form/personaloffer');
} else { } else {
...@@ -348,6 +377,7 @@ export class FormViewComponent implements OnInit { ...@@ -348,6 +377,7 @@ export class FormViewComponent implements OnInit {
} }
public setCurrentStep(step: stepType): void { public setCurrentStep(step: stepType): void {
//THIS PROBABLY CREATES CONSOLE ERRORS NG100 only in dev mode, please refer to https://angular.io/errors/NG0100 for more info //THIS PROBABLY CREATES CONSOLE ERRORS NG100 only in dev mode, please refer to https://angular.io/errors/NG0100 for more info
this.isPageValid = false;
this.currentPage = step; this.currentPage = step;
} }
public async saveEditedStructure() { public async saveEditedStructure() {
...@@ -365,30 +395,30 @@ export class FormViewComponent implements OnInit { ...@@ -365,30 +395,30 @@ export class FormViewComponent implements OnInit {
switch (currentPage) { switch (currentPage) {
case structureFormStep.structureChoice: case structureFormStep.structureChoice:
return { return {
_id: this.structureForm.get('_id').value _id: this.structureForm.get('_id').value,
}; };
case structureFormStep.structureNameAndAddress: case structureFormStep.structureNameAndAddress:
return { return {
structureName: this.structureForm.get('structureName').value, structureName: this.structureForm.get('structureName').value,
address: this.structureForm.get('address').value address: this.structureForm.get('address').value,
}; };
case structureFormStep.structureContact: case structureFormStep.structureContact:
return { return {
contactPhone: this.structureForm.get('contactPhone').value, contactPhone: this.structureForm.get('contactPhone').value,
contactMail: this.structureForm.get('contactMail').value contactMail: this.structureForm.get('contactMail').value,
}; };
case structureFormStep.structureAccessModality: case structureFormStep.structureAccessModality:
return { return {
accessModality: this.structureForm.get('accessModality').value accessModality: this.structureForm.get('accessModality').value,
}; };
case structureFormStep.structureHours: case structureFormStep.structureHours:
return { return {
hours: this.hoursForm.value, hours: this.hoursForm.value,
exceptionalClosures: this.structureForm.get('exceptionalClosures').value exceptionalClosures: this.structureForm.get('exceptionalClosures').value,
}; };
case structureFormStep.structurePmr: case structureFormStep.structurePmr:
return { return {
pmrAccess: this.structureForm.get('pmrAccess').value pmrAccess: this.structureForm.get('pmrAccess').value,
}; };
case structureFormStep.structureWebAndSocialNetwork: case structureFormStep.structureWebAndSocialNetwork:
return { return {
...@@ -396,13 +426,13 @@ export class FormViewComponent implements OnInit { ...@@ -396,13 +426,13 @@ export class FormViewComponent implements OnInit {
instagram: this.structureForm.get('instagram').value, instagram: this.structureForm.get('instagram').value,
linkedin: this.structureForm.get('linkedin').value, linkedin: this.structureForm.get('linkedin').value,
twitter: this.structureForm.get('twitter').value, twitter: this.structureForm.get('twitter').value,
website: this.structureForm.get('website').value website: this.structureForm.get('website').value,
}; };
case structureFormStep.structurePublicTarget: case structureFormStep.structurePublicTarget:
return { publics: this.structureForm.get('publics').value }; return { publics: this.structureForm.get('publics').value };
case structureFormStep.structureDigitalHelpingAccompaniment: case structureFormStep.structureDigitalHelpingAccompaniment:
return { return {
proceduresAccompaniment: this.structureForm.get('proceduresAccompaniment').value proceduresAccompaniment: this.structureForm.get('proceduresAccompaniment').value,
}; };
case structureFormStep.structureTrainingType: case structureFormStep.structureTrainingType:
return { return {
...@@ -410,15 +440,15 @@ export class FormViewComponent implements OnInit { ...@@ -410,15 +440,15 @@ export class FormViewComponent implements OnInit {
baseSkills: this.structureForm.get('baseSkills').value, baseSkills: this.structureForm.get('baseSkills').value,
digitalCultureSecurity: this.structureForm.get('digitalCultureSecurity').value, digitalCultureSecurity: this.structureForm.get('digitalCultureSecurity').value,
parentingHelp: this.structureForm.get('parentingHelp').value, parentingHelp: this.structureForm.get('parentingHelp').value,
socialAndProfessional: this.structureForm.get('socialAndProfessional').value socialAndProfessional: this.structureForm.get('socialAndProfessional').value,
}; };
case structureFormStep.structureTrainingPrice: case structureFormStep.structureTrainingPrice:
return { return {
freeWorkShop: this.structureForm.get('freeWorkShop').value freeWorkShop: this.structureForm.get('freeWorkShop').value,
}; };
case structureFormStep.structureWifi: case structureFormStep.structureWifi:
return { return {
equipmentsAndServices: this.structureForm.get('equipmentsAndServices').value equipmentsAndServices: this.structureForm.get('equipmentsAndServices').value,
}; };
case structureFormStep.structureEquipments: case structureFormStep.structureEquipments:
return { return {
...@@ -426,28 +456,57 @@ export class FormViewComponent implements OnInit { ...@@ -426,28 +456,57 @@ export class FormViewComponent implements OnInit {
nbNumericTerminal: this.structureForm.get('nbNumericTerminal').value, nbNumericTerminal: this.structureForm.get('nbNumericTerminal').value,
nbPrinters: this.structureForm.get('nbPrinters').value, nbPrinters: this.structureForm.get('nbPrinters').value,
nbScanners: this.structureForm.get('nbScanners').value, nbScanners: this.structureForm.get('nbScanners').value,
nbTablets: this.structureForm.get('nbTablets').value nbTablets: this.structureForm.get('nbTablets').value,
}; };
case structureFormStep.structureLabels: case structureFormStep.structureLabels:
return { return {
labelsQualifications: this.structureForm.get('labelsQualifications').value labelsQualifications: this.structureForm.get('labelsQualifications').value,
}; };
case structureFormStep.structureOtherServices: case structureFormStep.structureOtherServices:
return { return {
equipmentsAndServices: this.structureForm.get('equipmentsAndServices').value equipmentsAndServices: this.structureForm.get('equipmentsAndServices').value,
}; };
case structureFormStep.structureDescription: case structureFormStep.structureDescription:
return { return {
description: this.structureForm.get('description').value description: this.structureForm.get('description').value,
}; };
case structureFormStep.structureCovidInfo: case structureFormStep.structureCovidInfo:
return { return {
lockdownActivity: this.structureForm.get('lockdownActivity').value lockdownActivity: this.structureForm.get('lockdownActivity').value,
}; };
case structureFormStep.structureConsent: case structureFormStep.structureConsent:
return { return {
dataShareConsentDate: this.structureForm.get('dataShareConsentDate').value ? new Date().toString() : null dataShareConsentDate: this.structureForm.get('dataShareConsentDate').value ? new Date().toString() : null,
}; };
} }
} }
public canExit(): Promise<boolean> {
// List all exit pages in order to authorise exit
const exitPages: stepType[] = [
structureFormStep.noStructure,
structureFormStep.structureCreationFinishedInfo,
profileFormStep.profileJobSelection,
personalOfferFormStep.personalOfferFinishedInfo,
];
// Avoid confirmation when user submit form and leave.
if (
this.currentPage === this.nbSteps ||
this.currentPage < 1 ||
this.isEditMode ||
exitPages.includes(this.currentPage)
) {
return new Promise((resolve) => resolve(true));
} else {
return new Promise((resolve) => this.showModal(resolve));
}
}
private showModal(resolve: Function): void {
this.showConfirmationModal = true;
this.resolve = resolve;
}
public hasRedirectionAccepted(hasAccept: boolean): void {
this.resolve(hasAccept);
this.showConfirmationModal = false;
}
} }
...@@ -3,4 +3,5 @@ export enum formType { ...@@ -3,4 +3,5 @@ export enum formType {
profile, profile,
personaloffer, personaloffer,
account, account,
register,
} }
...@@ -8,7 +8,11 @@ export class PersonalOfferGuard implements CanActivate { ...@@ -8,7 +8,11 @@ export class PersonalOfferGuard implements CanActivate {
constructor(private router: Router) {} constructor(private router: Router) {}
canActivate(route: ActivatedRouteSnapshot): UrlTree | boolean { canActivate(route: ActivatedRouteSnapshot): UrlTree | boolean {
if (route.routeConfig.path === 'personaloffer' && this.router.routerState.snapshot.url === '/form/structure') { if (
route.routeConfig.path === 'personaloffer' &&
(this.router.routerState.snapshot.url === '/form/profile' ||
this.router.routerState.snapshot.url === '/form/structure')
) {
return true; return true;
} }
return this.router.parseUrl('/home'); return this.router.parseUrl('/home');
......
import { Component, EventEmitter, Input, Output, SimpleChanges } from '@angular/core'; import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms'; import { UntypedFormGroup } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { formType } from '../formType.enum'; import { formType } from '../formType.enum';
...@@ -8,7 +8,7 @@ import { personalOfferFormStep } from './personalOfferFormStep.enum'; ...@@ -8,7 +8,7 @@ import { personalOfferFormStep } from './personalOfferFormStep.enum';
selector: 'app-personal-offer-form', selector: 'app-personal-offer-form',
templateUrl: './personal-offer-form.component.html', templateUrl: './personal-offer-form.component.html',
}) })
export class PersonalOfferFormComponent { export class PersonalOfferFormComponent implements OnChanges {
@Input() nbSteps: number; @Input() nbSteps: number;
@Input() currentStep: personalOfferFormStep; @Input() currentStep: personalOfferFormStep;
@Input() personalOfferForm: UntypedFormGroup; @Input() personalOfferForm: UntypedFormGroup;
......
export class Owner { export class Owner {
email: string; email: string;
_id: string; _id: string;
name: string;
surname: string;
} }
...@@ -2,4 +2,5 @@ export class TempUser { ...@@ -2,4 +2,5 @@ export class TempUser {
_id: string; _id: string;
email: string; email: string;
pendingStructuresLink: string[]; pendingStructuresLink: string[];
updatedAt: string;
} }