diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 54eae011826b429c49877e3ceb093d84ed45e7ce..9b9e30d8dfb4bd5da2cb07181a97530b66c25292 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,6 @@ import { Component } from '@angular/core'; +import { ProfileService } from './profile/services/profile.service'; +import { AuthService } from './services/auth.service'; import { PrintService } from './shared/service/print.service'; @Component({ @@ -9,5 +11,13 @@ import { PrintService } from './shared/service/print.service'; export class AppComponent { title = 'pamn'; - constructor(public printService: PrintService) {} + constructor( + public printService: PrintService, + private authService: AuthService, + private profilService: ProfileService + ) { + if (this.authService.isLoggedIn()) { + this.profilService.getProfile(); + } + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1a02174b10116efa3ecd4d721e85175b3d4acd57..b412fc8acc7babcee6a1dff913ead669fb3e960e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -43,7 +43,6 @@ import { ResetPasswordComponent } from './reset-password/reset-password.componen LegalNoticeComponent, AboutComponent, MenuPhoneComponent, - FormComponent, UserVerificationComponent, ResetEmailComponent, ResetPasswordComponent, diff --git a/src/app/form/form.component.html b/src/app/form/form.component.html index 7d4eae8956ce7bc4b18ced1eed48be9fa9242917..e662a3d76d6a81059aec8aeb5d30337f1ec6ad8a 100644 --- a/src/app/form/form.component.html +++ b/src/app/form/form.component.html @@ -35,8 +35,9 @@ </label> </div> </div> - <p>Description</p> + <p>Description*</p> <textarea rows="4" style="width: 100%" maxlength="500" formControlName="description"></textarea> + <app-validator-form [control]="getStructureControl('description')"></app-validator-form> <p> Afin de rendre visible l'offre de formation numérique proposée lors de ce nouveau confinement, merci d'indiquer ici, les activités que vous avez pu maintenir @@ -77,9 +78,6 @@ <input type="text" formControlName="contactName" /> <p>Prénom</p> <input type="text" formControlName="contactSurname" /> - <p>Courriel*</p> - <input type="email" formControlName="contactMail" /> - <app-validator-form [control]="getStructureControl('contactMail')"></app-validator-form> <p>Fonction</p> <select formControlName="fonction"> <option value="">---Sélectionner---</option> diff --git a/src/app/form/form.component.ts b/src/app/form/form.component.ts index 85485bd4aa1ac94ef055186ac04ec345fecac4ee..dedb2ae2baa74350d9c3283dfbfdb5d4f757ce80 100644 --- a/src/app/form/form.component.ts +++ b/src/app/form/form.component.ts @@ -11,6 +11,7 @@ import { EquipmentAccess } from '../shared/enum/equipmentAccess.enum'; import { WeekDayEnum } from '../shared/enum/weekDay.enum'; import { typeStructureEnum } from '../shared/enum/typeStructure.enum'; import { FonctionContactEnum } from '../shared/enum/fonctionContact.enum'; +import { User } from '../models/user.model'; @Component({ selector: 'app-structureForm', @@ -18,7 +19,8 @@ import { FonctionContactEnum } from '../shared/enum/fonctionContact.enum'; styleUrls: ['./form.component.scss'], }) export class FormComponent implements OnInit { - @Input() public idStructure: number; + @Input() public idStructure?: number; + @Input() public profile?: User; @Output() closeEvent = new EventEmitter<Structure>(); public structureForm: FormGroup; public equipmentAccess = EquipmentAccess; @@ -36,10 +38,14 @@ export class FormComponent implements OnInit { constructor(private structureService: StructureService, private searchService: SearchService) {} ngOnInit(): void { - this.structureService.getStructure(this.idStructure).subscribe((structure) => { - this.initForm(structure); - this.structureId = structure.id; - }); + if (this.idStructure) { + this.structureService.getStructure(this.idStructure).subscribe((structure) => { + this.initForm(structure); + this.structureId = structure.id; + }); + } else { + this.initForm(new Structure()); + } this.searchService.getCategoriesAccompaniment().subscribe((categories: Category[]) => { this.proceduresAccompaniment = categories[0]; }); @@ -77,10 +83,12 @@ export class FormComponent implements OnInit { private initForm(structure: Structure): void { // Init form this.structureForm = new FormGroup({ + id: new FormControl(structure.id), + coord: new FormControl(structure.coord), structureType: this.loadArrayForCheckbox(structure.structureType, true), structureName: new FormControl(structure.structureName, Validators.required), structureRepresentation: new FormControl(structure.structureRepresentation, Validators.required), - description: new FormControl(structure.description), + description: new FormControl(structure.description, Validators.required), lockdownActivity: new FormControl(structure.lockdownActivity), address: new FormGroup({ numero: new FormControl(structure.address.numero), @@ -222,12 +230,21 @@ export class FormComponent implements OnInit { } public onSubmit(structureForm: FormGroup): void { if (structureForm.valid) { - this.structureService.postStructure(this.structureId, structureForm.value).subscribe( - (structure: Structure) => { - this.closeEvent.emit(structure); - }, - (err) => {} - ); + if (this.structureId) { + this.structureService.postStructure(this.structureId, structureForm.value).subscribe( + (structure: Structure) => { + this.closeEvent.emit(structure); + }, + (err) => {} + ); + } else { + this.structureService.createStructure(structureForm.value, this.profile).subscribe( + (structure: Structure) => { + this.closeEvent.emit(structure); + }, + (err) => {} + ); + } } else { } } diff --git a/src/app/map/components/map.component.scss b/src/app/map/components/map.component.scss index a0b56f0dc94c670afc6542e44726f9432d31257b..de50ff0b1c4d79a19e525aba1c04afd18c95f8df 100644 --- a/src/app/map/components/map.component.scss +++ b/src/app/map/components/map.component.scss @@ -27,29 +27,38 @@ ::ng-deep .leaflet-popup-close-button { display: none; } - +::ng-deep .leaflet-bar-part-single { + &:hover { + .fa-map-marker { + background-color: $blue-hover; + } + } + &:active { + .fa-map-marker { + background-color: $blue-active; + } + } +} ::ng-deep .fa-map-marker { - color: $black; position: absolute; - width: 12px; - height: 12px; - border: solid 1px currentColor; - border-radius: 7px 7px 7px 0; + width: 18px; + height: 18px; + border-radius: 50% 50% 50% 0; -webkit-transform: rotate(-45deg); transform: rotate(-45deg); - margin-left: -6px; - margin-top: 6px; -} - -::ng-deep .fa-map-marker:before { - content: ''; - position: absolute; - left: 3px; - top: 3px; - width: 4px; - height: 4px; - border: solid 1px currentColor; - border-radius: 3px; + background-color: $grey-3; + margin-left: -8px; + margin-top: 4px; + &:before { + content: ''; + position: absolute; + left: 5px; + top: 6px; + width: 7px; + height: 7px; + border-radius: 4px; + background-color: $white; + } } ::ng-deep .leaflet-control-locate-circle { @@ -82,6 +91,7 @@ ::ng-deep .leaflet-popup { border-radius: 6px; @include background-hash; + border: 1px solid $grey-4; padding: 0 0 4px 4px; bottom: -15px !important; h1 { @@ -110,7 +120,6 @@ ::ng-deep .leaflet-popup-content-wrapper { box-shadow: unset; border-radius: 6px; - border: 1px solid $grey-4; } ::ng-deep .leaflet-popup-content { width: 240px; diff --git a/src/app/map/components/map.component.ts b/src/app/map/components/map.component.ts index e8b0b1cc58598276b72881e1b669507ff117c014..4b2abe9c3efeeee10550f033dd23a37c640b1a46 100644 --- a/src/app/map/components/map.component.ts +++ b/src/app/map/components/map.component.ts @@ -69,9 +69,11 @@ export class MapComponent implements OnChanges { // Handle map marker tooltip if (changes.toogleToolTipId && changes.toogleToolTipId.currentValue !== changes.toogleToolTipId.previousValue) { if (changes.toogleToolTipId.previousValue !== undefined) { - this.mapService.toogleToolTip(changes.toogleToolTipId.previousValue); + this.mapService.setUnactiveMarker(changes.toogleToolTipId.previousValue); + } + if (changes.toogleToolTipId.currentValue !== undefined) { + this.mapService.setActiveMarker(changes.toogleToolTipId.currentValue); } - this.mapService.toogleToolTip(changes.toogleToolTipId.currentValue); } // Handle map marker selection if (changes.selectedMarkerId && this.map) { @@ -232,15 +234,6 @@ export class MapComponent implements OnChanges { }); } - /** - * Toogle all tooltips given in parameters - */ - public toggleToolTip(ids: Array<number>): void { - ids.forEach((id) => { - this.mapService.toogleToolTip(id); - }); - } - private centerLeafletMapOnMarker(markerId: number): void { const marker = this.mapService.getMarker(markerId); const latLngs = [marker.getLatLng()]; diff --git a/src/app/map/services/map.service.ts b/src/app/map/services/map.service.ts index 58594ff2388e9a06ffeb01abbb29ad578f4f45f6..eb7143fdc1b7666a997db978e9f0a210d0646b5f 100644 --- a/src/app/map/services/map.service.ts +++ b/src/app/map/services/map.service.ts @@ -8,6 +8,7 @@ import { MarkerType } from '../components/markerType.enum'; }) export class MapService { private static markersList = {}; + private isMarkerActive = false; public markerIconHover = divIcon({ className: null, html: '<svg width="40" height="46"><use xlink:href="assets/ico/sprite.svg#map-marker-locate"></use></svg>', @@ -15,6 +16,13 @@ export class MapService { iconAnchor: [20, 46], popupAnchor: [0, -46], }); + public markerIconActive = divIcon({ + className: null, + html: '<svg width="40" height="46" fill="#d50000"><use xlink:href="assets/ico/sprite.svg#map-marker"></use></svg>', + iconSize: [40, 46], + iconAnchor: [20, 46], + popupAnchor: [0, -46], + }); public markerIcon = divIcon({ className: null, html: @@ -96,13 +104,18 @@ export class MapService { } /** - * Toogle a tooltip * @param id marker id */ - public toogleToolTip(id: number): void { - if (id) { - this.getMarker(id).togglePopup(); + public setActiveMarker(id: number): void { + this.getMarker(id).setIcon(this.getMarkerIconHover(MarkerType.structure)); + } + + public setUnactiveMarker(id: number): void { + // To skip mouseleave when user emit click on structure list + if (!this.isMarkerActive) { + this.getMarker(id).setIcon(this.getMarkerIcon(MarkerType.structure)); } + this.isMarkerActive = false; } /** @@ -121,7 +134,8 @@ export class MapService { */ public setSelectedMarker(id: number): void { if (id) { - this.getMarker(id).setIcon(this.markerIconHover); + this.getMarker(id).setIcon(this.markerIconActive); + this.isMarkerActive = true; } } diff --git a/src/app/models/address.model.ts b/src/app/models/address.model.ts index 185be31968d9f84d366f051d29ff35984313f08d..d04d83abedde79b20dbf1d7ae484d34c5e4c4b57 100644 --- a/src/app/models/address.model.ts +++ b/src/app/models/address.model.ts @@ -1,5 +1,5 @@ export class Address { - numero: string; - street: string; - commune: string; + numero: string = null; + street: string = null; + commune: string = null; } diff --git a/src/app/models/day.model.ts b/src/app/models/day.model.ts index 122b812db74a4c566559fd0cadf6fb9b880790b7..005ccfa242ebb935a533cd0d2f151dded3377e1f 100644 --- a/src/app/models/day.model.ts +++ b/src/app/models/day.model.ts @@ -1,12 +1,12 @@ import { Time } from './time.model'; export class Day { - open: boolean; + open: boolean = false; time: Time[]; constructor(obj?: any) { Object.assign(this, obj, { - time: obj && obj.time ? obj.time.map((time) => new Time(time)) : null, + time: obj && obj.time ? obj.time.map((time) => new Time(time)) : [], }); } } diff --git a/src/app/models/openingDay.model.ts b/src/app/models/openingDay.model.ts index 5e286fe22705037afc1956df73c75136f1726936..71ba8d444c97b55c4393830dfa483caf5cff4845 100644 --- a/src/app/models/openingDay.model.ts +++ b/src/app/models/openingDay.model.ts @@ -1,8 +1,8 @@ export class OpeningDay { - day: string; - schedule: string; + day: string = null; + schedule: string = null; - constructor(day: string, schedule: string) { + constructor(day?: string, schedule?: string) { this.day = day; this.schedule = schedule; } diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index 7d2708fb0294682893f9b14b0d3bfb2afa9dc008..060157da0e8a2c3fd81015334e74747cc7d12943 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -1,60 +1,61 @@ +import { WebElement } from 'protractor'; import { Weekday } from '../structure-list/enum/weekday.enum'; import { Address } from './address.model'; import { Day } from './day.model'; import { OpeningDay } from './openingDay.model'; import { Week } from './week.model'; export class Structure { - public id: number; - public numero: string; - public createdAt: string; - public updatedAt: string; - public structureRepresentation: string; - public structureName: string; - public structureType: string[]; - public description: string; - public address: Address; - public contactPhone: string; - public contactMail: string; - public website: string; - public facebook: string; - public twitter: string; - public instagram: string; - public gender: string; - public contactName: string; - public contactSurname: string; - public fonction: string; - public lockdownActivity: string; - public pmrAccess: boolean; - public publicsAccompaniment: string[]; - public proceduresAccompaniment: string[]; - public accessModality: string[]; - public documentsMeeting: string; - public labelsQualifications: string[]; - public publics: string[]; - public nbComputers: number; - public nbPrinters: number; - public nbTablets: number; - public nbNumericTerminal: number; - public exceptionalClosures: string; - public equipmentsAndServices: string[]; + public id: number = null; + public numero: string = null; + public createdAt: string = null; + public updatedAt: string = null; + public structureRepresentation: string = null; + public structureName: string = null; + public structureType: string[] = []; + public description: string = null; + public address: Address = new Address(); + public contactPhone: string = null; + public contactMail: string = null; + public website: string = null; + public facebook: string = null; + public twitter: string = null; + public instagram: string = null; + public gender: string = null; + public contactName: string = null; + public contactSurname: string = null; + public fonction: string = null; + public lockdownActivity: string = null; + public pmrAccess: boolean = false; + public publicsAccompaniment: string[] = []; + public proceduresAccompaniment: string[] = []; + public accessModality: string[] = []; + public documentsMeeting: string = null; + public labelsQualifications: string[] = []; + public publics: string[] = []; + public nbComputers: number = null; + public nbPrinters: number = null; + public nbTablets: number = null; + public nbNumericTerminal: number = null; + public exceptionalClosures: string = null; + public equipmentsAndServices: string[] = []; public hours: Week; - public equipmentsDetails: string; - public equipmentsAccessType: string[]; + public equipmentsDetails: string = null; + public equipmentsAccessType: string[] = []; - public isOpen: boolean; - public openedOn: OpeningDay; - public baseSkills: string[]; - public accessRight: string[]; - public parentingHelp: string[]; - public socialAndProfessional: string[]; - public digitalCultureSecurity: string[]; + public isOpen: boolean = false; + public openedOn: OpeningDay = new OpeningDay(); + public baseSkills: string[] = []; + public accessRight: string[] = []; + public parentingHelp: string[] = []; + public socialAndProfessional: string[] = []; + public digitalCultureSecurity: string[] = []; public distance?: number; - public coord?: number[]; + public coord?: number[] = []; constructor(obj?: any) { Object.assign(this, obj, { - hours: obj && obj.hours ? new Week(obj.hours) : null, + hours: obj && obj.hours ? new Week(obj.hours) : new Week(), }); } diff --git a/src/app/models/user.model.ts b/src/app/models/user.model.ts index aa2391853d058ee08bd800715ec4bd620220678b..a60ee2247268e621cfe6a30259a4603c4d9fdd93 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -5,4 +5,5 @@ export class User { emailVerified: boolean; role: number; validationToken: string; + structuresLink: number[]; } diff --git a/src/app/models/week.model.ts b/src/app/models/week.model.ts index b2176e78550122b9bfbffa04905700122b54080b..742c749d8c8ae7df37c1f2c1876dd84572888b5f 100644 --- a/src/app/models/week.model.ts +++ b/src/app/models/week.model.ts @@ -11,13 +11,13 @@ export class Week { constructor(obj?: any) { Object.assign(this, obj, { - monday: obj && obj.monday ? new Day(obj.monday) : null, - tuesday: obj && obj.tuesday ? new Day(obj.tuesday) : null, - wednesday: obj && obj.wednesday ? new Day(obj.wednesday) : null, - thursday: obj && obj.thursday ? new Day(obj.thursday) : null, - friday: obj && obj.friday ? new Day(obj.friday) : null, - saturday: obj && obj.saturday ? new Day(obj.saturday) : null, - sunday: obj && obj.sunday ? new Day(obj.sunday) : null, + monday: obj && obj.monday ? new Day(obj.monday) : new Day(), + tuesday: obj && obj.tuesday ? new Day(obj.tuesday) : new Day(), + wednesday: obj && obj.wednesday ? new Day(obj.wednesday) : new Day(), + thursday: obj && obj.thursday ? new Day(obj.thursday) : new Day(), + friday: obj && obj.friday ? new Day(obj.friday) : new Day(), + saturday: obj && obj.saturday ? new Day(obj.saturday) : new Day(), + sunday: obj && obj.sunday ? new Day(obj.sunday) : new Day(), }); } diff --git a/src/app/profile/profile.component.html b/src/app/profile/profile.component.html index d85790c5f574a43b2182dc6fd633eb638e176910..7e26fd2292017a79dfa4a9c57e9f7e8878a43b21 100644 --- a/src/app/profile/profile.component.html +++ b/src/app/profile/profile.component.html @@ -4,6 +4,7 @@ <div *ngIf="userProfile" fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10px"> <p>Id: {{ userProfile._id }}</p> <p>Email: {{ userProfile.email }}</p> + <button (click)="toogleAddStructure()">Ajouter une structure</button> <button (click)="toogleChangeEmail()">Changer d'email</button> <form *ngIf="changeEmail" @@ -77,4 +78,10 @@ </form> </div> </div> + <app-structureForm + *ngIf="addStructure" + [profile]="userProfile" + (closeEvent)="toogleAddStructure($event)" + (clickOutside)="toogleAddStructure()" + ></app-structureForm> </div> diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index f9183d465112cc9c5ee38ce693646df618ba93ee..e340e7e7078ec4372d84c13961c1f8394f6d4bc1 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { Structure } from '../models/structure.model'; import { User } from '../models/user.model'; import { MustMatch } from '../shared/validator/form'; import { ProfileService } from './services/profile.service'; @@ -17,11 +18,12 @@ export class ProfileComponent implements OnInit { public loading = false; public changeEmail = false; public formEmail: FormGroup; + public addStructure = false; constructor(private formBuilder: FormBuilder, private profileService: ProfileService) {} ngOnInit(): void { - this.profileService.getProfile().subscribe((profile) => { + this.profileService.getProfile().then((profile) => { this.userProfile = profile; }); this.initForm(); @@ -55,6 +57,9 @@ export class ProfileComponent implements OnInit { public toogleChangePassword(): void { this.changePassword = !this.changePassword; } + public toogleAddStructure(): void { + this.addStructure = !this.addStructure; + } public toogleChangeEmail(): void { this.changeEmail = !this.changeEmail; diff --git a/src/app/profile/profile.module.ts b/src/app/profile/profile.module.ts index a9427003f2507d4092e966617363aa223996b4f5..1f86c78ac628b6b082a4fcc81f6eead59e0b8e92 100644 --- a/src/app/profile/profile.module.ts +++ b/src/app/profile/profile.module.ts @@ -3,10 +3,11 @@ import { ProfileComponent } from './profile.component'; import { SharedModule } from '../shared/shared.module'; import { CommonModule } from '@angular/common'; import { BrowserModule } from '@angular/platform-browser'; +import { FormComponent } from '../form/form.component'; @NgModule({ imports: [CommonModule, BrowserModule, SharedModule], - declarations: [ProfileComponent], - exports: [ProfileComponent], + declarations: [ProfileComponent, FormComponent], + exports: [ProfileComponent, FormComponent], }) export class ProfileModule {} diff --git a/src/app/profile/services/profile.service.ts b/src/app/profile/services/profile.service.ts index ef4d4537a3f3267d23918e12c2a8218e5ecde3e5..819eb0d3f9630f4e409bf31d67849a763965386a 100644 --- a/src/app/profile/services/profile.service.ts +++ b/src/app/profile/services/profile.service.ts @@ -2,17 +2,27 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { User } from '../../models/user.model'; +import { AuthService } from '../../services/auth.service'; @Injectable({ providedIn: 'root', }) export class ProfileService { private readonly baseUrl = 'api/users'; + private currentProfile: User = null; + constructor(private http: HttpClient, private authService: AuthService) {} - constructor(private http: HttpClient) {} + public async getProfile(): Promise<User> { + // Get profil by API only on first time + if (!this.currentProfile) { + const profile = await this.http.get<User>(`${this.baseUrl}/profile`).toPromise(); + this.currentProfile = profile; + } + return this.currentProfile; + } - public getProfile(): Observable<User> { - return this.http.get<User>(`${this.baseUrl}/profile`); + public isLinkedToStructure(idStructure: number): boolean { + return this.currentProfile.structuresLink.includes(idStructure); } public changePassword(newPassword: string, oldPassword: string): Observable<User> { diff --git a/src/app/services/structure.service.ts b/src/app/services/structure.service.ts index f881eb0a6875a6b3ebbff59e81880a2b39f15d9a..0c8192ceaabdb7b91c7138e4dcb275b136595be0 100644 --- a/src/app/services/structure.service.ts +++ b/src/app/services/structure.service.ts @@ -11,6 +11,7 @@ import { OpeningDay } from '../models/openingDay.model'; import { Weekday } from '../structure-list/enum/weekday.enum'; import { Time } from '../models/time.model'; import { Filter } from '../structure-list/models/filter.model'; +import { User } from '../models/user.model'; @Injectable({ providedIn: 'root', @@ -18,6 +19,11 @@ import { Filter } from '../structure-list/models/filter.model'; export class StructureService { constructor(private http: HttpClient) {} + public createStructure(structure: Structure, profile: User): Observable<Structure> { + const idUser = profile.email; + return this.http.post('/api/structures', { structure, idUser }).pipe(map((item: Structure) => new Structure(item))); + } + public postStructure(id: number, structure: Structure): Observable<Structure> { structure.updatedAt = new Date().toString(); return this.http.post('/api/structures/' + id, structure).pipe(map((item: Structure) => new Structure(item))); diff --git a/src/app/structure-list/components/card/card.component.html b/src/app/structure-list/components/card/card.component.html index fb162dab7397dab16d9459f4379362eddaed0259..2e4a7f611a02f04fc305904356e922df691cd355 100644 --- a/src/app/structure-list/components/card/card.component.html +++ b/src/app/structure-list/components/card/card.component.html @@ -1,4 +1,4 @@ -<div class="structure" fxLayout="column" (click)="cardClicked()" (mouseover)="cardHover()"> +<div class="structure" fxLayout="column" (click)="cardClicked()" (mouseenter)="cardHover()"> <div class="headerStructure" fxLayout="row" fxLayoutAlign="space-between center" fxLayoutGap="16px"> <span class="nomStructure">{{ structure.structureName }}</span> <div diff --git a/src/app/structure-list/components/structure-details/structure-details.component.html b/src/app/structure-list/components/structure-details/structure-details.component.html index 028c167ead96b611a11d9708136e381f6e3fe7b1..5412f1e53091817c7436e1d935df5dfe00b48e80 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.html +++ b/src/app/structure-list/components/structure-details/structure-details.component.html @@ -7,6 +7,9 @@ <div class="structrue-details-container" *ngIf="structure"> <!-- Header info --> <div fxLayout="row" fxLayoutAlign="end center"> + <button *ngIf="profileService.isLinkedToStructure(structure.id)" (click)="displayForm()"> + Modifier la structure + </button> <div (click)="close()" class="ico-close-details"></div> </div> <div fxLayout="row" class="structure-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="8px"> diff --git a/src/app/structure-list/components/structure-details/structure-details.component.ts b/src/app/structure-list/components/structure-details/structure-details.component.ts index cb66a608fdea824bab5f5e9507d78adbea36ac20..cf521ac418ad11c8d836ebbcacdf232c6dc7d4e4 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.ts +++ b/src/app/structure-list/components/structure-details/structure-details.component.ts @@ -11,6 +11,8 @@ import { Equipment } from '../../enum/equipment.enum'; import { typeStructureEnum } from '../../../shared/enum/typeStructure.enum'; import { TclService } from '../../../services/tcl.service'; import { TclStopPoint } from '../../../models/tclStopPoint.model'; +import { ProfileService } from '../../../profile/services/profile.service'; +import { User } from '../../../models/user.model'; @Component({ selector: 'app-structure-details', templateUrl: './structure-details.component.html', @@ -30,12 +32,14 @@ export class StructureDetailsComponent implements OnInit { public printMode = false; public isOtherSection = false; public showForm = false; + public currentProfile: User; constructor( route: ActivatedRoute, private printService: PrintService, - private searchService: SearchService, - private tclService: TclService + private tclService: TclService, + private profileService: ProfileService, + private searchService: SearchService ) { route.url.subscribe((url) => { if (url[0].path === 'structure') { @@ -46,6 +50,20 @@ export class StructureDetailsComponent implements OnInit { } ngOnInit(): void { + this.profileService.getProfile().then((p: User) => { + this.currentProfile = p; + }); + this.setReferentiels(); + const index = this.structure.proceduresAccompaniment.indexOf('autres'); + if (index > -1) { + this.structure.proceduresAccompaniment.splice(index, 1); + this.isOtherSection = true; + } + // GetTclStopPoints + this.getTclStopPoints(); + } + + private setReferentiels(): void { this.searchService.getCategoriesTraining().subscribe((referentiels) => { referentiels.forEach((referentiel) => { if (referentiel.isBaseSkills()) { @@ -59,15 +77,7 @@ export class StructureDetailsComponent implements OnInit { this.printService.onDataReady(); } }); - const index = this.structure.proceduresAccompaniment.indexOf('autres'); - if (index > -1) { - this.structure.proceduresAccompaniment.splice(index, 1); - this.isOtherSection = true; - } - // GetTclStopPoints - this.getTclStopPoints(); } - public getLabelTypeStructure(typeStructure: string[]): string { let label = ''; typeStructure.forEach((type) => { @@ -128,8 +138,9 @@ export class StructureDetailsComponent implements OnInit { public updateStructure(s: Structure): void { this.structure = new Structure({ ...this.structure, ...s }); - this.displayForm(); this.updatedStructure.emit(this.structure); + this.setReferentiels(); + this.displayForm(); } public getAccessIcon(accessModality: AccessModality): string { switch (accessModality) { diff --git a/src/app/structure-list/structure-list.component.html b/src/app/structure-list/structure-list.component.html index f0da17a8cd8ad9ce6d6d4fbc4d19d9d7b491602e..a4d7320ed0c1ee10516512502ddf3c53371c360e 100644 --- a/src/app/structure-list/structure-list.component.html +++ b/src/app/structure-list/structure-list.component.html @@ -5,7 +5,7 @@ {{ structureList ? structureList.length : '0' }} structure{{ structureList && structureList.length > 1 ? 's' : '' }} </div> -<div (scroll)="onScrollDown($event)" id="listCard" class="listCard" (mouseout)="mouseOut()"> +<div (scroll)="onScrollDown($event)" id="listCard" class="listCard" (mouseleave)="mouseLeave()"> <app-card *ngFor="let structure of structuresListChunked" [structure]="structure" diff --git a/src/app/structure-list/structure-list.component.ts b/src/app/structure-list/structure-list.component.ts index 7478e3778974522f3476e7004f00cc98cddfe178..68b0db213920b4720f9d922553ed91e1e83bf327 100644 --- a/src/app/structure-list/structure-list.component.ts +++ b/src/app/structure-list/structure-list.component.ts @@ -55,7 +55,7 @@ export class StructureListComponent implements OnChanges { this.displayMapMarkerId.emit([event.id]); } - public mouseOut(): void { + public mouseLeave(): void { this.displayMapMarkerId.emit([undefined]); }