guillotinaweb / ngx-schema-form

HTML form generation based on JSON Schema
MIT License
485 stars 174 forks source link

Can't resolve z-schema ERROR!!! #214

Open sindhujavs opened 6 years ago

sindhujavs commented 6 years ago

I'm getting the folllowing error: ERROR in ./node_modules/ngx-schema-form/fesm5/ngx-schema-form.js Module not found: Error: Can't resolve 'z-schema' in '..../node_modules/ngx-schema-form/fesm5'

Could anyone help. Thanks in advance.

WhileTrueEndWhile commented 6 years ago

Maybe that sounds too easy now, but did you install Z-Schema?

package.json

...
    "dependencies": {
        ...
         "z-schema": "^3.17.0"
...

I don't know if it will be installed, because the schema validator is interchangeable.

sindhujavs commented 6 years ago

Yup i did but didnt work.

WhileTrueEndWhile commented 6 years ago

Does it work with the old "angular2" version?


Edit:

For me, both versions work with Angular 6 ({angular2,ngx}-schema-form).

I noticed a difference: The map function of Observables is no longer available by default.

I can't say anything about problems with the high-level CLI, but I get exactly the error message if z-schema is not installed:

Error: Cannot find module 'z-schema' from '...'
novitskiy-aleksei commented 6 years ago

I'm using latest ngx-schema-form with angular6 + SystemJs and having similar issue

image

Have any thoughts about this?

shohrukh92 commented 6 years ago

I've these versions: "ngx-schema-form": "^2.1.0-beta.1" "z-schema": "^3.22.0" "@angular/*": "^6.0.3" and it works without any errors

gpessa commented 5 years ago

same here, If I fix it I get other deps missing

htmoia commented 5 years ago

Same with

"ngx-schema-form": "2.2.0-beta.1",
"@angular/core": "5.2.11",
"@ionic-native/core": "4.10.0",
"ionic-angular": "3.9.2"

Error: Cannot find module "z-schema" ngx-schema-form.js:1

ebrehault commented 5 years ago

Just make sure you have the same deps as here: https://github.com/guillotinaweb/ngx-schema-form/blob/master/package.json#L15 and it will run fine (that's how Travis is doing its install at the moment and the build is successful).

tqduy commented 4 years ago

Hi @ebrehault , I have an issue when upgrading from angular2-schema-form to ngx-schema-form where I add the z-schema package I have a schema json: "component": { "type": "string", "widget": "select", "description": "Component", "oneOf": [ { "description": "Audible Warning Devices", "enum": [ "AudibleWarningDevices" ] }, { "description": "Bonnet Release Cable", "enum": [ "BonnetReleaseCable" ] } ] }

I face an error when my widget try to get the initial data from this.FormProperty.value image

Do you have any idea about this? I think it is about the parsing approach is changed because of z-schema I use widget named 'select' ==> it is my custom widget that using ionic-selectable package

ebrehault commented 4 years ago

Sorry, I never saw this problem before. Maybe you could try to use the source version of ngx-schema-form so you can debug and see what happens.

tqduy commented 4 years ago

Sorry, I never saw this problem before. Maybe you could try to use the source version of ngx-schema-form so you can debug and see what happens.

@ebrehault thank you for response. Can you give me some clue so that I can track down about how the ControlWidget.formProperty is binding while rendering between the steps the sf-form tag to call widget class? image

The above error lead the formProperty._value = "" and cannot render the existing value loaded from API server

and one more extra question: I still use sf-form-element tag to render the schema, does this tag still available in ngx-schema-form?

ebrehault commented 4 years ago

I cannot provide any support at the moment as I am pretty busy with other matters.

@daniele-pecora, would you have time to have a quick look?

aman-di-fu commented 4 years ago

@tqduy I had this once when the oneOf didn't contain an empty value selection. Simply add something like this to your oneOf schema :

        {
          "description": "-- Make your selection --",
          "enum": [""]
        }

For me this behavior seems logic because the field's value has to be one of described by oneOf but initial it is null or `` (empty)

tqduy commented 4 years ago

@tqduy I had this once when the oneOf didn't contain an empty value selection. Simply add something like this to your oneOf schema :

        {
          "description": "-- Make your selection --",
          "enum": [""]
        }

For me this behavior seems logic because the field's value has to be one of described by oneOf but initial it is null or `` (empty)

@aman-di-fu Thank you for response. Your solution can solve the error message. But I still cannot received the initial data in the widget to render I will explain more: I have a component named A.component.html which used sf-form which schema and schemaModel come from API server

<sf-form *ngIf="showSchema" [schema]="schema" (onChange)="updateSchemaValue($event.value)" [validators]="fieldValidators" [actions]="actions" [(model)]="schemaModel">

the schema is an array schema widget: export class IonicArrayWidgetComponent extends ArrayWidget implements AfterViewInit { } with HTML : <sf-form-element [attr.id]="i" [formProperty]="itemProperty"></sf-form-element>

==> each element from the array widget is the group of ion-selectable : export class IonicSelectWithSearchComponent extends SelectWidget { }

==> The issue is about I cannot render the data for each IonicSelectWithSearchComponent because the value is always "". I go back to the IonicArrayWidgetComponent and see that the formProperty._value is "" as well. So I think there must be some mistake at the component A which sf-form cannot passing the schemaModel (aka schema data) to the widget

gabriellupu commented 4 years ago
npm i jexl --save
npm i z-schema --save

fixed it for me. using "ngx-schema-form": "^2.4.3",

daniele-pecora commented 4 years ago

I cannot provide any support at the moment as I am pretty busy with other matters.

@daniele-pecora, would you have time to have a quick look?

I'll have a look asap

daniele-pecora commented 4 years ago

@tqduy I had this once when the oneOf didn't contain an empty value selection. Simply add something like this to your oneOf schema :

        {
          "description": "-- Make your selection --",
          "enum": [""]
        }

For me this behavior seems logic because the field's value has to be one of described by oneOf but initial it is null or `` (empty)

@aman-di-fu Thank you for response. Your solution can solve the error message. But I still cannot received the initial data in the widget to render I will explain more: I have a component named A.component.html which used sf-form which schema and schemaModel come from API server

<sf-form *ngIf="showSchema" [schema]="schema" (onChange)="updateSchemaValue($event.value)" [validators]="fieldValidators" [actions]="actions" [(model)]="schemaModel">

the schema is an array schema widget: export class IonicArrayWidgetComponent extends ArrayWidget implements AfterViewInit { } with HTML : <sf-form-element [attr.id]="i" [formProperty]="itemProperty"></sf-form-element>

==> each element from the array widget is the group of ion-selectable : export class IonicSelectWithSearchComponent extends SelectWidget { }

==> The issue is about I cannot render the data for each IonicSelectWithSearchComponent because the value is always "". I go back to the IonicArrayWidgetComponent and see that the formProperty._value is "" as well. So I think there must be some mistake at the component A which sf-form cannot passing the schemaModel (aka schema data) to the widget

I'd recommend using :

               [model]="model"
               (onChangeModel)="model=$event"

instead of


               [(model)]="model"

this solves the issue that the array model is not pre-filled.

@ebrehault I think this is the problem...

ebrehault commented 4 years ago

Agreed. I am even wondering if we should add a warning message (in dev mode only) when people use changeModel (the implicit output used with [(model)] because it is causing so many confusion.

daniele-pecora commented 4 years ago

@ebrehault We already struggled on this with #233

ebrehault commented 4 years ago

yes, true. So if we want to restrict two-way binding to ngModel only, we just have to remove the modelChange output.

daniele-pecora commented 4 years ago

@ebrehault This would be a breaking change?

ebrehault commented 4 years ago

Yes, and we will mention it in the changelog. I think that's fine, it will avoid confusion in the future.