|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
|
import { Component, Input } from '@angular/core';
|
|
|
|
|
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
|
|
|
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
|
|
|
|
import * as L from 'leaflet';
|
|
|
|
|
import { Pin } from '../../model/Pin';
|
|
|
|
@ -27,17 +27,25 @@ export class PinMarkerComponent {
|
|
|
|
|
|
|
|
|
|
currentIndex: number = 0;
|
|
|
|
|
imageUrls: SafeUrl[] = [];
|
|
|
|
|
imageLoaded = false;
|
|
|
|
|
imagesLoaded = false;
|
|
|
|
|
|
|
|
|
|
@Output() pinOpened = new EventEmitter<void>();
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private pinService: PinService,
|
|
|
|
|
private modalService: ModalService,
|
|
|
|
|
private imageService: ImageService,
|
|
|
|
|
private sanitizer: DomSanitizer
|
|
|
|
|
) {}
|
|
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.loadImages();
|
|
|
|
|
// Écouter l'événement d'ouverture du popup
|
|
|
|
|
this.marker.on('popupopen', () => {
|
|
|
|
|
if (!this.imagesLoaded) {
|
|
|
|
|
this.loadImages();
|
|
|
|
|
this.pinOpened.emit();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadImages() {
|
|
|
|
@ -47,37 +55,33 @@ export class PinMarkerComponent {
|
|
|
|
|
const safeUrl = this.sanitizer.bypassSecurityTrustUrl(objectUrl);
|
|
|
|
|
this.imageUrls.push(safeUrl);
|
|
|
|
|
if (this.imageUrls.length === this.pin.files.length) {
|
|
|
|
|
this.imageLoaded = true;
|
|
|
|
|
this.imagesLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sharePin() {
|
|
|
|
|
this.modalService.openModal('share-modal', undefined, this.pin.id);
|
|
|
|
|
this.modalService.openModal('share-modal-' + this.pin.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onClosePopup() {
|
|
|
|
|
this.marker.closePopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onImageLoad() {
|
|
|
|
|
this.imageLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onDelete() {
|
|
|
|
|
this.modalService.openModal('confirm-modal');
|
|
|
|
|
this.modalService.openModal('confirm-modal-' + this.pin.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleConfirm() {
|
|
|
|
|
this.pinService.deletePin(this.pin.id).subscribe(() => {
|
|
|
|
|
this.marker.remove();
|
|
|
|
|
this.modalService.closeModal('confirm-modal');
|
|
|
|
|
this.modalService.closeModal('confirm-modal-' + this.pin.id);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleCancel() {
|
|
|
|
|
this.modalService.closeModal('confirm-modal');
|
|
|
|
|
this.modalService.closeModal('confirm-modal-' + this.pin.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get formattedDescription(): string {
|
|
|
|
|