8. Modal
Modals are blocking dialogs that require the user to take an explicit action before continuing. Use them for confirmation prompts or important warnings.
context.modal.<type>(config)
Modal types
context.modal.confirm({
title: "Delete record",
content: "Are you sure you want to delete this record? This cannot be undone.",
okText: "Delete",
okType: "danger",
cancelText: "Cancel",
onOk: async () => {
await context.deleteEntity("samples", context.router.id);
context.redirect("/samples");
}
});
context.modal.info({
title: "Information",
content: "This record has already been fiscalized and cannot be edited."
});
context.modal.warning({
title: "Unsaved changes",
content: "You have unsaved changes. Please save or discard before continuing."
});
context.modal.error({
title: "Export failed",
content: "The file could not be generated. Please contact support."
});
context.modal.success({
title: "Payment received",
content: "The invoice has been marked as paid."
});
Parameters
Prop
Type
Updating or destroying a modal programmatically
All modal methods return a handle with update and destroy methods:
const modal = context.modal.confirm({
title: "Processing...",
content: "Please wait.",
footer: null
});
await doLongTask();
modal.update({
title: "Done",
content: "The operation completed successfully."
});