ScifeonDialog
This class is used for showing dialogs (or popups). The class is wrapping the Aurelia Dialog-plugin, which is why there are some references to the documentation of this.
Example
Section titled “Example”Methods
Section titled “Methods”open(options: any): DialogOpenPromise<DialogOpenResult | DialogCancelResult>
Section titled “open(options: any): DialogOpenPromise<DialogOpenResult | DialogCancelResult>”Parameters
optionsAn object with the following possible values:
options = { lock: boolean, // If false, the dialog can be closes by pressing ESC or clicking the overlay model: any, // An object passed to the activate() method of the view model viewModel: any, // The view model view: string, // A HTML string, typically just the view corresponding to the view model style: string, // A CSS string, e.g. 'width: 800px;' header: string, // A HTML string footer: string // A HTML string - defaults to an OK and Cancel button};Returns
A DialogClosePromise, with the method .whenClosed(result => ...).
Example
import { MyDialogViewModel } from './my-dialog-view-model';... openDialog() { this.dialog.open({ viewModel: MyDialogViewModel, view: require('./my-dialog-view-model.html') }).whenClosed(result => /* do something with the result */); }...confirm(question: string): Promise<boolean>
Section titled “confirm(question: string): Promise<boolean>”Show a simple popup with the question and ‘Yes’ and ‘No’ buttons.
Parameters
questionThe question to show.
Returns
Returns true or false through a promise.
Example
... async openConfirmDialog() { const result = await this.dialog.confirm('Yes or no?'); if (result) { // do something when Yes is pressed } else { // do something else when No is pressed } }...message(message: string): DialogOpenPromise<DialogOpenResult | DialogCancelResult>
Section titled “message(message: string): DialogOpenPromise<DialogOpenResult | DialogCancelResult>”Show a simple popup with the message and an ‘OK’ button.
Parameters
messageThe message to show.
Returns
Returns a promise with a true value.
Example
... async openMessageDialog() { const result = await this.dialog.message('A message'); if (result) { // do something when the message has been shown } }...close(ok: boolean = true, object: any = null): void
Section titled “close(ok: boolean = true, object: any = null): void”Closes the current dialog.
Parameters
okWhether the result should be ok or not.objectThe object to return to the callee of the current dialog.
cancel(output: any = null): void
Section titled “cancel(output: any = null): void”Cancels (and closes) the current dialog.
Parameters
objectThe object to return to the callee of the current dialog.
ok(output: any = null): void
Section titled “ok(output: any = null): void”Closes the current dialog with an OK value.
Parameters
objectThe object to return to the callee of the current dialog.