ResourceOptionsInput
General options for resource.
Extends
Omit<NonNullable<AdminForthResourceInputCommon["options"]>,"allowedActions"|"bulkActions">
Properties
actions?
optionalactions:AdminForthActionInput[]
Array of actions which will be displayed in the resource.
Example:
actions: [
{
name: 'Auto submit',
allowed: ({ adminUser, standardAllowedActions }) => {
return adminUser.dbUser.role === 'superadmin';
},
action: ({ adminUser, resource, recordId, adminforth, extra, tr }) => {
console.log("auto submit", recordId, adminUser);
return { ok: true, successMessage: "Auto submitted" };
},
showIn: {
list: true,
showButton: true,
showThreeDotsMenu: true,
},
},
]
Overrides
Omit.actions
allowedActions?
optionalallowedActions:AllowedActionsInput
Allowed actions for resource.
Example:
allowedActions: {
create: ({ resource, adminUser }) => {
// Allow only superadmin to create records
return adminUser.dbUser.role === 'superadmin';
},
delete: false, // disable delete action for all users
}
bulkActions?
optionalbulkActions:AdminForthBulkAction[]
Custom bulk actions list. Bulk actions available in list view when user selects multiple records by using checkboxes.
createFieldGroups?
optionalcreateFieldGroups:FieldGroup[]
Inherited from
Omit.createFieldGroups
defaultSort?
optionaldefaultSort:object
Default sort for list view. Example:
import { AdminForthSortDirections } from 'adminforth';
...
defaultSort: {
columnName: 'created_at',
direction: AdminForthSortDirections.ASC,
}
columnName
columnName:
string
Column name which will be used to sort records.
direction
direction:
string
Direction of sorting. Can be 'asc' or 'desc'.
Inherited from
Omit.defaultSort
editFieldGroups?
optionaleditFieldGroups:FieldGroup[]
Inherited from
Omit.editFieldGroups
fieldGroups?
optionalfieldGroups:FieldGroup[]
Allows to make groups of columns in show, create and edit resource pages.
Inherited from
Omit.fieldGroups
listBufferSize?
optionallistBufferSize:number
Buffer size for virtual scroll in list view.
Inherited from
Omit.listBufferSize
listPageSize?
optionallistPageSize:number
Page size for list view
Inherited from
Omit.listPageSize
listRowsAutoRefreshSeconds?
optionallistRowsAutoRefreshSeconds:number
Whether to refresh existing list rows automatically every N seconds.
Inherited from
Omit.listRowsAutoRefreshSeconds
listTableClickUrl()?
optionallistTableClickUrl: (record,adminUser) =>Promise<string>
Callback to define what happens when user clicks on record in list view.
By default show view will be opened.
If you wish to open custom page, return URL to the custom page (can start with https://, or relative adminforth path)
If you wish to open page in new tab, add target=_blank get param to returned URL, example:
listTableClickUrl: async (record, adminUser) => {
return `https://google.com/search?q=${record.name}&target=_blank`;
}
If you wish to do nothing on click, return null.
Example:
listTableClickUrl: async (record, adminUser) => {
return null;
}
Parameters
| Parameter | Type | Description |
|---|---|---|
record | any | record which was clicked |
adminUser | AdminUser | user who clicked |
Returns
Promise<string>
Inherited from
Omit.listTableClickUrl
listVirtualScrollEnabled?
optionallistVirtualScrollEnabled:boolean
Whether to use virtual scroll in list view.
Inherited from
Omit.listVirtualScrollEnabled
pageInjections?
optionalpageInjections:object
Custom components which can be injected into AdminForth CRUD pages. Each injection is a path to a custom component which will be displayed in the admin panel. Can be also array to render multiple injections one after another.
Example:
pageInjections: {
list: {
beforeBreadcrumbs: '@@/Announcement.vue',
}
}
create?
optionalcreate:object
Custom components which can be injected into resource create page.
Component accepts next props: [resource, adminUser, meta]
create.afterBreadcrumbs?
optionalafterBreadcrumbs:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
create.beforeBreadcrumbs?
optionalbeforeBreadcrumbs:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
create.bottom?
optionalbottom:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
create.saveButton?
optionalsaveButton:AdminForthComponentDeclaration
Custom Save button component for Create page. Accepts props: [record, resource, adminUser, meta, saving, validating, isValid, disabled, saveRecord]
create.threeDotsDropdownItems?
optionalthreeDotsDropdownItems:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
edit?
optionaledit:object
Custom components which can be injected into resource edit page.
Component accepts next props: [record, resource, adminUser, meta]
edit.afterBreadcrumbs?
optionalafterBreadcrumbs:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
edit.beforeBreadcrumbs?
optionalbeforeBreadcrumbs:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
edit.bottom?
optionalbottom:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
edit.saveButton?
optionalsaveButton:AdminForthComponentDeclaration
Custom Save button component for Edit page. Accepts props: [record, resource, adminUser, meta, saving, validating, isValid, disabled, saveRecord]
edit.threeDotsDropdownItems?
optionalthreeDotsDropdownItems:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
list?
optionallist:object
Custom components which can be injected into resource list page.
Component accepts next props: [resource, adminUser, meta]
list.afterBreadcrumbs?
optionalafterBreadcrumbs:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
list.beforeActionButtons?
optionalbeforeActionButtons:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
list.beforeBreadcrumbs?
optionalbeforeBreadcrumbs:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
list.bottom?
optionalbottom:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
list.customActionIcons?
optionalcustomActionIcons:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
list.tableBodyStart?
optionaltableBodyStart:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
list.threeDotsDropdownItems?
optionalthreeDotsDropdownItems:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
show?
optionalshow:object
Custom components which can be injected into resource show page.
Component accepts next props: [record, resource, adminUser, meta]
show.afterBreadcrumbs?
optionalafterBreadcrumbs:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
show.beforeBreadcrumbs?
optionalbeforeBreadcrumbs:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
show.bottom?
optionalbottom:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
show.threeDotsDropdownItems?
optionalthreeDotsDropdownItems:AdminForthComponentDeclaration|AdminForthComponentDeclaration[]
Inherited from
Omit.pageInjections
showFieldGroups?
optionalshowFieldGroups:FieldGroup[]
Inherited from
Omit.showFieldGroups