apache / incubator-kie-issues

Apache License 2.0
12 stars 1 forks source link

`@kie-tools/form-generation-tool`: Doesn't set a default value on `array` field types #1313

Open pefernan opened 5 months ago

pefernan commented 5 months ago

When generating the binding expression to bind the model data into the form state, the generated tool sets a default value for each input. but It doesn't do so for array data types leaving the property null. This could cause problems in the runtime when submitting the payload with the null array.

Steps to reproduce:

  1. Build the jbpm-compact-architecture example (mvn clean install) to generate the json schemas.
  2. Run the form-generation-cli to generate forms (it doesn't matter the type)
  3. Start the jbpm-compact-architecture in dev mode (mvn clean compile quarkus:dev or pnpm -F @kie-tools-examples/jbpm-compact-architecture-example quarkus:dev)
  4. Start a hiring process instance from the Process Definitions tab. After submit you'll get see the error dialog appear

Image Image

jomarko commented 5 months ago

I have two observation about this issue.

01

The same object seems to have a default array field type implementation present in the task form - see the attached screenshot. Once the hiring process is started, in the Tasks view we will find the attached form view where the 'skills' has an UI elements rendered.

Screenshot 2024-06-18 104704

02

Form generation tools uses fields implemented here https://github.com/apache/incubator-kie-tools/tree/main/packages/uniforms-bootstrap4-codegen/src/uniforms . There you will easily find the message about unsupported Array field type. What is strange in our codebase is the duplication of places we implement form fields, another place is here https://github.com/apache/incubator-kie-tools/tree/main/packages/uniforms-patternfly/src, please notice there is ListField available.

Not sure if possible, but to unify user experience from tooling usage, we should probabaly minimize the amount of field implementation we use? Also it seem the external implementation has the ListField available https://uniforms.tools/docs/api-fields/