Skip to content
Snippets Groups Projects
Commit d6b6ee3e authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

feat: add tooltip handling for structure card hover

parent 19d75800
No related branches found
No related tags found
2 merge requests!11Recette,!10Feat/structure detail
Showing
with 136 additions and 31 deletions
<div fxLayout="row" class="content-container"> <div fxLayout="row" class="content-container">
<app-structure-list [structureList]="structures" [location]="currentLocation" class="left-pane"></app-structure-list> <app-structure-list
<app-map [structures]="structures" class="right-pane"></app-map> [structureList]="structures"
[location]="currentLocation"
(displayMapMarkerId)="setMapMarkerId($event)"
class="left-pane"
></app-structure-list>
<app-map [structures]="structures" [toogleToolTipId]="displayMarkerId" class="right-pane"></app-map>
</div> </div>
...@@ -15,6 +15,7 @@ import { GeojsonService } from '../services/geojson.service'; ...@@ -15,6 +15,7 @@ import { GeojsonService } from '../services/geojson.service';
}) })
export class HomeComponent implements OnInit { export class HomeComponent implements OnInit {
public structures: Structure[] = []; public structures: Structure[] = [];
public displayMarkerId: number;
public geolocation = false; public geolocation = false;
public currentLocation: GeoJson; public currentLocation: GeoJson;
constructor(private structureService: StructureService, private geoJsonService: GeojsonService) {} constructor(private structureService: StructureService, private geoJsonService: GeojsonService) {}
...@@ -86,4 +87,8 @@ export class HomeComponent implements OnInit { ...@@ -86,4 +87,8 @@ export class HomeComponent implements OnInit {
(err) => console.error(err) (err) => console.error(err)
); );
} }
public setMapMarkerId(event: Array<number>): void {
this.displayMarkerId = event[0];
}
} }
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
@import '../../../assets/scss/typography'; @import '../../../assets/scss/typography';
#map { #map {
height: calc(100vh - #{$header-height} - #{$footer-height}); height: calc(100vh - #{$header-height} - #{$footer-height} - 120px);
// height: 100%;
width: 100%; width: 100%;
border: 10px solid white; border: 10px solid white;
} }
...@@ -52,6 +53,7 @@ ...@@ -52,6 +53,7 @@
::ng-deep .leaflet-tooltip { ::ng-deep .leaflet-tooltip {
padding: 8px 10px 8px 10px; padding: 8px 10px 8px 10px;
border-radius: 6px;
h1 { h1 {
color: $purple; color: $purple;
@include cn-bold-20; @include cn-bold-20;
......
...@@ -6,6 +6,7 @@ import { Structure } from '../../models/structure.model'; ...@@ -6,6 +6,7 @@ import { Structure } from '../../models/structure.model';
import { GeoJson } from '../models/geojson.model'; import { GeoJson } from '../models/geojson.model';
import { GeojsonService } from '../../services/geojson.service'; import { GeojsonService } from '../../services/geojson.service';
import { MapService } from '../services/map.service'; import { MapService } from '../services/map.service';
import { LeafletControlLayersChanges } from '@asymmetrik/ngx-leaflet';
@Component({ @Component({
selector: 'app-map', selector: 'app-map',
...@@ -14,7 +15,7 @@ import { MapService } from '../services/map.service'; ...@@ -14,7 +15,7 @@ import { MapService } from '../services/map.service';
}) })
export class MapComponent implements OnChanges { export class MapComponent implements OnChanges {
@Input() public structures: Structure[] = []; @Input() public structures: Structure[] = [];
@Input() public toogleToolTipIds: Array<number> = []; @Input() public toogleToolTipId: number;
public map: Map; public map: Map;
public mapOptions: MapOptions; public mapOptions: MapOptions;
// Init locate options // Init locate options
...@@ -34,6 +35,17 @@ export class MapComponent implements OnChanges { ...@@ -34,6 +35,17 @@ export class MapComponent implements OnChanges {
if (changes.structures) { if (changes.structures) {
this.getStructurePosition(); this.getStructurePosition();
} }
if (changes.toogleToolTipId && changes.toogleToolTipId.currentValue !== changes.toogleToolTipId.previousValue) {
if (changes.toogleToolTipId.previousValue !== undefined) {
this.mapService.toogleToolTip(changes.toogleToolTipId.previousValue);
}
this.mapService.toogleToolTip(changes.toogleToolTipId.currentValue);
// if (changes.toogleToolTipId.currentValue === undefined) {
// this.mapService.toogleToolTip(changes.toogleToolTipId.previousValue);
// } else {
// this.mapService.toogleToolTip(changes.toogleToolTipId.currentValue);
// }
}
} }
/** /**
...@@ -43,7 +55,7 @@ export class MapComponent implements OnChanges { ...@@ -43,7 +55,7 @@ export class MapComponent implements OnChanges {
this.structures.forEach((element: Structure) => { this.structures.forEach((element: Structure) => {
this.getCoord(element.voie).subscribe((coord: GeoJson) => { this.getCoord(element.voie).subscribe((coord: GeoJson) => {
this.mapService this.mapService
.createMarker(coord.geometry.getLon(), coord.geometry.getLat(), 1, this.buildToolTip(element)) .createMarker(coord.geometry.getLon(), coord.geometry.getLat(), element.id, this.buildToolTip(element))
.addTo(this.map); .addTo(this.map);
}); });
}); });
......
...@@ -6,7 +6,7 @@ import { icon, Marker, Map } from 'leaflet'; ...@@ -6,7 +6,7 @@ import { icon, Marker, Map } from 'leaflet';
providedIn: 'root', providedIn: 'root',
}) })
export class MapService { export class MapService {
private markersList = {}; private static markersList = {};
constructor() {} constructor() {}
public createMarker(lat: number, lon: number, id: number, tooltip?: string): Marker { public createMarker(lat: number, lon: number, id: number, tooltip?: string): Marker {
...@@ -21,7 +21,7 @@ export class MapService { ...@@ -21,7 +21,7 @@ export class MapService {
if (tooltip) { if (tooltip) {
marker.bindTooltip(tooltip); marker.bindTooltip(tooltip);
} }
this.markersList[id] = marker; MapService.markersList[id] = marker;
return marker; return marker;
} }
...@@ -30,7 +30,9 @@ export class MapService { ...@@ -30,7 +30,9 @@ export class MapService {
* @param id marker id * @param id marker id
*/ */
public toogleToolTip(id: number): void { public toogleToolTip(id: number): void {
this.getMarker(id).toggleTooltip(); if (id) {
this.getMarker(id).toggleTooltip();
}
} }
/** /**
...@@ -46,6 +48,6 @@ export class MapService { ...@@ -46,6 +48,6 @@ export class MapService {
* Get marker by id * Get marker by id
*/ */
public getMarker(id: number): Marker { public getMarker(id: number): Marker {
return this.markersList[id] ? this.markersList[id] : null; return MapService.markersList[id] ? MapService.markersList[id] : null;
} }
} }
...@@ -2,8 +2,8 @@ import { Weekday } from '../structure-list/enum/weekday.enum'; ...@@ -2,8 +2,8 @@ import { Weekday } from '../structure-list/enum/weekday.enum';
import { Day } from './day.model'; import { Day } from './day.model';
import { OpeningDay } from './openingDay.model'; import { OpeningDay } from './openingDay.model';
import { Week } from './week.model'; import { Week } from './week.model';
export class Structure { export class Structure {
public id: number;
public numero: string; public numero: string;
public dateDeCreation: string; public dateDeCreation: string;
public derniereModification: string; public derniereModification: string;
...@@ -66,11 +66,11 @@ export class Structure { ...@@ -66,11 +66,11 @@ export class Structure {
public openDisplay(): string { public openDisplay(): string {
if (this.isOpen) { if (this.isOpen) {
return 'Ouvert actuellement '; return 'Ouvert actuellement';
} else if (this.openedOn.day) { } else if (this.openedOn.day) {
return 'Fermé - Ouvre ' + this.openedOn.day + ' à ' + this.openedOn.schedule; return 'Fermé - Ouvre ' + this.hours.getDayTranslation(this.openedOn.day) + ' à ' + this.openedOn.schedule;
} else { } else {
return 'Aucun horaire disponible '; return 'Aucun horaire disponible';
} }
} }
......
import { Day } from './day.model'; import { Day } from './day.model';
import { Time } from './time.model';
export class Week { export class Week {
monday: Day; monday: Day;
...@@ -21,4 +20,25 @@ export class Week { ...@@ -21,4 +20,25 @@ export class Week {
sunday: obj && obj.sunday ? new Day(obj.sunday) : null, sunday: obj && obj.sunday ? new Day(obj.sunday) : null,
}); });
} }
public getDayTranslation(day: string): string {
switch (day) {
case 'monday':
return 'lundi';
case 'tuesday':
return 'mardi';
case 'thursday':
return 'jeudi';
case 'wednesday':
return 'mercredi';
case 'friday':
return 'vendredi';
case 'saturday':
return 'samedi';
case 'sunday':
return 'dimanche';
default:
return null;
}
}
} }
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'day', pure: false })
export class DayPipe implements PipeTransform {
transform(day: string): any {
switch (day) {
case 'monday':
return 'lundi';
case 'tuesday':
return 'mardi';
case 'thursday':
return 'jeudi';
case 'wednesday':
return 'mercredi';
case 'friday':
return 'vendredi';
case 'saturday':
return 'samedi';
case 'sunday':
return 'dimanche';
default:
return null;
}
}
}
export {}; import { DayPipe } from './day.pipe';
export { DayPipe };
// tslint:disable-next-line:variable-name // tslint:disable-next-line:variable-name
export const SharedPipes = []; export const SharedPipes = [DayPipe];
<div class="structure" fxLayout="column" (click)="cardClicked()"> <div class="structure" fxLayout="column" (click)="cardClicked()" (mouseover)="cardHover()">
<span class="nomStructure">{{ structure.nomDeVotreStructure }}</span> <span class="nomStructure">{{ structure.nomDeVotreStructure }}</span>
<div class="headerStructure" fxLayout="row" fxLayoutAlign="space-between center"> <div class="headerStructure" fxLayout="row" fxLayoutAlign="space-between center">
......
...@@ -13,6 +13,7 @@ import { mergeMap } from 'rxjs/operators'; ...@@ -13,6 +13,7 @@ import { mergeMap } from 'rxjs/operators';
export class CardComponent implements OnInit { export class CardComponent implements OnInit {
@Input() public structure: Structure; @Input() public structure: Structure;
@Output() public showDetails: EventEmitter<Structure> = new EventEmitter<Structure>(); @Output() public showDetails: EventEmitter<Structure> = new EventEmitter<Structure>();
@Output() public hover: EventEmitter<Structure> = new EventEmitter<Structure>();
constructor(private geoJsonService: GeojsonService) {} constructor(private geoJsonService: GeojsonService) {}
ngOnInit(): void {} ngOnInit(): void {}
...@@ -39,4 +40,8 @@ export class CardComponent implements OnInit { ...@@ -39,4 +40,8 @@ export class CardComponent implements OnInit {
public cardClicked(): void { public cardClicked(): void {
this.showDetails.emit(this.structure); this.showDetails.emit(this.structure);
} }
public cardHover(hoverOut: boolean): void {
this.hover.emit(this.structure);
}
} }
<div class="structrue-details-container"> <div class="structrue-details-container">
<!-- Header info -->
<div fxLayout="row" class="structrue-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="20px"> <div fxLayout="row" class="structrue-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="20px">
<em class="ic-arrow-left clickable" (click)="close()"></em> <em class="ic-arrow-left clickable" (click)="close()"></em>
<div fxLayout="column" fxLayoutGap="10px" fxFlex="100%"> <div fxLayout="column" fxLayoutGap="10px" fxFlex="100%">
...@@ -39,7 +40,7 @@ ...@@ -39,7 +40,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Démarches -->
<div <div
*ngIf="structure.accompagnementDesDemarches.length > 0" *ngIf="structure.accompagnementDesDemarches.length > 0"
fxLayout="column" fxLayout="column"
...@@ -57,6 +58,7 @@ ...@@ -57,6 +58,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Services -->
<div fxLayout="column" class="structrue-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="20px"> <div fxLayout="column" class="structrue-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="20px">
<div fxLayout="row" fxLayoutAlign="none baseline" fxLayoutGap="20px"> <div fxLayout="row" fxLayoutAlign="none baseline" fxLayoutGap="20px">
<em class="ic-mouse"></em> <em class="ic-mouse"></em>
...@@ -71,18 +73,20 @@ ...@@ -71,18 +73,20 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Accueil -->
<div fxLayout="column" class="structrue-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="20px"> <div fxLayout="column" class="structrue-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="20px">
<div fxLayout="row" fxLayoutAlign="none baseline" fxLayoutGap="20px"> <div fxLayout="row" fxLayoutAlign="none baseline" fxLayoutGap="20px">
<em class="ic-mouse"></em> <em class="ic-mouse"></em>
<h2>Accueil</h2> <h2>Accueil</h2>
</div> </div>
<!-- Openning Hours -->
<div fxLayout="row" class="w-100"> <div fxLayout="row" class="w-100">
<div fxFlex="70%"> <div fxFlex="70%">
<h3 class="subtitle">Horaires d’ouverture au public :</h3> <h3 class="subtitle">Horaires d’ouverture au public :</h3>
<div fxLayout="column"> <div fxLayout="column">
<div *ngFor="let day of structure.hours | keyvalue: keepOriginalOrder"> <div *ngFor="let day of structure.hours | keyvalue: keepOriginalOrder">
<div *ngIf="day.value.open"> <div *ngIf="day.value.open">
<h4>{{ day.key }}</h4> <h4>{{ day.key | day }}</h4>
<div class="openning-time" fxLayout="row" fxLayoutAlign="none center"> <div class="openning-time" fxLayout="row" fxLayoutAlign="none center">
<div *ngFor="let timeRange of day.value.time; let isFirst = first"> <div *ngFor="let timeRange of day.value.time; let isFirst = first">
<p *ngIf="isFirst">de {{ timeRange.formatOpenningDate() }} à {{ timeRange.formatClosingDate() }}</p> <p *ngIf="isFirst">de {{ timeRange.formatOpenningDate() }} à {{ timeRange.formatClosingDate() }}</p>
...@@ -95,6 +99,7 @@ ...@@ -95,6 +99,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- modalitesDacces -->
<div fxFlex="30%"> <div fxFlex="30%">
<h3 class="subtitle">Accès</h3> <h3 class="subtitle">Accès</h3>
<div *ngFor="let acces of structure.modalitesDacces"> <div *ngFor="let acces of structure.modalitesDacces">
...@@ -107,10 +112,10 @@ ...@@ -107,10 +112,10 @@
></em> ></em>
<p>{{ acces }}</p> <p>{{ acces }}</p>
</div> </div>
<!-- modalitesDacces -->
</div> </div>
</div> </div>
</div> </div>
<!-- Equipements -->
<div fxLayout="column" class="structrue-details-block" fxLayoutAlign="baseline baseline"> <div fxLayout="column" class="structrue-details-block" fxLayoutAlign="baseline baseline">
<div fxLayout="row" fxLayoutAlign="none baseline" fxLayoutGap="20px"> <div fxLayout="row" fxLayoutAlign="none baseline" fxLayoutGap="20px">
<em class="ic-toolbox"></em> <em class="ic-toolbox"></em>
...@@ -125,6 +130,7 @@ ...@@ -125,6 +130,7 @@
<p>Ordinateurs à disposition : {{ structure.nombre }}</p> <p>Ordinateurs à disposition : {{ structure.nombre }}</p>
</div> </div>
</div> </div>
<!-- Labels -->
<div fxLayout="column" class="structrue-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="20px"> <div fxLayout="column" class="structrue-details-block" fxLayoutAlign="baseline baseline" fxLayoutGap="20px">
<div fxLayout="row" fxLayoutAlign="none baseline" fxLayoutGap="20px"> <div fxLayout="row" fxLayoutAlign="none baseline" fxLayoutGap="20px">
<em class="ic-toolbox"></em> <em class="ic-toolbox"></em>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
@import '../../../../assets/scss/color'; @import '../../../../assets/scss/color';
@import '../../../../assets/scss/typography'; @import '../../../../assets/scss/typography';
@import '../../../../assets/scss/z-index'; @import '../../../../assets/scss/z-index';
@import '../../../../assets/scss/layout';
.structrue-details-container { .structrue-details-container {
background-color: $white; background-color: $white;
...@@ -9,8 +10,9 @@ ...@@ -9,8 +10,9 @@
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
width: 980px; max-width: 980px;
height: 100%; width: 100%;
height: calc(100vh - #{$header-height} - #{$footer-height} - 36px);
padding: 18px 24px; padding: 18px 24px;
overflow: auto; overflow: auto;
} }
...@@ -23,6 +25,9 @@ ...@@ -23,6 +25,9 @@
@include cn-bold-16; @include cn-bold-16;
} }
} }
.structrue-details-block:last-child {
border-bottom: none;
}
.openning-time { .openning-time {
p { p {
......
<app-recherche></app-recherche> <app-recherche></app-recherche>
<span class="nbStructuresLabel">{{ structureList.length }} structures</span> <span class="nbStructuresLabel">{{ structureList.length }} structures</span>
<app-card <div (mouseout)="mouseOut()">
*ngFor="let structure of structureList" <app-card
[structure]="structure" *ngFor="let structure of structureList"
(showDetails)="showDetails($event)" [structure]="structure"
></app-card> (showDetails)="showDetails($event)"
(hover)="handleCardHover($event)"
></app-card>
</div>
<app-structure-details <app-structure-details
*ngIf="showStructureDetails" *ngIf="showStructureDetails"
[structure]="structure" [structure]="structure"
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Structure } from '../models/structure.model'; import { Structure } from '../models/structure.model';
import { GeoJson } from '../map/models/geojson.model'; import { GeoJson } from '../map/models/geojson.model';
@Component({ @Component({
...@@ -9,18 +9,30 @@ import { GeoJson } from '../map/models/geojson.model'; ...@@ -9,18 +9,30 @@ import { GeoJson } from '../map/models/geojson.model';
export class StructureListComponent implements OnInit { export class StructureListComponent implements OnInit {
@Input() public structureList: Structure[]; @Input() public structureList: Structure[];
@Input() public location: GeoJson; @Input() public location: GeoJson;
@Output() public displayMapMarkerId: EventEmitter<Array<number>> = new EventEmitter<Array<number>>();
@Output() public hoverOut: EventEmitter<Array<number>> = new EventEmitter<Array<number>>();
public showStructureDetails = false; public showStructureDetails = false;
public structure: Structure[]; public structure: Structure;
constructor() {} constructor() {}
ngOnInit(): void {} ngOnInit(): void {}
public showDetails(event): void { public showDetails(event: Structure): void {
this.showStructureDetails = true; this.showStructureDetails = true;
this.structure = event; this.structure = event;
// this.displayMapMarkerId.emit([this.structure.id]);
} }
public closeDetails(): void { public closeDetails(): void {
// this.displayMapMarkerId.emit([]);
this.showStructureDetails = false; this.showStructureDetails = false;
} }
public handleCardHover(event: Structure): void {
this.displayMapMarkerId.emit([event.id]);
}
public mouseOut(): void {
this.displayMapMarkerId.emit([undefined]);
}
} }
...@@ -40,10 +40,11 @@ a { ...@@ -40,10 +40,11 @@ a {
// Containers // Containers
.content-container { .content-container {
margin: 0; margin: 0;
padding: 20px 0 30px 0; padding: 30px 0 30px 0;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
width: 100%; width: 100%;
height: 100%;
&.medium-pt { &.medium-pt {
padding: 25px 0 30px 0; padding: 25px 0 30px 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment