itemListActionsApi
Modifies action buttons on the item list. The itemListActionsApi is exposed as a part of the event handler API.
Methods
- initialize() ⇒
undefined
- Initializes an empty collection of action buttons.
- areActionsInitialized() ⇒
Boolean
- Checks to see if the action buttons collection is initialized.
- getActions() ⇒
Array.<Action>
| null
- Returns array of actions or null if actions are not initialized.
- addDefaultActions() ⇒
undefined
- Adds default (New, Delete, Link, and Unlink) actions.
- addAction(actionType, clickHandler, options) ⇒
Action
| null
- Adds action of specific type to action buttons collection. Also, it initializes actions collection if it was not initialized before. Returns added action or null, if actionType is not of ACTION_TYPES type and clickHandler is not specified.
- removeActions(...actionTypes) ⇒
undefined
- Removes actions if they are present in the Map.
- differentiateActionsByItemListType() ⇒
undefined
- Removes actions depending on item list type.
- getGlobalVisibilityRules() ⇒
Object
| null
- Returns the button visibility rule set for the Item List object type. See Visibility Rule class
- getSublistVisibilityRules() ⇒
Object
| null
- Returns sublist button visibility rule set to the layout's object type. See Visibility Rule class
- checkActionsByVisibilityRules() ⇒
undefined
- Merges visibility rules and removes actions from child/associative lists accordingly.
- checkPermissions() ⇒
Promise
- Checks if user has permissions for each action and removes actions for which user does not have permission.
- checkRulesAndPermissions() ⇒
Promise
- Checks for item list type, visibility rules and permissions to remove actions that shouldn't been shown.
- setCustomGetDataFunction(getDataFunction) ⇒
undefined
- Supplies the given function to the item list. The item will expect the function to provide data to show in the tiem list whenever it is called. It is called with the View information and current item list state containing page, sort & filter information.
Properties Details
initialize() ⇒ undefined
Initializes an empty collection of action buttons.
areActionsInitialized() ⇒ Boolean
Checks to see if the action buttons collection is initialized.
Returns: Boolean
- True if actions are initialized, false otherwise.
Returns array of actions or null if actions are not initialized.
Returns: Array.<Action>
| null
- Array of actions or null.
addDefaultActions() ⇒ undefined
Adds default (New, Delete, Link, and Unlink) actions.
addAction(actionType, clickHandler, options) ⇒ Action
| null
Adds action of specific type to action buttons collection. Also, it initializes actions collection if it was not initialized before. Returns added action or null, if actionType is not of ACTION_TYPES type and clickHandler is not specified.
Returns: Action
| null
- Returns added action on success.
Param |
Type |
Default |
Description |
actionType |
ACTION_TYPES
|
| Action type of button to be added to the collection. See convenienceApi.constants. |
clickHandler |
function
|
|
Optional. Custom click handler that will be executed when the action button is clicked. |
options |
Object
|
| Optional. Custom action options. |
removeActions(...actionTypes) ⇒ undefined
Removes actions if they are present in the Map.
Param |
Type |
Description |
...actionTypes |
Array.<ACTION_TYPES>
|
Types of actions to be removed. See convenienceApi.constants. |
differentiateActionsByItemListType() ⇒ undefined
Removes actions depending on item list type.
getGlobalVisibilityRules() ⇒ Object
| null
Returns the button visibility rule set for the Item List object type. See Visibility Rule class
Returns: Object
| null
- Rule object.
getSublistVisibilityRules() ⇒ Object
| null
Returns sublist button visibility rule set to the layout's object type. See Visibility Rule class
Returns: Object
| null
- Rule object.
checkActionsByVisibilityRules() ⇒ undefined
Merges visibility rules and removes actions from child/associative lists accordingly.
checkPermissions() ⇒ Promise
Checks if user has permissions for each action and removes actions for which user does not have permission.
Returns: Promise
- Promise that is resolved when modifications are finished.
checkRulesAndPermissions() ⇒ Promise
Checks for item list type, visibility rules and permissions to remove actions that shouldn't been shown.
Returns: Promise
- Promise that is resolved when modifications are finished.
setCustomGetDataFunction(getDataFunction) ⇒ undefined
Supplies the given function to the item list. The item will expect the function to provide data to show in the tiem list whenever it is called. It is called with the View information and current item list state containing page, sort & filter information.
Param |
Type |
Description |
getDataFunction |
function
|
A promise function that resolves with a QueryResponse object containing the data to use to populate the item list. It has the following parameters: - ItemList <ItemList> - A Relativity Forms ItemList object representing the item list that data should be fetched for. - queryRequest <QueryRequest> - A QueryRequest object describing what data to retrieve.
|
Example
Copy
eventHandlers[eventNames.ITEM_LIST_MODIFY_ACTIONS] = function(itemListActionsApi, view) {
// To hide all actions it is needed to call initialize method.
// Otherwise, by default all rules are checked and appropriate buttons shown.
itemListActionsApi.initialize();
};
eventHandlers[eventNames.ITEM_LIST_MODIFY_ACTIONS] = function(itemListActionsApi, view) {
const USERS_LIST_ID = "usersList" ;
// Checks whether an action should be added to particular list.
if (view.ObjectTypeID === convenienceApi.constants.ARTIFACT_TYPE.USER) {
// Adds Link action and checks all needed rules and permissions.
itemListActionsApi.initialize();
itemListActionsApi.addAction(convenienceApi.constants.ACTION_TYPES.LINK);
return itemListActionsApi.checkRulesAndPermissions();
}
return void 0;
};
eventHandlers[eventNames.ITEM_LIST_MODIFY_ACTIONS] = function(itemListActionsApi, view) {
// Add default actions buttons, then find "New" and replace its title to "Create".
itemListActionsApi.addDefaultActions();
const actions = itemListActionsApi.getActions();
actions.filter(function(action) {
return action.type === convenienceApi.constants.ACTION_TYPES.NEW;
}).forEach(function(action) {
action.title = "Create" ;
});
};
eventHandlers[eventNames.ITEM_LIST_MODIFY_ACTIONS] = function(itemListActionsApi, view) {
const TITLE_OF_LIST_I_AM_LOOKING_FOR = "List of Items";
// Checks if custom data source should be defined for particular list
if (view.Name === TITLE_OF_LIST_I_AM_LOOKING_FOR) {
// Add a custom data source that shows arbitrary data
itemListActionsApi.setCustomGetDataFunction(function arbitraryCustomDataGenerator(itemList, request) {
const columnIDArray = itemList.FieldCollection.map(function getColumnID(field) {
return field.HeaderName; // The HeaderName is used by liquid as the column identifier
});
const rowDataArray = [];
const counter = 0;
// generate arbitrary data for the requested page size
for(let i = 0; i < request.pageSize; i++) {
const rowData = {};
columnIDArray.forEach(function(columnID) {
rowData[columnID] = "Cell data:" + counter.toString();
counter++;
});
rowDataArray.push(rowData);
}
return {
Results: rowDataArray,
TotalCount: rowDataArray.length
};
});
}
return void 0;
};
// This will make the item list titled 'List of Items' show this data:
// |---------------|---------------|---------------|---------------|
// | First column | Second column | Third column | Fourth column |
// |===============|===============|===============|===============|
// | Cell data: 1 | Cell data: 2 | Cell data: 3 | Cell data: 4 |
// |---------------|---------------|---------------|---------------|
// | Cell data: 5 | Cell data: 6 | Cell data: 7 | Cell data: 8 |
// |---------------|---------------|---------------|---------------|
// | Cell data: 9 | Cell data: 10 | Cell data: 11 | Cell data: 12 |
// |---------------|---------------|---------------|---------------|