AdminForthBulkAction
Extends
Properties
action()
action: (
__namedParameters) =>Promise<{error?:string;ok:boolean;successMessage?:string; }>
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 | { adminUser: AdminUser; resource: AdminForthResource; selectedIds: any[]; tr: (key, category?, params?) => string; } |
__namedParameters.adminUser | AdminUser |
__namedParameters.resource | AdminForthResource |
__namedParameters.selectedIds | any[] |
__namedParameters.tr | (key, category?, params?) => string |
Returns
Promise<{ error?: string; ok: boolean; successMessage?: string; }>
allowed()?
optionalallowed: (__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 | { adminUser: AdminUser; allowedActions: AllowedActionsResolved; resource: AdminForthResource; selectedIds?: any[]; } | - |
__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: options: \{ bulkActions: [ \{ label: 'Mark as read', action: async (\{ resource, recordIds \}) => \{ await markAsRead(recordIds); \}, allowed: (\{ allowedActions \}) => allowedActions.edit, \} ], allowedActions: \{ edit: (\{ resource, adminUser, recordIds \}) => \{ return adminUser.dbUser.role === 'superadmin'; \} \} \} |
__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>
badge?
optionalbadge:string
Optional small badge for button which will be displayed in the list view
Inherited from
AdminForthBulkActionCommon.badge
buttonCustomCssClass?
optionalbuttonCustomCssClass:string
Add custom class
Inherited from
AdminForthBulkActionCommon.buttonCustomCssClass
confirm?
optionalconfirm:string
Confirmation message which will be displayed to user before action is executed.
Inherited from
AdminForthBulkActionCommon.confirm
icon?
optionalicon:string
Icon for action button which will be displayed in the list view
Inherited from
AdminForthBulkActionCommon.icon
id?
optionalid:string
Inherited from
label
label:
string
Label for action button which will be displayed in the list view
Inherited from
AdminForthBulkActionCommon.label
showInThreeDotsDropdown?
optionalshowInThreeDotsDropdown:boolean
Show in three dots dropdown menu in list view.
Inherited from
AdminForthBulkActionCommon.showInThreeDotsDropdown
successMessage?
optionalsuccessMessage:string
Success message which will be displayed to user after action is executed.