fix overlay demo
This commit is contained in:
@@ -1,22 +1,22 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import { ConfirmationService, MessageService } from 'primeng/api';
|
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||||
import { ButtonModule } from 'primeng/button';
|
import {ButtonModule} from 'primeng/button';
|
||||||
import { DialogModule } from 'primeng/dialog';
|
import {DialogModule} from 'primeng/dialog';
|
||||||
import { ToastModule } from 'primeng/toast';
|
import {ToastModule} from 'primeng/toast';
|
||||||
import { DrawerModule } from 'primeng/drawer';
|
import {DrawerModule} from 'primeng/drawer';
|
||||||
import { Popover, PopoverModule } from 'primeng/popover';
|
import {Popover, PopoverModule} from 'primeng/popover';
|
||||||
import { ConfirmPopupModule } from 'primeng/confirmpopup';
|
import {ConfirmPopupModule} from 'primeng/confirmpopup';
|
||||||
import { InputTextModule } from 'primeng/inputtext';
|
import {InputTextModule} from 'primeng/inputtext';
|
||||||
import { FormsModule } from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import { TooltipModule } from 'primeng/tooltip';
|
import {TooltipModule} from 'primeng/tooltip';
|
||||||
import { TableModule } from 'primeng/table';
|
import {TableModule} from 'primeng/table';
|
||||||
import { Product, ProductService } from '@/app/pages/service/product.service';
|
import {Product, ProductService} from '@/app/pages/service/product.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-overlay-demo',
|
selector: 'app-overlay-demo',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [ToastModule, DialogModule, ButtonModule, DrawerModule, PopoverModule, ConfirmPopupModule, InputTextModule, FormsModule, TooltipModule, TableModule, ToastModule],
|
imports: [ToastModule, DialogModule, ButtonModule, DrawerModule, PopoverModule, ConfirmPopupModule, InputTextModule, FormsModule, TooltipModule, TableModule, ToastModule],
|
||||||
template: ` <div class="flex flex-col md:flex-row gap-8">
|
template: `<div class="flex flex-col md:flex-row gap-8">
|
||||||
<div class="md:w-1/2">
|
<div class="md:w-1/2">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="font-semibold text-xl mb-4">Dialog</div>
|
<div class="font-semibold text-xl mb-4">Dialog</div>
|
||||||
@@ -40,15 +40,23 @@ import { Product, ProductService } from '@/app/pages/service/product.service';
|
|||||||
<p-table [value]="products" selectionMode="single" [(selection)]="selectedProduct" dataKey="id" [rows]="5" [paginator]="true" (onRowSelect)="onProductSelect(op2, $event)">
|
<p-table [value]="products" selectionMode="single" [(selection)]="selectedProduct" dataKey="id" [rows]="5" [paginator]="true" (onRowSelect)="onProductSelect(op2, $event)">
|
||||||
<ng-template #header>
|
<ng-template #header>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th pSortableColumn="name" style="width: 33%;">
|
||||||
<th>Image</th>
|
Name
|
||||||
<th>Price</th>
|
<p-sortIcon field="name" />
|
||||||
|
</th>
|
||||||
|
<th style="width: 33%;">Image</th>
|
||||||
|
<th pSortableColumn="price" style="width: 33%;">
|
||||||
|
Price
|
||||||
|
<p-sortIcon field="price" />
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template #body let-product>
|
<ng-template #body let-product>
|
||||||
<tr [pSelectableRow]="product">
|
<tr [pSelectableRow]="product">
|
||||||
<td>{{ product.name }}</td>
|
<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>
|
||||||
|
<img [src]="'/demo/images/product/' + product.image" [alt]="product.name" class="w-16 shadow-sm" />
|
||||||
|
</td>
|
||||||
<td>{{ product.price }}</td>
|
<td>{{ product.price }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@@ -113,7 +121,7 @@ import { Product, ProductService } from '@/app/pages/service/product.service';
|
|||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="font-semibold text-xl mb-4">ConfirmPopup</div>
|
<div class="font-semibold text-xl mb-4">ConfirmPopup</div>
|
||||||
<p-confirmpopup></p-confirmpopup>
|
<p-confirmpopup key="confirm2"></p-confirmpopup>
|
||||||
<p-button #popup (click)="confirm($event)" icon="pi pi-check" label="Confirm" class="mr-2"></p-button>
|
<p-button #popup (click)="confirm($event)" icon="pi pi-check" label="Confirm" class="mr-2"></p-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -122,7 +130,7 @@ import { Product, ProductService } from '@/app/pages/service/product.service';
|
|||||||
<p-button label="Delete" icon="pi pi-trash" severity="danger" [style]="{ width: 'auto' }" (click)="openConfirmation()" />
|
<p-button label="Delete" icon="pi pi-trash" severity="danger" [style]="{ width: 'auto' }" (click)="openConfirmation()" />
|
||||||
<p-dialog header="Confirmation" [(visible)]="displayConfirmation" [style]="{ width: '350px' }" [modal]="true">
|
<p-dialog header="Confirmation" [(visible)]="displayConfirmation" [style]="{ width: '350px' }" [modal]="true">
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<i class="pi pi-exclamation-triangle mr-4" style="font-size: 2rem"> </i>
|
<i class="pi pi-exclamation-triangle mr-6" style="font-size: 2rem"> </i>
|
||||||
<span>Are you sure you want to proceed?</span>
|
<span>Are you sure you want to proceed?</span>
|
||||||
</div>
|
</div>
|
||||||
<ng-template #footer>
|
<ng-template #footer>
|
||||||
@@ -136,8 +144,6 @@ import { Product, ProductService } from '@/app/pages/service/product.service';
|
|||||||
providers: [ConfirmationService, MessageService, ProductService]
|
providers: [ConfirmationService, MessageService, ProductService]
|
||||||
})
|
})
|
||||||
export class OverlayDemo implements OnInit {
|
export class OverlayDemo implements OnInit {
|
||||||
images: any[] = [];
|
|
||||||
|
|
||||||
display: boolean = false;
|
display: boolean = false;
|
||||||
|
|
||||||
products: Product[] = [];
|
products: Product[] = [];
|
||||||
@@ -164,28 +170,6 @@ export class OverlayDemo implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.productService.getProductsSmall().then((products) => (this.products = products));
|
this.productService.getProductsSmall().then((products) => (this.products = products));
|
||||||
|
|
||||||
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) {
|
confirm(event: Event) {
|
||||||
@@ -194,11 +178,27 @@ export class OverlayDemo implements OnInit {
|
|||||||
target: event.target || new EventTarget(),
|
target: event.target || new EventTarget(),
|
||||||
message: 'Are you sure that you want to proceed?',
|
message: 'Are you sure that you want to proceed?',
|
||||||
icon: 'pi pi-exclamation-triangle',
|
icon: 'pi pi-exclamation-triangle',
|
||||||
|
rejectButtonProps: {
|
||||||
|
label: 'Cancel',
|
||||||
|
severity: 'secondary',
|
||||||
|
outlined: true
|
||||||
|
},
|
||||||
|
acceptButtonProps: {
|
||||||
|
label: 'Save'
|
||||||
|
},
|
||||||
accept: () => {
|
accept: () => {
|
||||||
this.messageService.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted' });
|
this.messageService.add({
|
||||||
|
severity: 'info',
|
||||||
|
summary: 'Confirmed',
|
||||||
|
detail: 'You have accepted'
|
||||||
|
});
|
||||||
},
|
},
|
||||||
reject: () => {
|
reject: () => {
|
||||||
this.messageService.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected' });
|
this.messageService.add({
|
||||||
|
severity: 'error',
|
||||||
|
summary: 'Rejected',
|
||||||
|
detail: 'You have rejected'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,12 @@ export class OverlayDemo implements OnInit {
|
|||||||
|
|
||||||
onProductSelect(op: Popover, event: any) {
|
onProductSelect(op: Popover, event: any) {
|
||||||
op.hide();
|
op.hide();
|
||||||
this.messageService.add({ severity: 'info', summary: 'Product Selected', detail: event?.data.name, life: 3000 });
|
this.messageService.add({
|
||||||
|
severity: 'info',
|
||||||
|
summary: 'Product Selected',
|
||||||
|
detail: event?.data.name,
|
||||||
|
life: 3000
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
openConfirmation() {
|
openConfirmation() {
|
||||||
|
|||||||
Reference in New Issue
Block a user