eclipsesource / eclipsesource/jsonforms

Programmatic builder pattern UISchema alternative

Open
#2,338 1 comment 0 reactions 0 assignees View on GitHub
core enhancement
Dominant language
TypeScript
Stars
2.7k
Forks
424
Avg merge
17d 8h
Merged PRs (30d)
1

Description

### Is your feature request related to a problem? Please describe.

I like the simple idea of jsonforms, but the uischema json-configuration seems to be verbose, and includes a lot of property-references, and the and/or-language of the visibility/enablement is very limited. I realize the choice of json for this is LITERALLY in the project name, but I belive a programmatic approach may be a better solution.

### Describe the solution you'd like

I have been working on an alternative approach. This approach is also typesafe, if a typescript-version of the schema is generated (typically using plugins during build-time). I now have a runnable proof-of-concept, where the uischema is programmatic:

```
export const eksempeluischema = new VerticalLayoutDef((add) => {
add.field("bareBokstaver", new ControlDef());
add.field("jaNei", new ControlDef());
add.container(new HorizontalLayoutDef((add) => {
add.field("tall", new ControlDef()).visible((c) => c.getParent().jaNei);
add.field("harListe", new ControlDef());
}
));
}
```
Advantages:

- This is a much more compact solution (replaces 30 or so lines of json, a lot more if the rules are more complex)
- The "visible" rule can be coded in javascript, which is a lot more expressive
- The configuration can be parameterized, so you can add conditional logic and have different variants
- It is easy to reuse sub-uischema-definitions, making a more modularized design
- This approach is also typesafe (meaning it will give a compilation error if any of the referenced field-names are not in the actual schema, so typos and wrong references should not be a problem.

The POC is unfortunately in a code base that can not be shared for legal reasons, but I would be happy to provide more info if you find this to be an interesting approach

### Describe alternatives you've considered

Alternative approaces would be to keep this POC local to our organization only, or create a new standalone open-source project when we have something that can be shared

### Framework

_No response_

### RendererSet

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.