xrm-alerts
Version:
Custom alerts and popup windows for Dynamics 365/CRM
55 lines (54 loc) • 3.43 kB
TypeScript
interface ContentFrame extends Window {
getResponse(): object;
}
interface Button {
label: string;
callback?: () => void;
setFocus?: boolean;
preventClose?: boolean;
internalId?: string;
}
type ButtonList = Button[];
type IconType = "INFO" | "WARNING" | "ERROR" | "SUCCESS" | "QUESTION" | "LOADING" | "NONE";
type Nullable<T> = T | undefined;
declare class AlertManager {
private readonly iconTypeToClassMap;
private isInitialised;
private crmContext;
private context;
private jQuery;
// purpose: display an alert style dialog for the user using a styled CRM lightbox
// Allows for custom buttons and callbacks
// title = Main big message
// message = (optional) Sub-heading shown below the title
// icon = (optional, defaults to none) Displays a custom icon on the alert: INFO, WARNING, ERROR, SUCCESS, QUESTION, LOADING
// buttons = (otional, defaults to 'Ok') Array of buttons and callback functions for each button. Callbacks optional. E.g. [{label: "OK", callback: function(){}},{label: "Cancel"}]
// width = (optional, defaults to 500) Custom width of the dialog
// height = (optional, defaults to 250) Custom height of the dialog
// padding = (optional, defaults to 20) Sets the amount of padding around the light-box. Set to 0 for no padding (on iframes etc)
// preventCancel = (optional, defaults to false) Hides the 'X' in the top right corner, meaning you can only dismiss the alert using the buttons
show(title?: string, message?: string, buttons?: ButtonList, icon?: IconType, preventCancel?: boolean, width?: number, height?: number, padding?: number): void;
showIFrame(iframeUrl: string, width?: number, height?: number, padding?: number, title?: string, buttons?: ButtonList, preventCancel?: boolean): void;
showWebResource(webResourceName: string, title?: string, buttons?: ButtonList, preventCancel?: boolean, width?: number, height?: number, padding?: number, baseUrl?: string): void;
showDialogProcess(dialogId: string, entityName: string, recordId: string, callback?: () => void, width?: number, height?: number, baseUrl?: string): void;
showLoading(): void;
// Hide the alert manually without performing any callbacks
hide(subgridCall?: boolean): void;
// Encode the Title or Message to display xml tags, e.g. from a plugin error trace
// Also replaces javascript line breaks with <br>
htmlEncode(text: string): string;
// Get the CRM window from inside an iframe to access custom functions, e.g. parent.Alert.getCrmWindow().doSomething();
getCrmWindow(): Nullable<Window>;
setButtonEnabled(internalId: string, isEnabled: boolean, childCall: boolean): void;
// Use the returned iframe context with jQuery to get data from the iframe, i.e. this.$("#something", Alert.getIFrameContext().document);
getIFrameWindow(subgridCall?: boolean): Nullable<ContentFrame>;
getIFrameResponse(subgridCall?: boolean): Nullable<object>;
// Custom jQuery wrapper to use jquery from the parent CRM page to access elements from the top page where Alertjs is
private $;
// Calculates the height of the sub-heading/message based on other variables
private calculateMessageHeight;
// Internal button click event
private buttonClicked;
}
declare const Alert: AlertManager;
export { Alert as default, ContentFrame, Button, ButtonList, IconType, Nullable };