2026-04-27 21:53:11 +03:30
|
|
|
import { SharedDialogComponent } from '@/shared/components/dialog/dialog.component';
|
2024-12-31 12:58:33 +03:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2026-04-27 21:53:11 +03:30
|
|
|
import { FormsModule } from '@angular/forms';
|
2024-12-31 12:58:33 +03:00
|
|
|
import { ConfirmationService, MessageService } from 'primeng/api';
|
|
|
|
|
import { ButtonModule } from 'primeng/button';
|
2026-04-27 21:53:11 +03:30
|
|
|
import { ConfirmPopupModule } from 'primeng/confirmpopup';
|
2024-12-31 12:58:33 +03:00
|
|
|
import { DialogModule } from 'primeng/dialog';
|
|
|
|
|
import { DrawerModule } from 'primeng/drawer';
|
2025-01-03 12:05:34 +03:00
|
|
|
import { InputTextModule } from 'primeng/inputtext';
|
2026-04-27 21:53:11 +03:30
|
|
|
import { Popover, PopoverModule } from 'primeng/popover';
|
2025-01-07 11:38:04 +03:00
|
|
|
import { TableModule } from 'primeng/table';
|
2026-04-27 21:53:11 +03:30
|
|
|
import { ToastModule } from 'primeng/toast';
|
|
|
|
|
import { TooltipModule } from 'primeng/tooltip';
|
2025-01-07 13:04:10 +03:00
|
|
|
import { Product, ProductService } from '../service/product.service';
|
2024-12-31 12:58:33 +03:00
|
|
|
|
|
|
|
|
@Component({
|
2026-04-27 21:53:11 +03:30
|
|
|
selector: 'app-overlay-demo',
|
|
|
|
|
standalone: true,
|
|
|
|
|
imports: [
|
|
|
|
|
ToastModule,
|
|
|
|
|
DialogModule,
|
|
|
|
|
ButtonModule,
|
|
|
|
|
DrawerModule,
|
|
|
|
|
PopoverModule,
|
|
|
|
|
ConfirmPopupModule,
|
|
|
|
|
InputTextModule,
|
|
|
|
|
FormsModule,
|
|
|
|
|
TooltipModule,
|
|
|
|
|
TableModule,
|
|
|
|
|
ToastModule,
|
|
|
|
|
SharedDialogComponent,
|
|
|
|
|
],
|
|
|
|
|
template: ` <div class="flex flex-col md:flex-row gap-8">
|
|
|
|
|
<div class="md:w-1/2">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="font-semibold text-xl mb-4">SharedDialogComponent</div>
|
|
|
|
|
<shared-dialog
|
|
|
|
|
header="SharedDialogComponent"
|
|
|
|
|
[(visible)]="display"
|
|
|
|
|
[breakpoints]="{ '960px': '75vw' }"
|
|
|
|
|
[style]="{ width: '30vw' }"
|
|
|
|
|
[modal]="true"
|
|
|
|
|
>
|
|
|
|
|
<p class="leading-normal m-0">
|
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
|
|
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
|
|
|
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
|
|
|
|
|
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
|
|
|
|
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
|
|
|
|
|
mollit anim id est laborum.
|
|
|
|
|
</p>
|
|
|
|
|
<ng-template #footer>
|
|
|
|
|
<p-button label="Save" (click)="close()" />
|
|
|
|
|
</ng-template>
|
|
|
|
|
</shared-dialog>
|
|
|
|
|
<p-button label="Show" [style]="{ width: 'auto' }" (click)="open()" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="font-semibold text-xl mb-4">Popover</div>
|
|
|
|
|
<div class="flex flex-wrap gap-2">
|
|
|
|
|
<p-button type="button" label="Show" (click)="toggleDataTable(op2, $event)" />
|
|
|
|
|
<p-popover #op2 id="overlay_panel" [style]="{ width: '450px' }">
|
|
|
|
|
<p-table
|
|
|
|
|
[value]="products"
|
|
|
|
|
selectionMode="single"
|
|
|
|
|
[(selection)]="selectedProduct"
|
|
|
|
|
dataKey="id"
|
|
|
|
|
[rows]="5"
|
|
|
|
|
[paginator]="true"
|
|
|
|
|
(onRowSelect)="onProductSelect(op2, $event)"
|
|
|
|
|
>
|
|
|
|
|
<ng-template #header>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>Name</th>
|
|
|
|
|
<th>Image</th>
|
|
|
|
|
<th>Price</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</ng-template>
|
|
|
|
|
<ng-template #body let-product>
|
|
|
|
|
<tr [pSelectableRow]="product">
|
|
|
|
|
<td>{{ product.name }}</td>
|
|
|
|
|
<td>
|
|
|
|
|
<img
|
|
|
|
|
[src]="
|
|
|
|
|
'https://primefaces.org/cdn/primeng/images/demo/product/' + product.image
|
|
|
|
|
"
|
|
|
|
|
[alt]="product.name"
|
|
|
|
|
class="w-16 shadow-sm"
|
|
|
|
|
/>
|
|
|
|
|
</td>
|
|
|
|
|
<td>{{ product.price }}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</p-table>
|
|
|
|
|
</p-popover>
|
|
|
|
|
<p-toast />
|
2024-12-31 12:58:33 +03:00
|
|
|
</div>
|
2026-04-27 21:53:11 +03:30
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="font-semibold text-xl mb-4">Tooltip</div>
|
|
|
|
|
<div class="inline-flex gap-4">
|
|
|
|
|
<input pInputText type="text" placeholder="Username" pTooltip="Your username" />
|
|
|
|
|
<p-button type="button" label="Save" pTooltip="Click to proceed" />
|
2024-12-31 12:58:33 +03:00
|
|
|
</div>
|
2026-04-27 21:53:11 +03:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="md:w-1/2">
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="font-semibold text-xl mb-4">Drawer</div>
|
|
|
|
|
<p-drawer [(visible)]="visibleLeft" header="Drawer">
|
|
|
|
|
<p>
|
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
|
|
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
|
|
|
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
|
|
|
</p>
|
|
|
|
|
</p-drawer>
|
|
|
|
|
|
|
|
|
|
<p-drawer [(visible)]="visibleRight" header="Drawer" position="right">
|
|
|
|
|
<p>
|
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
|
|
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
|
|
|
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
|
|
|
</p>
|
|
|
|
|
</p-drawer>
|
|
|
|
|
|
|
|
|
|
<p-drawer [(visible)]="visibleTop" header="Drawer" position="top">
|
|
|
|
|
<p>
|
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
|
|
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
|
|
|
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
|
|
|
</p>
|
|
|
|
|
</p-drawer>
|
|
|
|
|
|
|
|
|
|
<p-drawer [(visible)]="visibleBottom" header="Drawer" position="bottom">
|
|
|
|
|
<p>
|
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
|
|
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
|
|
|
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
|
|
|
</p>
|
|
|
|
|
</p-drawer>
|
|
|
|
|
|
|
|
|
|
<p-drawer [(visible)]="visibleFull" header="Drawer" position="full">
|
|
|
|
|
<p>
|
|
|
|
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
|
|
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
|
|
|
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
|
|
|
</p>
|
|
|
|
|
</p-drawer>
|
|
|
|
|
|
|
|
|
|
<p-button
|
|
|
|
|
icon="pi pi-arrow-right"
|
|
|
|
|
(click)="visibleLeft = true"
|
|
|
|
|
[style]="{ marginRight: '0.25em' }"
|
|
|
|
|
/>
|
|
|
|
|
<p-button
|
|
|
|
|
icon="pi pi-arrow-left"
|
|
|
|
|
(click)="visibleRight = true"
|
|
|
|
|
[style]="{ marginRight: '0.25em' }"
|
|
|
|
|
/>
|
|
|
|
|
<p-button
|
|
|
|
|
icon="pi pi-arrow-down"
|
|
|
|
|
(click)="visibleTop = true"
|
|
|
|
|
[style]="{ marginRight: '0.25em' }"
|
|
|
|
|
/>
|
|
|
|
|
<p-button
|
|
|
|
|
icon="pi pi-arrow-up"
|
|
|
|
|
(click)="visibleBottom = true"
|
|
|
|
|
[style]="{ marginRight: '0.25em' }"
|
|
|
|
|
/>
|
|
|
|
|
<p-button icon="pi pi-external-link" (click)="visibleFull = true" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="font-semibold text-xl mb-4">ConfirmPopup</div>
|
|
|
|
|
<p-confirmpopup></p-confirmpopup>
|
|
|
|
|
<p-button
|
|
|
|
|
#popup
|
|
|
|
|
(click)="confirm($event)"
|
|
|
|
|
icon="pi pi-check"
|
|
|
|
|
label="Confirm"
|
|
|
|
|
class="mr-2"
|
|
|
|
|
></p-button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="card">
|
|
|
|
|
<div class="font-semibold text-xl mb-4">ConfirmDialog</div>
|
|
|
|
|
<p-button
|
|
|
|
|
label="Delete"
|
|
|
|
|
icon="pi pi-trash"
|
|
|
|
|
severity="danger"
|
|
|
|
|
[style]="{ width: 'auto' }"
|
|
|
|
|
(click)="openConfirmation()"
|
|
|
|
|
/>
|
|
|
|
|
<shared-dialog
|
|
|
|
|
header="Confirmation"
|
|
|
|
|
[(visible)]="displayConfirmation"
|
|
|
|
|
[style]="{ width: '350px' }"
|
|
|
|
|
[modal]="true"
|
|
|
|
|
>
|
|
|
|
|
<div class="flex items-center justify-center">
|
|
|
|
|
<i class="pi pi-exclamation-triangle mr-4" style="font-size: 2rem"> </i>
|
|
|
|
|
<span>Are you sure you want to proceed?</span>
|
|
|
|
|
</div>
|
|
|
|
|
<ng-template #footer>
|
|
|
|
|
<p-button
|
|
|
|
|
label="No"
|
|
|
|
|
icon="pi pi-times"
|
|
|
|
|
(click)="closeConfirmation()"
|
|
|
|
|
text
|
|
|
|
|
severity="secondary"
|
|
|
|
|
/>
|
|
|
|
|
<p-button
|
|
|
|
|
label="Yes"
|
|
|
|
|
icon="pi pi-check"
|
|
|
|
|
(click)="closeConfirmation()"
|
|
|
|
|
severity="danger"
|
|
|
|
|
outlined
|
|
|
|
|
autofocus
|
|
|
|
|
/>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</shared-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>`,
|
|
|
|
|
providers: [ConfirmationService, MessageService, ProductService],
|
2024-12-31 12:58:33 +03:00
|
|
|
})
|
2025-01-07 13:04:10 +03:00
|
|
|
export class OverlayDemo implements OnInit {
|
2026-04-27 21:53:11 +03:30
|
|
|
images: any[] = [];
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
display: boolean = false;
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
products: Product[] = [];
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
visibleLeft: boolean = false;
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
visibleRight: boolean = false;
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
visibleTop: boolean = false;
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
visibleBottom: boolean = false;
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
visibleFull: boolean = false;
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
displayConfirmation: boolean = false;
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
selectedProduct!: Product;
|
2025-01-07 11:38:04 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
constructor(
|
|
|
|
|
private productService: ProductService,
|
|
|
|
|
private confirmationService: ConfirmationService,
|
|
|
|
|
private messageService: MessageService,
|
|
|
|
|
) {}
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
ngOnInit() {
|
|
|
|
|
this.productService.getProductsSmall().then((products) => (this.products = products));
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
this.images = [];
|
|
|
|
|
this.images.push({
|
|
|
|
|
source: 'assets/demo/images/sopranos/sopranos1.jpg',
|
|
|
|
|
thumbnail: 'assets/demo/images/sopranos/sopranos1_small.jpg',
|
|
|
|
|
title: 'Sopranos 1',
|
|
|
|
|
});
|
|
|
|
|
this.images.push({
|
|
|
|
|
source: 'assets/demo/images/sopranos/sopranos2.jpg',
|
|
|
|
|
thumbnail: 'assets/demo/images/sopranos/sopranos2_small.jpg',
|
|
|
|
|
title: 'Sopranos 2',
|
|
|
|
|
});
|
|
|
|
|
this.images.push({
|
|
|
|
|
source: 'assets/demo/images/sopranos/sopranos3.jpg',
|
|
|
|
|
thumbnail: 'assets/demo/images/sopranos/sopranos3_small.jpg',
|
|
|
|
|
title: 'Sopranos 3',
|
|
|
|
|
});
|
|
|
|
|
this.images.push({
|
|
|
|
|
source: 'assets/demo/images/sopranos/sopranos4.jpg',
|
|
|
|
|
thumbnail: 'assets/demo/images/sopranos/sopranos4_small.jpg',
|
|
|
|
|
title: 'Sopranos 4',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
confirm(event: Event) {
|
|
|
|
|
this.confirmationService.confirm({
|
|
|
|
|
key: 'confirm2',
|
|
|
|
|
target: event.target || new EventTarget(),
|
|
|
|
|
message: 'Are you sure that you want to proceed?',
|
|
|
|
|
icon: 'pi pi-exclamation-triangle',
|
|
|
|
|
accept: () => {
|
|
|
|
|
this.messageService.add({
|
|
|
|
|
severity: 'info',
|
|
|
|
|
summary: 'Confirmed',
|
|
|
|
|
detail: 'You have accepted',
|
2024-12-31 12:58:33 +03:00
|
|
|
});
|
2026-04-27 21:53:11 +03:30
|
|
|
},
|
|
|
|
|
reject: () => {
|
|
|
|
|
this.messageService.add({
|
|
|
|
|
severity: 'error',
|
|
|
|
|
summary: 'Rejected',
|
|
|
|
|
detail: 'You have rejected',
|
2024-12-31 12:58:33 +03:00
|
|
|
});
|
2026-04-27 21:53:11 +03:30
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-12-31 12:58:33 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
open() {
|
|
|
|
|
this.display = true;
|
|
|
|
|
}
|
2025-01-03 11:41:08 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
close() {
|
|
|
|
|
this.display = false;
|
|
|
|
|
}
|
2025-01-03 11:41:08 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
toggleDataTable(op: Popover, event: any) {
|
|
|
|
|
op.toggle(event);
|
|
|
|
|
}
|
2025-01-03 11:41:08 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
onProductSelect(op: Popover, event: any) {
|
|
|
|
|
op.hide();
|
|
|
|
|
this.messageService.add({
|
|
|
|
|
severity: 'info',
|
|
|
|
|
summary: 'Product Selected',
|
|
|
|
|
detail: event?.data.name,
|
|
|
|
|
life: 3000,
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-01-03 11:41:08 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
openConfirmation() {
|
|
|
|
|
this.displayConfirmation = true;
|
|
|
|
|
}
|
2025-01-03 11:41:08 +03:00
|
|
|
|
2026-04-27 21:53:11 +03:30
|
|
|
closeConfirmation() {
|
|
|
|
|
this.displayConfirmation = false;
|
|
|
|
|
}
|
2025-01-03 11:41:08 +03:00
|
|
|
}
|