UNPKG

@adaptabletools/adaptable

Version:

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

181 lines (180 loc) 5.52 kB
import { AdaptableMessageType, BaseContext, AdaptableColumnContext } from '../../types'; import { CellDataChangedInfo } from '../AdaptableState/Common/CellDataChangedInfo'; import { MathOperation } from '../AdaptableState/Common/Enums'; import { GridCell } from '../AdaptableState/Selection/GridCell'; /** * Options related to Editing in AdapTable - includes Server Validation, Smart Edit Operations and Cell Editabiility */ export interface EditOptions<TData = any> { /** * Function to validate AdapTable data edits remotely */ validateOnServer?: (serverValidationContext: ServerValidationContext<TData>) => Promise<ServerValidationResult>; /** * Whether to display message after Server Validation runs * * @defaultValue true */ displayServerValidationMessages?: boolean; /** * Function which checks if a given Grid Cell is editable */ isCellEditable?: (cellEditableContext: CellEditableContext<TData>) => boolean; /** * Columns that will display a Select dropdown when editing */ showSelectCellEditor?: (currentColumContext: AdaptableColumnContext<TData>) => boolean; /** * List of Column values to display when Editing (i.e. in Edit Lookups, Bulk Update) */ customEditColumnValues?: (context: CustomEditColumnValuesContext<TData>) => CustomEditColumnValueInfo[] | Promise<CustomEditColumnValueInfo[]>; /** * Options for Plus Minus module (keyboard increment / decrement) */ plusMinusOptions?: PlusMinusOptions; /** * Options for Smart Edit module */ smartEditOptions?: SmartEditOptions<TData>; } /** * Context used when getting Distinct Column Values for Editing */ export interface CustomEditColumnValuesContext<TData = any> extends AdaptableColumnContext<TData> { /** * Current distinct values in Column */ defaultValues: Required<CustomEditColumnValueInfo>[]; /** * Search text in Edit - used when fetching values from server */ currentSearchValue: string; /** * Currently edited Grid Cell */ gridCell: GridCell; } /** * Information about items in the Edit Controls */ export interface EditColumnValueInfo { value: any; label?: string; } /** * Information about items in the custom Edit Controls */ export interface CustomEditColumnValueInfo { value: any; label?: string; } /** * Used for Server Validation ie. after an edit in AG Grid which must be checked on Server */ export interface ServerValidationResult { /** * Header to diplay with validation * @defaultValue 'Server Validation Message', */ validationHeader?: string; /** * Message to diplay with validation */ validationMessage?: string; /** * Cell Value to use for after Server Validation */ newCellValue?: any; /** * Type of Message to Display * @defaultValue Info * */ messageType?: AdaptableMessageType; } /** * Custom Operation used in Smart Edit Module */ export type SmartEditCustomOperation<TData = any> = { /** * Name of the Custom Operation (as appears in AdapTable UI) */ name: string; /** * Custom Operation function - returns a number */ operation: (context: SmartEditOperationContext<TData>) => number; }; /** * Operation used by Smart Edit - either System or Custom */ export type SmartEditOperation = SmartEditCustomOperation | MathOperation; /** * Context used in Custom Smart Edit Operations */ export interface SmartEditOperationContext<TData = any> extends BaseContext { /** * Smart Edit value */ smartEditValue: number; /** * Current selected grid cell - contains column, row and cell value information */ currentCell: GridCell<TData>; } /** * Context used when validating data edits on Server */ export interface ServerValidationContext<TData = any> extends BaseContext { /** * Details of Cell Edit */ cellDataChangedInfo: CellDataChangedInfo<TData>; } /** * Context used when checking Cell editability */ export interface CellEditableContext<TData = any> extends BaseContext { /** * Cell being edited */ gridCell: GridCell<TData>; /** * Default editability according to the AG Grid Column Definition (`ColDef.editable`) */ defaultColDefEditableValue: boolean; } /** * Options for editing-based Plus Minus Module */ export interface PlusMinusOptions { /** * Key to increase cell value for nudges (if not overriden in Plus Minus Rule/Nudge). * * Can be a single key (e.g. `'+'`) or a keyboard shortcut combination that uses * `+` as the glue between parts (e.g. `'shift+Enter'`, `'ctrl+ArrowUp'`). * Supported modifiers are `ctrl`, `cmd`, `alt` and `shift`. * * @defaultValue '+' */ incrementKey?: string; /** * Key to decrease cell value for nudges (if not overriden in Plus Minus Rule/Nudge). * * Can be a single key (e.g. `'-'`) or a keyboard shortcut combination that uses * `+` as the glue between parts (e.g. `'shift+Backspace'`, `'ctrl+ArrowDown'`). * Supported modifiers are `ctrl`, `cmd`, `alt` and `shift`. * * @defaultValue '-' */ decrementKey?: string; } /** * Options for editing-based Smart Edit Module */ export interface SmartEditOptions<TData = any> { /** * Custom Operations to use in Smart Edit */ customOperations?: SmartEditCustomOperation<TData>[]; }