Skip to main content

AdminForthResourceInputCommon

Resource describes one table or collection in database. AdminForth generates set of pages for 'list', 'show', 'edit', 'create', 'filter' operations for each resource.

Extended by

Properties

columns

columns: AdminForthResourceColumnInputCommon[]

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.


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.

createFieldGroups?

optional createFieldGroups: object[]

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'.

editFieldGroups?

optional editFieldGroups: object[]

fieldGroups?

optional fieldGroups: object[]

Allows to make groups of columns in show, create and edit resource pages.

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
ParameterTypeDescription
recordanyrecord which was clicked
adminUserAdminUseruser 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[]

pageInjections.edit.beforeBreadcrumbs?

optional beforeBreadcrumbs: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.edit.bottom?

optional bottom: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.edit.threeDotsDropdownItems?

optional threeDotsDropdownItems: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.list?

optional list: object

Custom components which can be injected into resource list page.

Component accepts next props: [resource, adminUser, meta]

pageInjections.list.afterBreadcrumbs?

optional afterBreadcrumbs: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.list.beforeBreadcrumbs?

optional beforeBreadcrumbs: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.list.bottom?

optional bottom: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.list.customActionIcons?

optional customActionIcons: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.list.threeDotsDropdownItems?

optional threeDotsDropdownItems: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.show?

optional show: object

Custom components which can be injected into resource show page.

Component accepts next props: [record, resource, adminUser, meta]

pageInjections.show.afterBreadcrumbs?

optional afterBreadcrumbs: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.show.beforeBreadcrumbs?

optional beforeBreadcrumbs: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.show.bottom?

optional bottom: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

pageInjections.show.threeDotsDropdownItems?

optional threeDotsDropdownItems: AdminForthComponentDeclaration | AdminForthComponentDeclaration[]

showFieldGroups?

optional showFieldGroups: object[]


recordLabel()?

optional recordLabel: (item) => string

Hook which allow you to modify record label

Example:

recordLabel: (record) => `${record.name} - ${record.id}`,

Parameters

ParameterType
itemany

Returns

string


resourceId?

optional resourceId: string

Unique identifier of resource. By default it equals to table name in database. If you wish you can explicitly set it to any string. We added to support cases when 2 datasources have tables with the same name.


table

table: string

Table name in database which will be used to fetch data from. Might be case sensitive.