File

projects/maplander/shared/src/lib/components/dialog/dialog.service.ts

Index

Methods

Constructor

constructor(_dialog: MatDialog)
Parameters :
Name Type Optional
_dialog MatDialog No

Methods

alert
alert(title: string, message: string, options: literal type)
Parameters :
Name Type Optional Default value
title string No
message string No
options literal type No {accept: null}
confirm
confirm(title: string, message: string, options: literal type)
Parameters :
Name Type Optional Default value
title string No
message string No
options literal type No {accept: null, cancel: null}
withInput
withInput(title: string, message: string, options: literal type)
Parameters :
Name Type Optional Default value
title string No
message string No
options literal type No {placeholder: null, accept: null, cancel: null}
import {Injectable} from '@angular/core';
import {MatDialog} from '@angular/material/dialog';
import {DialogComponent} from './dialog.component';
import {MatDialogRef} from '@angular/material/dialog/typings/dialog-ref';
import {DialogType} from '@maplander/types';

@Injectable()
export class DialogService {

  constructor(
    private _dialog: MatDialog
  ) {
  }

  confirm(title: string, message: string, options: {
    accept: string,
    cancel: string
  } = {accept: null, cancel: null}): MatDialogRef<DialogComponent> {
    return this._dialog.open(DialogComponent,
      {
        data:
          {
            type: DialogType.CONFIRM,
            title: title,
            message: message,
            options: options
          },
        disableClose: true,
        panelClass: 'global_dialog'
      }
    );
  }

  alert(title: string, message: string, options: { accept: string } = {accept: null}): MatDialogRef<DialogComponent> {
    return this._dialog.open(DialogComponent,
      {
        data:
          {
            type: DialogType.ALERT,
            title: title,
            message: message,
            options: options
          },
        disableClose: false,
        panelClass: 'global_dialog'
      }
    );
  }

  withInput(title: string, message: string, options: {
    placeholder: string,
    accept?: string,
    cancel?: string
  } = {placeholder: null, accept: null, cancel: null}): MatDialogRef<DialogComponent> {
    return this._dialog.open(DialogComponent,
      {
        data:
          {
            type: DialogType.WITH_INPUT,
            title: title,
            message: message,
            options: options
          },
        disableClose: false,
        panelClass: 'global_dialog'
      }
    );
  }
}

result-matching ""

    No results matching ""