AdminForthResourceCommon
Resource describes one table or collection in database. AdminForth generates set of pages for 'list', 'show', 'edit', 'create', 'filter' operations for each resource.
Properties
columns
columns:
AdminForthResourceColumnCommon
[]
Array of columns which will be displayed in the admin panel. Each column has its own configuration.
dataSource
dataSource:
string
ID of datasource which will be used to fetch data from.
dataSourceColumns?
optional
dataSourceColumns:AdminForthResourceColumnCommon
[]
Internal array of columns which are not virtual. You should not edit it.
label?
optional
label:string
Label for resource which will be displayed in the admin panel. By default it equals to table name in database.
options?
optional
options:object
General options for resource.
allowedActions?
optional
allowedActions:AllowedActionsResolved
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?
optional
bulkActions:AdminForthBulkActionCommon
[]
Custom bulk actions list. Bulk actions available in list view when user selects multiple records by using checkboxes.
createEditGroups?
optional
createEditGroups:object
[]
Allows to make groups of columns in create/edit resource pages.
defaultSort?
optional
defaultSort:object
Default sort for list view. Example:
import { AdminForthSortDirections } from 'adminforth';
...
defaultSort: {
columnName: 'created_at',
direction: AdminForthSortDirections.ASC,
}
defaultSort.columnName
columnName:
string
Column name which will be used to sort records.
defaultSort.direction
direction:
string
Direction of sorting. Can be 'asc' or 'desc'.
listPageSize?
optional
listPageSize:number
Page size for list view
listRowsAutoRefreshSeconds?
optional
listRowsAutoRefreshSeconds:number
Whether to refresh existing list rows automatically every N seconds.
listTableClickUrl()?
optional
listTableClickUrl: (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
>
pageInjections?
optional
pageInjections: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',
}
}
pageInjections.create?
optional
create:object
Custom components which can be injected into resource create page.
Component accepts next props: [resource, adminUser, meta]
pageInjections.create.afterBreadcrumbs?
optional
afterBreadcrumbs:AdminForthComponentDeclaration
|AdminForthComponentDeclaration
[]
pageInjections.create.beforeBreadcrumbs?
optional
beforeBreadcrumbs:AdminForthComponentDeclaration
|AdminForthComponentDeclaration
[]
pageInjections.create.bottom?
optional
bottom:AdminForthComponentDeclaration
|AdminForthComponentDeclaration
[]
pageInjections.create.threeDotsDropdownItems?
optional
threeDotsDropdownItems:AdminForthComponentDeclaration
|AdminForthComponentDeclaration
[]
pageInjections.edit?
optional
edit:object
Custom components which can be injected into resource edit page.
Component accepts next props: [record, resource, adminUser, meta]
pageInjections.edit.afterBreadcrumbs?
optional
afterBreadcrumbs:AdminForthComponentDeclaration
|AdminForthComponentDeclaration
[]