Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive configuration #163

Closed
benmerckx opened this issue Jun 14, 2022 · 0 comments · Fixed by #364
Closed

Reactive configuration #163

benmerckx opened this issue Jun 14, 2022 · 0 comments · Fixed by #364

Comments

@benmerckx
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant