AdminForthBulkAction
Extends
Properties
action()
action: (
__namedParameters
) =>Promise
<object
>
Callback which will be called on backend when user clicks on action button. It should return Promise which will be resolved when action is done.
Parameters
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.adminUser | AdminUser |
__namedParameters.resource | AdminForthResource |
__namedParameters.selectedIds | any [] |
__namedParameters.tr | (key , category ?, params ?) => string |
Returns
Promise
<object
>
error?
optional
error:string
ok
ok:
boolean
successMessage?
optional
successMessage:string
allowed()?
optional
allowed: (__namedParameters
) =>Promise
<boolean
>
Allowed callback called to check whether action is allowed for user.
- It called first time when user goes to list view. If callback returns false, action button will be hidden on list view.
- This same callback called second time when user clicks an action button. If callback returns false, action will not be executed. In second time selectedIds will be passed to callback (because checkbox for items are selected), so you can use this to make additional checks ( for example to check if user has permission for certain records ).
Example:
allowed: async ({ resource, adminUser, selectedIds }) => {
if (adminUser.dbUser.role !== 'superadmin') {
return false;
}
return true;
}
Parameters
Parameter | Type | Description |
---|---|---|
__namedParameters | object | - |
__namedParameters.adminUser | AdminUser | Admin user object |
__namedParameters.allowedActions | AllowedActionsResolved | Allowed standard actions for current user resolved by calling allowedActions callbacks if they are passed. You can use this variable to rely on standard actions permissions. E.g. if you have custom actions "Mark as read", you might want to allow it only for users who have "edit" action allowed: Example:
|
__namedParameters.resource | AdminForthResource | - |
__namedParameters.selectedIds ? | any [] | recordIds will be passed only once user tries to perform bulk action by clicking on button |
Returns
Promise
<boolean
>
confirm?
optional
confirm:string
Confirmation message which will be displayed to user before action is executed.
Inherited from
AdminForthBulkActionCommon
. confirm
icon?
optional
icon:string
Icon for action button which will be displayed in the list view
Inherited from
AdminForthBulkActionCommon
. icon
id?
optional
id:string
Inherited from
AdminForthBulkActionCommon
. id
label
label:
string
Label for action button which will be displayed in the list view
Inherited from
AdminForthBulkActionCommon
. label
state
state:
string
Inherited from
AdminForthBulkActionCommon
. state
successMessage?
optional
successMessage:string
Success message which will be displayed to user after action is executed.