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 @@
[userList]="userList"
[totalUserResult]="totalUserResult"
[isLogged]="true"
[filterActive]="filterActive"
(resetEvent)="shouldResetFilters()"
(showMoreEvent)="showMore($event)"
></app-result-list>
......
......@@ -16,12 +16,18 @@ export class AnnuaireComponent implements OnInit {
public totalUserResult: number;
public resetFilters: number = 0;
public nextPage: number = 1;
public filterActive: boolean = false;
ngOnInit(): void {
this.getUsers({ queryParam: '', page: 1, jobFilters: [], employerFilter: [] });
}
public getUsers(params: SearchQuery): void {
if (this.userIsLoggedIn()) {
if (params.employerFilter?.length || params.jobFilters.length) {
this.filterActive = true;
} else {
this.filterActive = false;
}
this.searchService
.searchUserRegistry(params.queryParam, params.page, params.jobFilters, params.employerFilter)
.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">
{{ userList.length }} <span *ngIf="showPagination"> sur {{ totalUserResult }} </span> utilisateurs trouvés
</div>
......
......@@ -35,6 +35,9 @@
&.notEmpty {
//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);
&.filterActive {
max-height: calc(100vh - $footer-height - $header-height - $header-height - 5rem);
}
@media #{$large-phone} {
height: 100%;
}
......
......@@ -13,6 +13,7 @@ export class ResultListComponent implements OnInit, OnChanges {
@Input() userList: UserAnnuary[];
@Input() totalUserResult: number;
@Input() isLogged: boolean;
@Input() filterActive: boolean;
@Output() resetEvent = new EventEmitter<any>();
@Output() showMoreEvent = new EventEmitter<any>();
public maxPerPage: number = 20;
......
......@@ -17,8 +17,7 @@
.content {
display: flex;
align-items: center;
max-width: 980px;
margin: 0 auto 0.5rem auto;
margin-bottom: 0.5rem;
input {
@include lato-regular-13;
@include input-search;
......@@ -188,7 +187,7 @@ a {
}
}
.filterTags {
margin: 0.5rem 0 0 0;
margin-top: 0.5rem;
.title {
margin-top: 5px;
color: $grey-3;
......
......@@ -171,9 +171,9 @@ export class SearchBarComponent implements OnInit, OnChanges {
this.splitFilters(this.checkedFilterList);
this.countCheckedFilters();
this.searchEvent.emit({
queryParam: inputTerm,
jobFilters: this.jobFilterChecked,
employerFilter: this.employerFilterChecked,
queryParam: inputTerm || '',
jobFilters: this.checkedFilterList.length ? this.jobFilterChecked : [],
employerFilter: this.checkedFilterList.length ? this.employerFilterChecked : [],
});
}
}
......@@ -9,20 +9,18 @@ import { OrientationFormComponent } from './form/orientation-form/orientation-fo
import { AdminGuard } from './guards/admin.guard';
import { AuthGuard } from './guards/auth.guard';
import { LoginGuard } from './guards/login.guard';
import { DeactivateGuard } from './guards/deactivate.guard';
import { LegalNoticeComponent } from './legal-notice/legal-notice.component';
import { LoginComponent } from './login/login.component';
import { NewsletterSubscriptionComponent } from './newsletter-subscription/newsletter-subscription.component';
import { PageComponent } from './page/page.component';
import { EditComponent } from './profile/edit/edit.component';
import { ResetEmailComponent } from './reset-email/reset-email.component';
import { ResetPasswordComponent } from './reset-password/reset-password.component';
import { StructureResolver } from './resolvers/structure.resolver';
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 { StructureListComponent } from './structure-list/structure-list.component';
import { StructureExcludeComponent } from './structure/structure-exclude/structure-exclude.component';
import { StructureJoinComponent } from './structure/structure-join/structure-join.component';
const footerOutletRoute: Route = {
path: '',
......@@ -143,12 +141,6 @@ const routes: Routes = [
canActivate: [AuthGuard],
loadChildren: () => import('./profile/profile.module').then((m) => m.ProfileModule),
},
{
path: 'edit',
canActivate: [AuthGuard],
component: EditComponent,
},
footerOutletRoute,
{
path: '',
outlet: 'left-pane',
......
......@@ -17,13 +17,12 @@ import { stepType } from '../step.type';
@Component({
selector: 'app-footer-form',
templateUrl: './footer-form.component.html',
styleUrls: ['./footer-form.component.scss']
styleUrls: ['./footer-form.component.scss'],
})
export class FooterFormComponent implements OnChanges {
@Input() currentForm: formType;
@Input() isValid: boolean;
@Input() isClaimMode: boolean;
@Input() isAccountMode: boolean;
@Input() btnName: string[];
@Input() nbPagesForm: number;
@Input() form: UntypedFormGroup;
......@@ -74,7 +73,8 @@ export class FooterFormComponent implements OnChanges {
}
if (
this.currentForm === formType.structure &&
(this.currentStep === structureFormStep.noStructure || this.currentStep === structureFormStep.StructureInfoUnknown)
(this.currentStep === structureFormStep.noStructure ||
this.currentStep === structureFormStep.StructureInfoUnknown)
) {
this.isLastFormStep = true;
}
......@@ -134,8 +134,11 @@ export class FooterFormComponent implements OnChanges {
const user = new User(this.form.value);
// Create user with structure
user.structuresLink = this.linkedStructureId;
this.authService.register(user).subscribe(() => {});
this.newsletterService.newsletterSubscribe(user.email).subscribe(() => {});
this.authService.register(user).subscribe(() => {
if (this.acceptNewsletter) {
this.newsletterService.newsletterSubscribe(user.email).subscribe();
}
});
document.getElementsByClassName('page')[0].scrollTo(0, 0);
}
if (this.isProfileLastPage()) {
......@@ -195,7 +198,9 @@ export class FooterFormComponent implements OnChanges {
private isStructureChoiceValid(): boolean {
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 {
private isPersonalOfferpage(): boolean {
return (
this.currentForm === formType.personaloffer && this.currentStep === personalOfferFormStep.personalOfferStructureChoice
this.currentForm === formType.personaloffer &&
this.currentStep === personalOfferFormStep.personalOfferStructureChoice
);
}
public isPersonalOfferFirstPage(): boolean {
......
@import '../../../../../assets/scss/color';
@import '../../../../../assets/scss/typography';
.disabled {
opacity: 0.4;
cursor: not-allowed;
}
p.special {
@include lato-regular-14;
color: $grey-3;
......
......@@ -11,6 +11,7 @@
<app-account-credentials
[accountForm]="accountForm"
[profile]="profile"
[isAccountMode]="isAccountMode"
(validateForm)="setValidationsForm($event)"
(userExists)="verifyUserExist($event)"
></app-account-credentials>
......
......@@ -14,8 +14,8 @@ export class AccountFormComponent implements OnChanges {
@Input() nbSteps: number;
@Input() currentStep: accountFormStep;
@Input() accountForm: UntypedFormGroup;
@Input() isAccountMode: boolean;
public isClaimMode = false;
public isAccountMode = false;
public pagesValidation = [];
public userAcceptSavedDate = false;
public isPageValid: boolean;
......
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard } from '../../guards/auth.guard';
import { DeactivateGuard } from '../../guards/deactivate.guard';
import { RoleGuard } from '../../guards/role.guard';
import { StructureResolver } from '../../resolvers/structure.resolver';
import { TempUserResolver } from '../../resolvers/temp-user.resolver';
import { RouteRole } from '../../shared/enum/routeRole.enum';
import { AccountFormComponent } from './account-form/account-form.component';
import { FormViewComponent } from './form-view.component';
......@@ -21,9 +23,18 @@ const routes: Routes = [
structure: StructureResolver,
},
},
{
path: 'register/:id',
component: FormViewComponent,
canDeactivate: [DeactivateGuard],
resolve: {
user: TempUserResolver,
},
},
{
path: '',
component: FormViewComponent,
canDeactivate: [DeactivateGuard],
children: [
{
path: 'structure',
......
<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
[formType]="formType[routeParam]"
[isEditMode]="isEditMode"
......@@ -6,12 +11,13 @@
[nbSteps]="nbSteps"
></app-progress-bar>
<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
[nbSteps]="nbSteps"
[accountForm]="accountForm"
[hoursForm]="hoursForm"
[currentStep]="currentPage"
[isAccountMode]="isAccountMode"
(goNext)="nextPage()"
(pageValid)="validatePage($event)"
(acceptNewsletter)="acceptReceiveNewsletter($event)"
......@@ -57,6 +63,7 @@
[currentStep]="currentPage"
[currentForm]="currentFormType"
[form]="currentForm"
[linkedStructureId]="linkedStructureId"
[btnName]="['Précédent', 'Suivant']"
[isValid]="isPageValid"
[acceptNewsletter]="userAcceptNewsletter"
......
......@@ -24,7 +24,7 @@ import { structureFormStep } from './structure-form/structureFormStep.enum';
@Component({
selector: 'app-form-view',
templateUrl: './form-view.component.html',
styleUrls: ['./form-view.component.scss']
styleUrls: ['./form-view.component.scss'],
})
export class FormViewComponent implements OnInit {
public routeParam: string;
......@@ -62,6 +62,10 @@ export class FormViewComponent implements OnInit {
public showWebsite: boolean;
public showSocialNetwork: boolean;
// Modal canExit var
public showConfirmationModal = false;
private resolve: Function;
public profile: User;
public isAccountMode: boolean = false;
public isClaimMode: boolean = false;
......@@ -71,6 +75,7 @@ export class FormViewComponent implements OnInit {
public structureWithOwners: StructureWithOwners;
public isPageValid: boolean = false;
public hoursForm: UntypedFormGroup;
public isRegisterNewMember: boolean = false;
constructor(
private router: Router,
......@@ -87,26 +92,19 @@ export class FormViewComponent implements OnInit {
this.initPage();
this.profileService.getProfile().then((user: 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
// 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) => {
if (data.user) {
this.isAccountMode = true;
this.createAccountForm(data.user.email);
this.linkedStructureId = data.user.pendingStructuresLink;
this.currentPage = accountFormStep.accountInfo;
}
if (data.structure) {
this.isEditMode = true;
this.structure = data.structure;
......@@ -138,6 +136,19 @@ export class FormViewComponent implements OnInit {
this.createAccountForm();
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) {
this.nbSteps = totalFormSteps;
this.currentPage = profileFormStep.profileBeginningInfo;
......@@ -175,15 +186,21 @@ export class FormViewComponent implements OnInit {
private createAccountForm(email?: string): void {
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)]),
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)]),
password: new UntypedFormControl('', [
Validators.required,
Validators.pattern(CustomRegExp.PASSWORD) //NOSONAR
Validators.pattern(CustomRegExp.PASSWORD), //NOSONAR
]),
confirmPassword: new UntypedFormControl('')
confirmPassword: new UntypedFormControl(''),
},
[MustMatch('password', 'confirmPassword')]
);
......@@ -193,14 +210,14 @@ export class FormViewComponent implements OnInit {
this.profileForm = new UntypedFormGroup({
employer: new UntypedFormGroup({
name: new UntypedFormControl('', [Validators.required]),
validated: new UntypedFormControl(false, [Validators.required])
validated: new UntypedFormControl(false, [Validators.required]),
}),
job: new UntypedFormGroup({
name: new UntypedFormControl('', [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 {
accessRight: new UntypedFormControl(personalOffer.accessRight),
digitalCultureSecurity: new UntypedFormControl(personalOffer.digitalCultureSecurity),
socialAndProfessional: new UntypedFormControl(personalOffer.socialAndProfessional),
parentingHelp: new UntypedFormControl(personalOffer.parentingHelp)
parentingHelp: new UntypedFormControl(personalOffer.parentingHelp),
});
}
......@@ -316,11 +333,20 @@ export class FormViewComponent implements OnInit {
profile: this.profileService
.updateProfile(this.profileForm.get('employer').value.name, this.profileForm.get('job').value.name)
.pipe(
map((res) => res),
map((res) => (this.profile = res)),
catchError((_e) => of())
)
}).subscribe(() => {
this.router.navigateByUrl('form/structure');
),
}).subscribe(async () => {
// 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 {
const user = await this.profileService.getProfile();
const newStructure = new Structure(this.structureForm.value);
newStructure.hours = this.hoursForm.value;
if (!this.structureForm.value.freeWorkShop) {
newStructure.freeWorkShop = true;
}
this.structureService.createStructure(newStructure, this.profile).subscribe((struct) => {
if (user.job.hasPersonalOffer) {
if (user.job && user.job.hasPersonalOffer) {
this.structure = struct;
this.router.navigateByUrl('form/personaloffer');
} else {
......@@ -348,6 +377,7 @@ export class FormViewComponent implements OnInit {
}
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.isPageValid = false;
this.currentPage = step;
}
public async saveEditedStructure() {
......@@ -365,30 +395,30 @@ export class FormViewComponent implements OnInit {
switch (currentPage) {
case structureFormStep.structureChoice:
return {
_id: this.structureForm.get('_id').value
_id: this.structureForm.get('_id').value,
};
case structureFormStep.structureNameAndAddress:
return {
structureName: this.structureForm.get('structureName').value,
address: this.structureForm.get('address').value
address: this.structureForm.get('address').value,
};
case structureFormStep.structureContact:
return {
contactPhone: this.structureForm.get('contactPhone').value,
contactMail: this.structureForm.get('contactMail').value
contactMail: this.structureForm.get('contactMail').value,
};
case structureFormStep.structureAccessModality:
return {
accessModality: this.structureForm.get('accessModality').value
accessModality: this.structureForm.get('accessModality').value,
};
case structureFormStep.structureHours:
return {
hours: this.hoursForm.value,
exceptionalClosures: this.structureForm.get('exceptionalClosures').value
exceptionalClosures: this.structureForm.get('exceptionalClosures').value,
};
case structureFormStep.structurePmr:
return {
pmrAccess: this.structureForm.get('pmrAccess').value
pmrAccess: this.structureForm.get('pmrAccess').value,
};
case structureFormStep.structureWebAndSocialNetwork:
return {
......@@ -396,13 +426,13 @@ export class FormViewComponent implements OnInit {
instagram: this.structureForm.get('instagram').value,
linkedin: this.structureForm.get('linkedin').value,
twitter: this.structureForm.get('twitter').value,
website: this.structureForm.get('website').value
website: this.structureForm.get('website').value,
};
case structureFormStep.structurePublicTarget:
return { publics: this.structureForm.get('publics').value };
case structureFormStep.structureDigitalHelpingAccompaniment:
return {
proceduresAccompaniment: this.structureForm.get('proceduresAccompaniment').value
proceduresAccompaniment: this.structureForm.get('proceduresAccompaniment').value,
};
case structureFormStep.structureTrainingType:
return {
......@@ -410,15 +440,15 @@ export class FormViewComponent implements OnInit {
baseSkills: this.structureForm.get('baseSkills').value,
digitalCultureSecurity: this.structureForm.get('digitalCultureSecurity').value,
parentingHelp: this.structureForm.get('parentingHelp').value,
socialAndProfessional: this.structureForm.get('socialAndProfessional').value
socialAndProfessional: this.structureForm.get('socialAndProfessional').value,
};
case structureFormStep.structureTrainingPrice:
return {
freeWorkShop: this.structureForm.get('freeWorkShop').value
freeWorkShop: this.structureForm.get('freeWorkShop').value,
};
case structureFormStep.structureWifi:
return {
equipmentsAndServices: this.structureForm.get('equipmentsAndServices').value
equipmentsAndServices: this.structureForm.get('equipmentsAndServices').value,
};
case structureFormStep.structureEquipments:
return {
......@@ -426,28 +456,57 @@ export class FormViewComponent implements OnInit {
nbNumericTerminal: this.structureForm.get('nbNumericTerminal').value,
nbPrinters: this.structureForm.get('nbPrinters').value,
nbScanners: this.structureForm.get('nbScanners').value,
nbTablets: this.structureForm.get('nbTablets').value
nbTablets: this.structureForm.get('nbTablets').value,
};
case structureFormStep.structureLabels:
return {
labelsQualifications: this.structureForm.get('labelsQualifications').value
labelsQualifications: this.structureForm.get('labelsQualifications').value,
};
case structureFormStep.structureOtherServices:
return {
equipmentsAndServices: this.structureForm.get('equipmentsAndServices').value
equipmentsAndServices: this.structureForm.get('equipmentsAndServices').value,
};
case structureFormStep.structureDescription:
return {
description: this.structureForm.get('description').value
description: this.structureForm.get('description').value,
};
case structureFormStep.structureCovidInfo:
return {
lockdownActivity: this.structureForm.get('lockdownActivity').value
lockdownActivity: this.structureForm.get('lockdownActivity').value,
};
case structureFormStep.structureConsent:
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 {
profile,
personaloffer,
account,
register,
}
......@@ -8,7 +8,11 @@ export class PersonalOfferGuard implements CanActivate {
constructor(private router: Router) {}
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 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 { Router } from '@angular/router';
import { formType } from '../formType.enum';
......@@ -8,7 +8,7 @@ import { personalOfferFormStep } from './personalOfferFormStep.enum';
selector: 'app-personal-offer-form',
templateUrl: './personal-offer-form.component.html',
})
export class PersonalOfferFormComponent {
export class PersonalOfferFormComponent implements OnChanges {
@Input() nbSteps: number;
@Input() currentStep: personalOfferFormStep;
@Input() personalOfferForm: UntypedFormGroup;
......
export class Owner {
email: string;
_id: string;
name: string;
surname: string;
}
......@@ -2,4 +2,5 @@ export class TempUser {
_id: string;
email: string;
pendingStructuresLink: string[];
updatedAt: string;
}