eLabSDK2.UI.Dialog

Hierarchy

  • default

    Dialog

Methods

closeDialog

Static closeDialog(data?): Promise<any>

Close the currently open dialog.

Parameters

NameTypeDescription
data?unknownData to pass back when closing the dialog

Returns

Promise<any>

A promise that resolves when the dialog is closed


confirm

Static confirm(title, contents, subTitle?): Promise<unknown>

Display a confirmation dialog with OK and Cancel buttons.

Parameters

NameTypeDescription
titlestringThe dialog title
contentsstringThe dialog content/message
subTitle?stringOptional subtitle to display

Returns

Promise<unknown>

A promise that resolves with user's choice (true for OK, false for Cancel)


getDialogContainer

Static getDialogContainer(dialogId): HTMLElement

Get dialog container DOM element by dialog id.

Parameters

NameTypeDescription
dialogIdstringThe element id of the dialog

Returns

HTMLElement

A dialog container DOM element, or null if not found.


getDialogFooter

Static getDialogFooter(dialogId): HTMLElement

Get dialog footer DOM element by dialog id.

Parameters

NameTypeDescription
dialogIdstringThe element id of the dialog

Returns

HTMLElement

A dialog footer DOM element, or null if not found.


openExportSettingsDialog

Static openExportSettingsDialog(config): Promise<ExportSettings>

Display the export settings modal.

Parameters

NameTypeDescription
configExportSettingsDialogConfigConfiguration object in which you can specify fileType with the default export fileType ('CSV', 'XLSX', 'PDF').

Returns

Promise<ExportSettings>

A promise that resolves with export settings


showConfirmDialog

Static showConfirmDialog(dialogConfig): Promise<any>

Display a Confirm type modal dialog to get extra consent by the user.

Parameters

NameTypeDescription
dialogConfigSDKBasicDialogConfigurationDialog configuration object

Returns

Promise<any>

A promise that resolves when the dialog is interacted with


showDialog

Static showDialog(dialogConfig): Promise<any>

Display a generic dialog

Parameters

NameTypeDescription
dialogConfigSDKBasicDialogConfigurationDialog configuration object

Returns

Promise<any>

A promise that when resolved contains the dialog result.

Example

eLabSDK2.UI.Dialog.showDialog({
  id: 'confirm-action',
  title: 'Confirm Action',
  content: '<p>Are you sure you want to proceed with this action?</p>',
  width: '50vw',
  notices: [{
    id: 'warning-notice',
    style: 'warning',
    contents: 'This action cannot be undone',
    title: 'Warning',
    icon: 'fas fa-exclamation-triangle',
    isVisible: () => true
  }],
  buttons: {
    ok: {
      id: 'confirm-btn',
      label: 'Confirm',
      onClick: () => {
        console.log('Action confirmed');
        return Promise.resolve(true); // Return Promise<boolean> to close dialog
      }
    },
    cancel: {
      id: 'cancel-btn',
      label: 'Cancel',
      onClick: () => {
        console.log('Action cancelled');
        return Promise.resolve();
      }
    }
  },
  onRendered: () => {
    console.log('Dialog rendered');
  },
  useValidation: true
}).then((result) => {
  console.log('Dialog closed with result:', result);
});

showErrorDialog

Static showErrorDialog(title, message, width?): Promise<any>

Display a Error type modal dialog to inform the user of an error. This modal closes on ok without any logic.

Parameters

NameTypeDefault valueDescription
titlestringundefinedDialog title shown on top
messagestringundefinedContent of the dialog
width?number350Width of the dialog in pixels

Returns

Promise<any>

A promise that resolves when the dialog is closed


showInfoDialog

Static showInfoDialog(title, message): Promise<any>

Display a Info type modal dialog to inform the user. This modal closes on ok without any logic.

Parameters

NameTypeDescription
titlestringDialog title shown on top
messagestringContent of the dialog

Returns

Promise<any>

A promise that resolves when the dialog is closed


showValidationMessage

Static showValidationMessage(validationMessage): void

Display a validation error message below a form field.

Parameters

NameTypeDescription
validationMessageSDKValidationMessageValidation message configuration

Returns

void


triggerOk

Static triggerOk(): void

Trigger onOk function and close dialog.

Returns

void


© 2023 eLabNext