Auto-generated admin panel for node.js with react BasePropertyComponent

Components

<BasePropertyComponent />

Type Definitions

object

# BasePropertyProps

Props which are passed to all your custom property components

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

View Source adminjs/src/frontend/components/property-type/base-property-props.ts, line 8

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

View Source adminjs/src/frontend/components/property-type/base-property-props.ts, line 91