UNPKG

@adaptabletools/adaptable

Version:

Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

127 lines (126 loc) 3.83 kB
import { FormContext, RowDataChangedInfo } from '../../types'; import { AlertButton, AlertDefinition } from '../AdaptableState/AlertState'; import { AdaptableAlert } from '../AdaptableState/Common/AdaptableAlert'; import { AdaptableForm } from '../AdaptableState/Common/AdaptableForm'; import { CellDataChangedInfo } from '../types'; /** * Options related to Alerts in Adaptable. */ export interface AlertOptions<TData = any> { /** * How many alerts held in State at any one time; when limit is breached, oldest alert will be removed * * @defaultValue 20 * @gridInfoItem * @noCodeItem */ maxAlertsInStore?: number; /** * How long (in ms) a Cell will be highlighted when an Alert fires * * @defaultValue 2000 * @gridInfoItem */ cellHighlightDuration?: number; /** * How long (in ms) a Row will be highlighted when an Alert Fires * * @defaultValue 4000 * @gridInfoItem */ rowHighlightDuration?: number; /** * How long (in ms) Alert panel in Status Bar highlights when an Alert Fires * * @defaultValue 2000 */ statusbarHighlightDuration?: number; /** * Custom onClick Handlers for Buttons (displayed in Alert Forms) */ commandHandlers?: CommandHandler<TData>[]; /** * Full definitions of Alert Forms - the names of which are provided in Alert State */ alertForms?: AlertForm<TData>[]; /** * Whether Alert rule is evaluated against the `rawValue` or `formattedValue` of the changed cell data * * @defaultValue 'rawValue' * @gridInfoItem */ dataChangeDetectionPolicy?: DataChangeDetectionPolicy; /** * Function providing Header to display in Alert; if empty, AdapTable provides dynamically */ alertMessageHeader?: (alertMessageContext: AlertMessageContext<TData>) => string | undefined; /** * Function providing Message to display in Alert; if empty, AdapTable provides dynamically */ alertMessageText?: (alertMessageContext: AlertMessageContext<TData>) => string | undefined; /** * Shows Alert if Primary Key column in Adaptable Options is not present or incorrect * * @defaultValue false * @gridInfoItem * @noCodeItem * @uiLabel Show Missing Primary Key Warning */ showMissingPrimaryKeyAlert?: boolean; } /** * Cell Change that will trigger an Alert: can be 'rawValue' or 'formattedValue' */ export type DataChangeDetectionPolicy = 'rawValue' | 'formattedValue'; /** * Handles an Alert Form Command */ export type CommandHandler<TData = any> = { /** * Name of the Handler */ name: string; /** * Handler function to call when the Button is clicked */ handler: (button: AlertButton<AlertFormContext<TData>>, context: AlertFormContext<TData>) => void; }; /** * Form to show in an Alert */ export type AlertForm<TData = any> = { /** * Name of the Form */ name: string; /** * The Form to display in the Alert */ form: AdaptableForm<AlertFormContext<TData>>; }; /** * Context required by functions when using an Alert Button */ export interface AlertFormContext<TData = any> extends FormContext { /** * Alert that has been triggered */ alert: AdaptableAlert<TData>; } /** * Context used for creating bespoke Alert messages */ export interface AlertMessageContext<TData = any> { /** * Current Alert Definition */ alertDefinition: AlertDefinition; /** * Cell Data change that might have triggered the Alert */ cellDataChangedInfo?: CellDataChangedInfo<TData>; /** * Row Data change that might have triggered the Alert (e.g. Row Added or Removed) */ rowDataChangedInfo?: RowDataChangedInfo<TData>; }