🛂 Update actions on shared pins
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
5a700b31c6
commit
2af63046da
@ -0,0 +1,71 @@
|
|||||||
|
<div id="confirm-share-modal-{{ pinId }}">
|
||||||
|
<!-- Fond assombri -->
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 bg-gray-900 bg-opacity-50 w-full h-full z-40 transition-opacity duration-300 ease-in-out"
|
||||||
|
[ngClass]="{
|
||||||
|
'opacity-0 pointer-events-none': !isOpen,
|
||||||
|
'opacity-100': isOpen
|
||||||
|
}"
|
||||||
|
(click)="cancel()"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<!-- Contenu principal -->
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 z-50 flex justify-center items-center w-full h-full overflow-y-auto"
|
||||||
|
[ngClass]="{
|
||||||
|
'opacity-0 scale-50 pointer-events-none': !isOpen,
|
||||||
|
'opacity-100 scale-100': isOpen
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="bg-white dark:bg-gray-700 rounded-lg shadow p-6 w-full max-w-md transition-transform duration-300 ease-in-out my-8"
|
||||||
|
>
|
||||||
|
<!-- Modal header -->
|
||||||
|
<div
|
||||||
|
class="flex items-center justify-between border-b rounded-t dark:border-gray-600 mb-6 pb-2"
|
||||||
|
>
|
||||||
|
<h2 class="text-lg font-semibold text-gray-900 dark:text-white">
|
||||||
|
Confirmation
|
||||||
|
</h2>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
(click)="closeModal()"
|
||||||
|
class="end-2.5 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="w-3 h-3"
|
||||||
|
aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 14 14"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Fermer la modal</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p class="text-sm text-gray-700 dark:text-gray-300 mb-6">{{ message }}</p>
|
||||||
|
|
||||||
|
<div class="flex justify-end space-x-4">
|
||||||
|
<button
|
||||||
|
class="px-4 py-2 text-white bg-red-600 hover:bg-red-700 rounded"
|
||||||
|
(click)="confirm()"
|
||||||
|
>
|
||||||
|
Supprimer
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="px-4 py-2 bg-gray-300 dark:bg-gray-600 text-gray-800 dark:text-white rounded hover:bg-gray-400 dark:hover:bg-gray-500"
|
||||||
|
(click)="cancel()"
|
||||||
|
>
|
||||||
|
Annuler
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ConfirmShareModalComponent } from './confirm-share-modal.component';
|
||||||
|
|
||||||
|
describe('ConfirmShareModalComponent', () => {
|
||||||
|
let component: ConfirmShareModalComponent;
|
||||||
|
let fixture: ComponentFixture<ConfirmShareModalComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [ConfirmShareModalComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ConfirmShareModalComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,74 @@
|
|||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import {
|
||||||
|
Component,
|
||||||
|
EventEmitter,
|
||||||
|
Input,
|
||||||
|
OnDestroy,
|
||||||
|
OnInit,
|
||||||
|
Output,
|
||||||
|
} from '@angular/core';
|
||||||
|
import { Subscription } from 'rxjs';
|
||||||
|
import { ModalService } from '../../services/modal/modal.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-confirm-share-modal',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule],
|
||||||
|
templateUrl: './confirm-share-modal.component.html',
|
||||||
|
})
|
||||||
|
export class ConfirmShareModalComponent implements OnInit, OnDestroy {
|
||||||
|
@Input() message: string =
|
||||||
|
'Voulez-vous retirer ce pin partagé de votre carte ?';
|
||||||
|
@Input() pinId: string = '';
|
||||||
|
@Input() pinOpened!: EventEmitter<void>;
|
||||||
|
|
||||||
|
@Output() confirmed = new EventEmitter<void>();
|
||||||
|
@Output() cancelled = new EventEmitter<void>();
|
||||||
|
|
||||||
|
modalId: string = '';
|
||||||
|
|
||||||
|
isOpen = false;
|
||||||
|
private subscription!: Subscription;
|
||||||
|
|
||||||
|
constructor(private modalService: ModalService) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.modalId = 'confirm-share-modal-' + this.pinId;
|
||||||
|
|
||||||
|
this.subscription = this.modalService
|
||||||
|
.getModalState(this.modalId)
|
||||||
|
.subscribe((state) => {
|
||||||
|
this.isOpen = state;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.pinOpened.subscribe(() => {
|
||||||
|
this.moveModalToBody();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.subscription?.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
confirm() {
|
||||||
|
this.confirmed.emit();
|
||||||
|
this.modalService.closeModal(this.modalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel() {
|
||||||
|
this.cancelled.emit();
|
||||||
|
this.modalService.closeModal(this.modalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
closeModal() {
|
||||||
|
this.isOpen = false;
|
||||||
|
this.modalService.closeModal(this.modalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private moveModalToBody(): void {
|
||||||
|
const modal = document.getElementById(this.modalId);
|
||||||
|
if (modal && modal.parentElement !== document.body) {
|
||||||
|
document.body.appendChild(modal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue