OpenSlides/client/src/app/core/ui-services/prompt.service.ts

28 lines
872 B
TypeScript
Raw Normal View History

2018-10-01 15:36:16 +02:00
import { Injectable } from '@angular/core';
import { PromptDialogComponent } from '../../shared/components/prompt-dialog/prompt-dialog.component';
import { MatDialog } from '@angular/material';
/**
* A general service for prompting 'yes' or 'cancel' thinks from the user.
*/
@Injectable({
providedIn: 'root'
})
2019-02-08 17:24:32 +01:00
export class PromptService {
public constructor(private dialog: MatDialog) {}
2018-10-01 15:36:16 +02:00
/**
* Opens the dialog. Returns true, if the user accepts.
* @param title The title to display in the dialog
* @param content The content in the dialog
*/
public async open(title: string, content: string): Promise<any> {
const dialogRef = this.dialog.open(PromptDialogComponent, {
width: '250px',
data: { title: title, content: content }
});
return dialogRef.afterClosed().toPromise();
}
}