Skip to content

Reactive configuration #163

@benmerckx

Description

@benmerckx

Figure out how we can support configuration that depends on the value of the field or values of the entry it belongs to. Example:

select('Status', {
  width: 0.2,
  initialValue: 'draft',
  options(entry) {
    if (entry.status === 'something') return {sent: 'Different options'}
    return {
      draft: 'Draft',
      sent: 'Sent'
    }
  },
  readOnly(entry) {
    return entry.status === 'sent'
  },
  visible(entry) {
    return entry.status !== 'paid' && entry.status !== 'credited'
  }
})

The type of entry cannot be inferred in any way so it will have to be user supplied. We might possibly use to the generated types but that could cause potential circular issues with typescript compiler. Especially if it changes the underlying value, like in the options example above it will be impossible and we'll have to force a return type. We'll need a section in the docs that highlights how to manage these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions