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.type
and the records, more specifically, pass in the selected records, loaded records or the current record.
- Set the correct
- For data actions:
- For
Records
level data action:- Use the passed in
records
, the records are always not empty.
- Use the passed in
- For
DataSource
level data action:- Always process all of the data despite the passed-in records.
- For
Properties
Property | Type | Notes |
---|---|---|
() => void | This method will be invoked when the widget that provides the action is removed. | |
string | IconResult | The action icon. | |
string | The unique ID. For widget-provided actions, the ID is the combination of the widget ID and action name. | |
IntlShape | The | |
(dataSets: DataRecordSet[], dataLevel: DataLevel, widgetId: string) => Promise<boolean> | Will be invoked to determine whether the data action can process the data. | |
boolean | Whether the action is watching the data sets change. If the action is watching the data sets change, the | |
string | The user readable-label for the action. | |
string | The action name. | |
(dataSets: DataRecordSet[], widgetId: string) => 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. | |
(dataSets: DataRecordSet[], dataLevel: DataLevel, widgetId: string, actionConfig?: any) => Promise<boolean | ReactElement<any, string | JSXElementConstructor<any>>> | This is the action logic. | |
boolean | Whether the action can be used by the widget that provides the action. | |
string | The widget ID that provides the action. If no widget ID is provided, the action is provided by the framework. |
destroy
Interface Propertydestroy: () => void
This method will be invoked when the widget that provides the action is removed.
Type declaration
function(): void
Returns
void
id
Interface Propertyid: string
The unique ID. For widget-provided actions, the ID is the combination of the widget ID and action name.
isSupported
Interface PropertyisSupported: (dataSets: DataRecordSet[], dataLevel: DataLevel, widgetId: string) => Promise<boolean>
Will be invoked to determine whether the data action can process the data.
Type declaration
function(dataSets: DataRecordSet[], dataLevel: DataLevel, widgetId: string): Promise<boolean>
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>
true
if the data action can process the data.
isWatchingDataSetsChange
isWatchingDataSetsChange: boolean
Whether the action is watching the data sets change. If the action is watching the data sets change, the onDataSetsChange
method will be invoked when the data sets change.
onDataSetsChange
onDataSetsChange: (dataSets: DataRecordSet[], widgetId: string) => 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.
Type declaration
function(dataSets: DataRecordSet[], widgetId: string): void
Parameters
Parameter | Type | Notes |
---|---|---|
data | DataRecordSet[] | The data sets that will be processed. |
widget | string | The widget id that use the data actions. |
Returns
void
onExecute
Interface PropertyonExecute: (dataSets: DataRecordSet[], dataLevel: DataLevel, widgetId: string, actionConfig?: any) => Promise<boolean | ReactElement<any, string | JSXElementConstructor<any>>>
This is the action logic.
Type declaration
function(dataSets: DataRecordSet[], dataLevel: DataLevel, widgetId: string, actionConfig?: any): Promise<boolean | ReactElement<any, string | JSXElementConstructor<any>>>
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<any, string | JSXElementConstructor<any>>>
true
if the action is executed successfully. If the action needs to show a dialog, return the dialog content.