|
|
|
@ -44,6 +44,7 @@ export class EditPinPopupComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
|
|
inputFocused: boolean = false;
|
|
|
|
|
files: any[] = [];
|
|
|
|
|
isPinModalOpen: boolean = false;
|
|
|
|
|
@Input() modalId!: string;
|
|
|
|
|
|
|
|
|
|
private modalOpenSubscription!: Subscription;
|
|
|
|
|
private routerSubscription!: Subscription;
|
|
|
|
@ -79,7 +80,7 @@ export class EditPinPopupComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
|
// Initialiser le formulaire avec les valeurs de base
|
|
|
|
|
this.form.patchValue({
|
|
|
|
|
title: this.pin?.title || 'vide',
|
|
|
|
|
title: this.pin?.title || '',
|
|
|
|
|
description: this.pin?.description || '',
|
|
|
|
|
location: "Chargement de l'adresse...",
|
|
|
|
|
});
|
|
|
|
@ -100,7 +101,6 @@ export class EditPinPopupComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
|
|
.pipe(take(1))
|
|
|
|
|
.subscribe(
|
|
|
|
|
(address) => {
|
|
|
|
|
console.log('Adresse récupérée:', address);
|
|
|
|
|
if (address && address.display_name) {
|
|
|
|
|
this.form.patchValue({ location: address.display_name });
|
|
|
|
|
} else {
|
|
|
|
@ -119,16 +119,14 @@ export class EditPinPopupComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// S'abonner aux changements d'état du modal
|
|
|
|
|
this.modalOpenSubscription = this.modalService.showModal$.subscribe(
|
|
|
|
|
(state) => {
|
|
|
|
|
this.modalOpenSubscription = this.modalService
|
|
|
|
|
.getModalState(this.modalId)
|
|
|
|
|
.subscribe((state) => {
|
|
|
|
|
this.isPinModalOpen = state;
|
|
|
|
|
|
|
|
|
|
// Lorsque le modal s'ouvre, s'assurer qu'il est dans le body
|
|
|
|
|
if (state) {
|
|
|
|
|
setTimeout(() => this.moveModalToBody(), 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// S'abonner aux événements de navigation du router
|
|
|
|
|
this.routerSubscription = this.router.events
|
|
|
|
@ -217,7 +215,6 @@ export class EditPinPopupComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
|
|
.toPromise();
|
|
|
|
|
|
|
|
|
|
if (address) {
|
|
|
|
|
console.log("Données d'adresse :", JSON.stringify(address));
|
|
|
|
|
this.form.get('location')?.setValue(address.display_name);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -259,10 +256,10 @@ export class EditPinPopupComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openPinModal() {
|
|
|
|
|
this.modalService.openModal();
|
|
|
|
|
this.modalService.openModal(this.modalId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closePinModal() {
|
|
|
|
|
this.modalService.closeModal();
|
|
|
|
|
this.modalService.closeModal(this.modalId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|