Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfirmDialog: pTemplate="message" and pTemplate="icon" is missing #13700

Closed
akhalaiav opened this issue Sep 19, 2023 · 1 comment · Fixed by #13703
Closed

ConfirmDialog: pTemplate="message" and pTemplate="icon" is missing #13700

akhalaiav opened this issue Sep 19, 2023 · 1 comment · Fixed by #13703
Assignees
Labels
Core Team Issue or pull request has been *opened* by a member of Core Team Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@akhalaiav
Copy link

akhalaiav commented Sep 19, 2023

Describe the feature you would like to see added

According to my design, I should have a custom message for the dialog.

Снимок экрана 2023-09-19 в 09 24 08

The current implementation has header and footer templates

According to documentation https://primeng.org/confirmdialog

<div class="card flex justify-content-center">
    <p-toast></p-toast>
    <p-confirmDialog #cd [style]="{width: '50vw'}">
        <ng-template pTemplate="header">
            <h3>Header Content</h3>
        </ng-template>
        <ng-template pTemplate="footer">
            <button type="button" pButton icon="pi pi-times" label="No" (click)="cd.reject()"></button>
            <button type="button" pButton icon="pi pi-check" label="Yes" (click)="cd.accept()"></button>
        </ng-template>
    </p-confirmDialog>
    <p-button (click)="confirm1()" icon="pi pi-check" label="Confirm"></p-button>
</div>

Is your feature request related to a problem?

No response

Describe the solution you'd like

Will be better when we have something like that:

<div class="card flex justify-content-center">
...
    <p-confirmDialog>
        <ng-template pTemplate="message">
            <p>Custom Message Structure</p>
        </ng-template>
    </p-confirmDialog>
...
</div>

Describe alternatives you have considered

For now, I should create a string with HTML code and add to the message property like:

this.confirmationService.confirm({
      header: 'Some Header',
      message: '<p>Some Custom Message with needed logic</p>',
      accept: () => {
        console.log('accepted')
      },
    });

Additional context

Current:
PrimeNg Version - 16.3.1
Node 18

Environment
Latest Angular and Primeng version

@akhalaiav akhalaiav added Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible Type: New Feature Issue contains a new feature or new component request labels Sep 19, 2023
@cetincakiroglu
Copy link
Contributor

Hi,

As the info text in the Templates section of the ConfirmDialog page, indicates that:

Properties of the dialog are defined in two ways, message, icon, and header properties can either be defined using confirm method or declaratively on p-confirmDialog ng-template by header and footer templates. If these values are unlikely to change then declarative approach would be useful, still properties defined in a ng-template can be overridden with confirm method call.
  • You can declaratively use templates with ng-template (header, footer)
  • You can define it by API (message, icon, header) as shown below
        this.confirmationService.confirm({
            message: 'Are you sure that you want to proceed?',
            header: 'Confirmation',
            icon: 'pi pi-exclamation-triangle',
            accept: () => {
                this.messageService.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted' });
            },
            reject: (type: ConfirmEventType) => {
                switch (type) {
                    case ConfirmEventType.REJECT:
                        this.messageService.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected' });
                        break;
                    case ConfirmEventType.CANCEL:
                        this.messageService.add({ severity: 'warn', summary: 'Cancelled', detail: 'You have cancelled' });
                        break;
                }
            }
        });

So this is not an issue or bug. A declarative option for the message does not exist. However, it's a good idea to put it as a feature.

Thanks for reporting and requesting it!

@cetincakiroglu cetincakiroglu added Status: Discussion Issue or pull request needs to be discussed by Core Team and removed Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Sep 19, 2023
@cetincakiroglu cetincakiroglu self-assigned this Sep 19, 2023
@cetincakiroglu cetincakiroglu changed the title ConfirmDialog: have no pTemplate="message" ConfirmDialog: pTemplate="message" and pTemplate="icon" is missing Sep 19, 2023
@cetincakiroglu cetincakiroglu added this to the 16.3.2 milestone Sep 19, 2023
@cetincakiroglu cetincakiroglu added the Core Team Issue or pull request has been *opened* by a member of Core Team label Sep 19, 2023
@cetincakiroglu cetincakiroglu added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Type: New Feature Issue contains a new feature or new component request Status: Discussion Issue or pull request needs to be discussed by Core Team labels Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Team Issue or pull request has been *opened* by a member of Core Team Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants