Interface
A data action is a piece code that can process data. It can process the whole data source, some data records, or both (determined by the isSupported method).
A data action can receive multiple data sets, but the data action can decide whether it supports multiple data sets or not.
The isSupported method is invoked first to test whether the data action can process the provided data.
The onExecute method will be invoked when an user click the action menu.
Both of these two methods are passed in the DataRecordSet and DataLevel parameters, the widget that uses the data action decides how to pass in DataRecordSet ,
and the action can decide how to process the data.
Widgets should use the DataActionList component to use the data actions.
Although the data action can be very flexible, for consistent UX, these guides should be followed:
- For widgets that use data actions:
- Set the correct
DataRecordSet.typeand the records, more specifically, pass in the selected records, loaded records or the current record.
- Set the correct
- For data actions:
- For
Recordslevel data action:- Use the passed in
records, the records are always not empty.
- Use the passed in
- For
DataSourcelevel data action:- Always process all of the data despite the passed-in records.
- For
Properties
| Property | Type | Notes |
|---|---|---|
icon | string | IconResult | The action icon. |
id | string | The unique ID. For widget-provided actions, the ID is the combination of the widget ID and action name. |
intl | IntlShape | The |
isWatchingDataSetsChange | boolean | Whether the action is watching the data sets change. If the action is watching the data sets change, the |
label | string | The user readable-label for the action. |
name | string | The action name. |
supportProviderWidget | boolean | Whether the action can be used by the widget that provides the action. |
widgetId | string | The widget ID that provides the action. If no widget ID is provided, the action is provided by the framework. |
Methods
| Method | Returns | Notes |
|---|---|---|
destroy() | void | This method will be invoked when the widget that provides the action is removed. |
isSupported(dataSets, dataLevel, widgetId) | Promise<boolean> | Will be invoked to determine whether the data action can process the data. |
onDataSetsChange(dataSets, widgetId) | void | This method will be invoked when the data sets change and the action is watching the data sets change. Please make sure check the widget ID before processing the data sets. |
onExecute(dataSets, dataLevel, widgetId, actionConfig?) | Promise<boolean | ReactElement<unknown, string | JSXElementConstructor<any>>> | This is the action logic. |
destroy
Interface Methoddestroy(): voidThis method will be invoked when the widget that provides the action is removed.
Returns
voidisSupported
Interface MethodisSupported(dataSets: DataRecordSet[], dataLevel: DataLevel, widgetId: string): Promise<boolean>Will be invoked to determine whether the data action can process the data.
Parameters
| Parameter | Type | Notes |
|---|---|---|
data | DataRecordSet[] | The data sets that will be processed. |
data | DataLevel | The data level that will be processed. |
widget | string | The widget id that use the data actions. |
Returns
Promise<boolean>onDataSetsChange
onDataSetsChange(dataSets: DataRecordSet[], widgetId: string): voidThis method will be invoked when the data sets change and the action is watching the data sets change. Please make sure check the widget ID before processing the data sets.
Parameters
| Parameter | Type | Notes |
|---|---|---|
data | DataRecordSet[] | The data sets that will be processed. |
widget | string | The widget id that use the data actions. |
Returns
voidonExecute
Interface MethodonExecute(dataSets: DataRecordSet[], dataLevel: DataLevel, widgetId: string, actionConfig?: any): Promise<boolean | ReactElement<unknown, string | JSXElementConstructor<any>>>This is the action logic.
Parameters
| Parameter | Type | Notes |
|---|---|---|
data | DataRecordSet[] | The data sets that will be processed. |
data | DataLevel | The data level that will be processed. |
widget | string | The widget id that use the data actions. |
action | any | The action config that is set by the user. Not all actions have the config. |
Returns
Promise<boolean | ReactElement<unknown, string | JSXElementConstructor<any>>>