Type Definitions
object
# BasePropertyProps
Example
// AdminJSOptions
const AdminJS = require('adminjs')
const ResourceModel = require('./resource-model')
const AdminJSOptions = {
resources: [{
resource: ResourceModel
options: {
properties: {
name: {
components: {
show: AdminJS.bundle('./my-react-component'),
},
},
},
},
}],
}
// my-react-component.tsx
const MyReactComponent = (props: BasePropertyProps) => {
const { record, property } = props
const value = record.params[property.path] === 'foo' ? 'bar' : 'zoe'
return (
<PropertyInShow property={property}>
{value}
</PropertyInShow>
)
}
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
property |
PropertyJSON
|
Property JSON representation |
|
resource |
ResourceJSON
|
Resource JSON representation |
|
record |
RecordJSON
|
<optional> |
Record JSON representation. Null for filter |
onChange |
OnPropertyChange
|
<optional> |
callback function which should indicate change of the field value. You can use it, when overriding edit properties. |
filter |
any
|
<optional> |
Filter object taken from the query params. It is used on the filter components. |
where |
PropertyPlace
|
Where given property should be rendered. Either of 'show' | 'list' | 'edit' | 'filter'. |
object
# EditPropertyProps
Properties:
Name | Type | Description |
---|---|---|
onChange |
OnPropertyChange
|
callback function which should indicate change of the field value. |
record |
RecordJSON
|
Record JSON representation. Null for filter |
object
# FilterPropertyProps
Properties:
Name | Type | Description |
---|---|---|
filter |
any
|
Filter object taken from the query params. It is used on the filter components |
onChange |
OnPropertyChange
|
callback function which should indicate change of the filter value. |
record |
undefined
|
# OnPropertyChange(propertyOrRecord, valueopt, selectedRecordopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
propertyOrRecord |
RecordJSON
|
string
|
property.path or updated RecordJSON object |
|
value |
any
|
<optional> |
when propertyOrRecord is a property.path, here should be an updated value. |
selectedRecord |
RecordJSON
|
<optional> |
In case of "reference" fields (with select), when they change they pass selected record object., This is mostly for an internal use - you probably wont have to use that. |
object
# ShowPropertyProps
Properties:
Name | Type | Description |
---|---|---|
property |
PropertyJSON
|
Property JSON representation |
resource |
ResourceJSON
|
Resource JSON representation |
record |
RecordJSON
|
Record JSON representation. Null for filter |