eLabSDK2.UI.Dialog
Hierarchy
-
default↳
Dialog
Methods
closeDialog
Static closeDialog(data?): Promise<any>
Close the currently open dialog.
Parameters
| Name | Type | Description |
|---|---|---|
data? | unknown | Data 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
| Name | Type | Description |
|---|---|---|
title | string | The dialog title |
contents | string | The dialog content/message |
subTitle? | string | Optional 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
| Name | Type | Description |
|---|---|---|
dialogId | string | The 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
| Name | Type | Description |
|---|---|---|
dialogId | string | The 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
| Name | Type | Description |
|---|---|---|
config | ExportSettingsDialogConfig | Configuration 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
| Name | Type | Description |
|---|---|---|
dialogConfig | SDKBasicDialogConfiguration | Dialog 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
| Name | Type | Description |
|---|---|---|
dialogConfig | SDKBasicDialogConfiguration | Dialog 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
| Name | Type | Default value | Description |
|---|---|---|---|
title | string | undefined | Dialog title shown on top |
message | string | undefined | Content of the dialog |
width? | number | 350 | Width 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
| Name | Type | Description |
|---|---|---|
title | string | Dialog title shown on top |
message | string | Content 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
| Name | Type | Description |
|---|---|---|
validationMessage | SDKValidationMessage | Validation message configuration |
Returns
void
triggerOk
Static triggerOk(): void
Trigger onOk function and close dialog.
Returns
void
© 2023 eLabNext
Updated about 18 hours ago