angular / angular/components

(Dialog) Component-less alert and confirm dialogs

Offen
#17,048 5 Kommentare 21 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/dialog feature needs: discussion P5
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### Feature Description

My proposal is to create one or two methods on the `MatDialog` provider/controller to allow component-less alert and confirm dialogs, for example:

// Alert dialog
this.dialog.alert({
title: 'Forbidden',
message: 'The resource you are trying to access is forbidden.',
okButton: 'OK'
})

// Confirm dialog
this.dialog.confirm({
title: 'Server error',
message: 'The server is currently in maintenance.',
confirmButton: 'Retry',
cancelButton: 'Cancel'
})

Alternatively, both `alert` and `confirm` could be on a single method:

this.dialog.alert({
title: 'The title',
message: 'The message',
confirmButton: 'OK', // Optional, only for confirm
dismissButton: 'Dismiss'
}).afterClose().subscribe((result: boolean) => console.log); // True if confirm, false if dismiss.

#### Use Case

Currently, we have to create a component for every dialog, event the simplest dialog. This is painful and useless in most cases. Other alternatives (what I do) is to create a `AlertService` that does it for me. But makes no sense maintain it if it could be a simple feature of `MatDialog`

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der Prüfung des bestehenden MatDialog provider/controller und des aktuellen component-based dialog flow. Vergleiche die vorgeschlagenen alert- und confirm-APIs, einschließlich der button labels und des boolean close result. Als abgeschlossen gilt die Arbeit, wenn das component-less-Verhalten und die API-Auswahl für beide dialog outcomes definiert und implementiert sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.