ajsf icon indicating copy to clipboard operation
ajsf copied to clipboard

schema objectWrap is broken

Open newmanw opened this issue 3 years ago • 0 comments

Describe the bug which template:

  • [x] MaterialDesignFrameworkModule — Material Design
  • [ ] Bootstrap3FrameworkModule — Bootstrap 3
  • [ ] Bootstrap4FrameworkModule — Bootstrap 4
  • [ ] NoFrameworkModule — plain HTML
  • [ ] Other (please specify below)

A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

Does not work with non object schema:

{ "schema": { "title": "Name", "type": "string" }, "data": "Jane" }

Cut/paste this form into the demo project to produce failure. The form is set up correctly however the value of "Jane" is not mapped into the form.

Expected behavior This should create a 'Name' field with the value "Jane"

Screenshots Screen Shot 2020-09-15 at 1 30 49 PM

Desktop (please complete the following information):

  • OS: [e.g. iOS] macOs Catalina
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] current

Log output covering before error and any error statements N/A

Additional context N/A

Possible Implementation

Looking at the code there are a few issues I can see at the top level. With this type of schema there is code to check and "wrap" in an object.

https://github.com/hamzahamidi/ajsf/blob/master/projects/ajsf-core/src/lib/json-schema-form.component.ts#L451-L456

However it does not look like the data/value is also wrapped. IE the value of "Jane" should also be mapped to

{
  1: "Jane"
}

newmanw avatar Sep 15 '20 19:09 newmanw