Skip to content

array showing only first item #195

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

Open
emilb604 opened this issue Feb 8, 2018 · 3 comments
Open

array showing only first item #195

emilb604 opened this issue Feb 8, 2018 · 3 comments

Comments

@emilb604
Copy link

emilb604 commented Feb 8, 2018

only first element is being displayed, console error:

ERROR TypeError: Cannot read property 'name' of undefined
at checkBindingNoChanges (core.js:9912)
at checkNoChangesNodeInline (core.js:13965)
at checkNoChangesNode (core.js:13935)
at debugCheckNoChangesNode (core.js:14764)
at debugCheckDirectivesFn (core.js:14666)
at Object.eval [as updateDirectives] (ConfigComponent.html:2)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14648)
at checkNoChangesView (core.js:13773)
at callViewAction (core.js:14126)
at execEmbeddedViewsAction (core.js:14104)

Schema looks like following for array:

            "CurrentConfig" : {
                "type" : "object",
                "properties" : {
                    "fields" : {
                        "type" : "array",
                        "items" : {
                            "type" : "object",
                            "properties" : {
                                "name" : {
                                    "type" : "string",
                                    "title" : "name"
                                },
                                "showLabel" : {
                                    "type" : "boolean",
                                    "title" : "showLabel"
                                },
                                "showData" : {
                                    "type" : "boolean",
                                    "title" : "showData"
                                },
                                "label" : {
                                    "type" : "string",
                                    "title" : "label"
                                },
                                "displayStyle" : {
                                    "type" : "string",
                                    "title" : "displayStyle",
                                    "enum" : [ 
                                        "controls-vin-label", 
                                        "controls-vin-label2"
                                    ]
                                },
                                "display" : {
                                    "type" : "string",
                                    "title" : "display",
                                    "enum" : [ 
                                        "value", 
                                        "transValue"
                                    ]
                                },
                                "divClass" : {
                                    "type" : "string",
                                    "title" : "divClass",
                                    "enum" : [ 
                                        "current-data-sm", 
                                        "current-data-lg"
                                    ]
                                },
                                "transValueMIMEType" : {
                                    "type" : "string",
                                    "title" : "transValueMIMEType",
                                    "enum" : [ 
                                        "text/colour", 
                                        "image/jpg"
                                    ]
                                }
                            }
                        }
                    }
                }
            }       

data

 "CurrentConfig" : {
            "fields" : [ 
                {
                    "name" : "part",
                    "showLabel" : true,
                    "showData" : true,
                    "label" : "",
                    "displayStyle" : "controls-vin-label",
                    "display" : "value",
                    "divClass" : "current-data-sm",
                    "transValueMIMEType" : ""
                }, 
                {
                    "name" : "parentpart",
                    "showLabel" : true,
                    "showData" : true,
                    "label" : "BODY",
                    "displayStyle" : "controls-bodyno-label",
                    "display" : "value",
                    "divClass" : "current-data-reg",
                    "transValueMIMEType" : ""
                }, 
                {
                    "name" : "seqno",
                    "showLabel" : true,
                    "showData" : true,
                    "label" : "ASN",
                    "displayStyle" : "controls-asn-label",
                    "display" : "value",
                    "divClass" : "current-data-reg",
                    "transValueMIMEType" : ""
                }, 
                {
                    "name" : "partImage",
                    "showLabel" : false,
                    "showData" : true,
                    "label" : "",
                    "display" : "transValue",
                    "divClass" : "image-div",
                    "transValueMIMEType" : "image/jpg"
                }, 
                {
                    "name" : "extcolor",
                    "showLabel" : false,
                    "showData" : true,
                    "label" : "COLOUR",
                    "display" : "transValue",
                    "divClass" : "current-colour-box",
                    "transValueMIMEType" : "text/colour"
                }, 
                {
                    "name" : "ssn",
                    "showLabel" : true,
                    "showData" : true,
                    "label" : "SSN",
                    "display" : "value",
                    "divClass" : "current-data-reg",
                    "transValueMIMEType" : ""
                }
            ]
        },
@emilb604
Copy link
Author

emilb604 commented Feb 8, 2018

looks like following solved the issue.
previously:
<json-schema-form framework="bootstrap-4" [form]="config" [(ngModel)]="config.data"></json-schema-form>

changed to:
<json-schema-form framework="bootstrap-4" [schema]="config.schema" [(data)]="config.data"></json-schema-form>

@Sebastian-Fitzner
Copy link

Sebastian-Fitzner commented Feb 16, 2018

It is indeed a bug which I couldn't solved by changing the lines. The module just cut off all the other data. I do not get any error in the console.

What I figured out so far, is thatlayoutNode is only containing one array item element ...

@Sebastian-Fitzner
Copy link

Sebastian-Fitzner commented Feb 16, 2018

Here is at least the issue I had with it.

I have an asnychronous call to get the form data. The initial state was an empty object. After receiving the data, the form just stays in its current structure.

That is connected to the defaultWidgetOptions object which contains listItems. This has a default value of 1 and does not play nice with the array length of my provided form data.

I fixed it for me by not rendering the form at all in the beginning.

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

No branches or pull requests

2 participants