primeng icon indicating copy to clipboard operation
primeng copied to clipboard

New ConfirmDialog Component

Open cagataycivici opened this issue 10 years ago • 14 comments

Subset of Dialog to make it easier to create a confirm dialog with backed by a confirm service for reuse so could be fired from any action.

import {ConfirmDialogModule,ConfirmationService} from 'primeng/primeng';
<p-confirmDialog header="Confirmation" icon="fa fa-question-circle" width="425"></p-confirmDialog>

<button type="text" (click)="confirm()" pButton icon="fa-check" label="Confirm"></button>
export class ConfirmDialogDemo { 

    constructor(private confirmationService: ConfirmationService) {}

    confirm() {
        this.confirmationService.confirm({
            message: 'Are you sure that you want to perform this action?',
            accept: () => {
                //Actual logic to perform a confirmation
            }
        });
    }
}

cagataycivici avatar Sep 14 '16 16:09 cagataycivici

I want some more functionality in dialog like button label text because I have more confirmation dialog in a a single template. I want to pass the button labels text, like message header and icon from confirm() function. I red primeng tutorial. tutorial suggest that by using acceptLabel attribute, Its possible to change button lable text but in my confirm function its giving error that confirm function doesn't have acceptLabel attribute. Is this confirmDialog module support that functionality? If yes, what could be the right format of the code structure. Any suggestion could be appreciated. thanks.

KumarGovindh avatar Dec 02 '16 06:12 KumarGovindh

What I think could fit nicely is allow html messages.

Instead of

<span class=\"ui-confirmdialog-message\">{{message}}</span>

We do

<span class=\"ui-confirmdialog-message\" [innerHTML]="message"></span>

What do you think, @cagataycivici ?

ebosantos avatar Jan 20 '17 20:01 ebosantos

@KumarGovindh Did you find how to customize acceptLabel and rejectLabel?

igogu avatar Feb 09 '17 11:02 igogu

Hi again,

I found how to do it, you just have to defined in you p-confirmDialog acceptLabel=""; for example:

<p-confirmDialog id="popupBorrar" header="Confirmation" width="425" acceptLabel="Add" #cd>

igogu avatar Feb 09 '17 16:02 igogu

Why cant we simply pass the confirmdialog template to the service? Why cant we define multiple confirmdialogs per page identified by #id or something like that so we can target it with the .confirm() function? What the hell?

barocsi avatar Feb 20 '17 13:02 barocsi

@barocsi Take a look at p-dialog.

ebosantos avatar Feb 20 '17 14:02 ebosantos

Thanks, but this is not the way it should work. Why would I pollute my static dom with dialogs instead of having generic templates that I can display dynamically? It smells like an anti-pattern.

barocsi avatar Feb 20 '17 14:02 barocsi

Has anyone found the proper solution ?

sajalsuraj avatar Sep 22 '17 06:09 sajalsuraj

Any news about this feature? Should we open an issue for creating more confirmDialog on the same page?

pierfreeman avatar Oct 03 '17 10:10 pierfreeman

Does the p-confirmDialog support a ng-template pTemplate="body" ?

sgentile avatar Dec 21 '17 19:12 sgentile

the solution for my is appendTo="body"

<p-confirmDialog header="Confirmation" icon="fa fa-question-circle" width="425" appendTo="body" #cd>

Did you have any possible in multi line of content in confirmation box ?

prakashpixels avatar May 22 '18 10:05 prakashpixels

Is there no way to close these confirmation dialogs using the service? I want to display a "Your session is going to expire" message, and close the confirmation if the session expires—but there doesn't appear to be a way to do that.

shaungrady avatar Jun 28 '18 23:06 shaungrady

@shaungrady use normal dialog with modal=true

kuriel-dev avatar Aug 14 '18 17:08 kuriel-dev