Admin UI
Show View

Show view

Optiontypedefaultdescription
fields(string|FieldConfig)[]see belowwhat fields to show in the view and how they should be rendered
assocFrom(string|UiAssocFromConfig)[]all assoFrom relationswhat assocFrom to include and how to render on the show view
commentsbooleantruewhether to include a section for showing /
adding comments for the entity on the show view

Fields

Per default the show view contains (beside the assocFrom tables)

  • all attributes of the entity except id, createdAt, updatedAt
  • all assocTo items
  • all assocToMany items

in unreliable order - although usually in the order of the definition of the attributes in the domain configuration.

You can state which field and which order should be rendered by giving an array of either the field or assoc names (with default behavior) or FieldConfig objects which allows you to control nearly every aspect of rendering.

adminConfig:AdminConfig = {
  entities: {
    Car: {
      show: {
        fields: ['Driver', 'license', 'color', 'mileage']
      }
    }
  }
}

FieldConfig

Optiontypedefaultdescription
namestringthe name of the attribute or entity of the assoc or assocToMany
typestringthe type from the domain configurationthe type of the attribute or entity of the assoc
labelstring | ()=>stringlookup in resources or humanized field namethe label for the field
listbooleandependent from the attribute / assoc type in the domainConfigurationthe column label for the field
renderFunctionuses renderValue / renderListreturns the string-value that should be displayed in the index table
renderValueFunctiontype aware content (as link if assoc)returns the string-value of exactly one value (e.g. from array values) that should be displayed in the view
renderListFunctioncomma-separated valuesif more than one value, gets the (rendered) values and returns the (combined) string-value that should be displayed in the view
valueanyitem[field]gets the value (as is) from the item
querystringattribute or indication for assocpart of the query of the view to add for this field's value

Label

If you do not provide a label, the default label will be looked up under this path in the resources of the AdminConfig.

['resources', locale, 'entities', entity, 'label', field]

If no such entry exists, the humanized attribute name of the entity or the humanized name of the assoc entity will be used.

Render

Let's say you want to render the color attribute in the respective color itself. A (admittedly trivial) implementation could be:

adminConfig:AdminConfig = {
  entities: {
    Car: {
      show: {
        fields: [
          'license', 
          { name: 'color', render: (item:any) => `<span style="color: ${item.color}">${item.color}</span>` }, 
          'mileage', 
          'Driver'
        ]
      }
    }
  }
}

assocFrom

Per default the show view will render every assocFrom as a child-table with the same fields as on the index view of the associated entity.

You can define which assocFrom tables, in which order and with which fields to render by providing this configuration.

Optiontypedefaultdescription
entitystringthe entity of the assocFrom relationship
fields(string|FieldConfig)[]see fields for indexwhat fields to show in the table and how they should be rendered
queryQueryFndefault query for the index action of the assocFrom relationshipcustom query
searchbooleantrue if > 10 itemswhether to offer client side search of the table
orderOrderType1st column ascwhich column should be sorted initially
filterFilterTypefilter for the table - same as in index view but performed on the client
entitystringthe entity of the assocFrom relationship
showAddbooleantruewhether offering the creation of a new child record for this assocFrom relationship

Example

Given the following domain configuration:

entity: 
  Car: 
    assocFrom: 
      - Driver
      - Accessory
    attributes: 
      license: Key
      color: string
  
  Driver: 
    assocTo: Car
    attributes: 
      name: string
      licenseValidTill: Date
 
  Accessory:
    assocTo: Car
    attributes: 
      name: Key
      available: boolean!

A show view configuration like this

adminConfig:AdminConfig = {
  entities: {
    Car: {
      show: {
        assocFrom: [
          'Driver', 
          { 
            entity: 'Accessory', 
            fields: [
              'name', 
              { name: 'available', render: (item:any) => item['available'] ? '🙂' : '🙁' }
            ], 
            search: false
          }
        ]
      }
    }
  }
}

would

  • render all attributes of Car
  • the assocFrom tables for Driver and Accessory in this order
  • the Driver table same as for index action for this entity
  • the Accessory table with the fields name and available in that order
  • the field available of the Accessory table with emojis instead of true / false
  • regardless of the number of items in the Accessory table, there will be no search offered