Code Monkey home page Code Monkey logo

vue-json-schema-form's People

Contributors

alexdw avatar crickford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-json-schema-form's Issues

support root-level array type

Nice lib ❤️ , are you considering adding support to arrays at root level as well?

Use case:
When the json schema root type is array we should be able to have add/remove whole blocks of properties, same as right now it's working when a sub-type is array of objects

Example schema

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/root.json",
  "title": "root",
  "type": "array",
  "items": {
    "title": "Person",
    "type": "object",
    "$id": "#/items",
    "properties": {
      "firstName": {
        "type": "string",
        "title": "First Name",
        "description": "The person's first name.",
        "example": "John"
      },
      "lastName": {
        "type": "string",
        "title": "Last Name",
        "description": "The person's last name.",
        "example": "Doe"
      },
      "nickNames": {
        "type": "array",
        "title": "Nicknames",
        "items": {
          "type": "string",
          "example": "j-dough"
        }
      },
      "address": {
        "type": "object",
        "title": "Address",
        "properties": {
          "lineOne": {
            "type": "string",
            "title": "Address line 1",
            "example": "Address line 1"
          },
          "lineTwo": {
            "type": "string",
            "title": "Address line 2",
            "example": "Address line 2"
          },
          "postalCode": {
            "type": "string",
            "title": "Postal code",
            "example": "Postal code"
          }
        }
      },
      "age": {
        "title": "Age",
        "description": "Age in years which must be equal to or greater than zero.",
        "type": "integer",
        "minimum": 0
      }
    },
    "required": [
      "firstName"
    ]
  }
}

Remote Json Schemas

Are there any plans to support remote schemas? I am new to Vue so if it's already covered please let me know.

remove 1st items in object array

When I try to remove 1st item in object array, 2nd item is removed instead of 1st one in schema form.
however, I checked form-data through the script, the result is right.

I attached an image and JsonSchema below.

{
"title": "Person",
"type": "object",
"properties": {
"firstname": {
"type": "string",
"title": "First Name"
},
"testArray": {
"type": "array",
"title": "TESTARRAY",
"items": {
"type": "object",
"properties": {
"item1": {
"type": "number",
"title": "item1"
},
"item2": {
"type": "number",
"title": "item2"
}
}
}
}
}
}

image

Use of the default property in Json schema

It would have been very handy to be able to display the value of the default property in Json Schema in the form when generated. E.g. in TextElement.vue if you change :value="value" to :value="schema.default != null ? schema.default : value" (if this doesn't cause other issues, I haven't deep dived into your source code). Or is there some other way to achieve this that I've overlooked?

How generate recursive form field from Schema? $ref has no effect on form.

I am trying to generate a form which can have multiple recursive fields. I have used https://codepen.io/crickford/pen/ZmJqwd this demo (I am not using any custom component). Whenever i am using "$ref" it ignores it.

My Json-schema is valid. Even if i replace the following schema in codepen i don't get expected result, where as it is giving me by editing schema property of the source in this link http://www.alpacajs.org/docs/api/recursive-references.html

I don't know where am I mistaking !! At least in codepen attached schema code should work.
Kindly guide me or share working demo fiddle with me. Thanks in advance.

Here is my schema:
{ "type": "object", "title": "", "properties": { "Namespace": { "type": "string", "title": "Namespace ", "attrs": { "placeholder": "Namespace", "title": "Please enter Namespace" } }, "Name": { "type": "string", "title": "Display Name : ", "attrs": { "placeholder": "Display Name", "title": "Please enter Display name" } }, "SubSteps": { "type": "array", "title": "SubSteps", "items": { "type": "object", "title": "Sub step", "$ref": "#/definitions/SubSteps" } } }, "definitions": { "SubSteps": { "type": "object", "title": "SubStep item", "properties": { "Namespace": { "type": "string", "title": "Namespace ", "attrs": { "placeholder": "Namespace", "title": "Please enter Namespace" } }, "Name": { "type": "string", "title": "Display Name : ", "attrs": { "placeholder": "Display Name", "title": "Please enter Display name" } }, "SubSteps": { "type": "array", "title": "SubSteps", "items": { "type": "object", "title": "Sub step", "$ref": "#/definitions/SubSteps" } } } } }, "required": [ "Name" ] }

Using this with Symfony forms?

We are currently writing an adaption of a twig frontend written in PHP generating forms using Symfony/FromBuilder. We found a library that converts Symfony forms into JSON Schema but the resulting schema is not exactly what this project needs. Are there any matching transformers out there known to you guys? Thanks in advance, Jan

How to generate a new version after personalized modification ?

First of all , thank you for providing such an excellent project.

In actual use, we need to make some changes based on your project. But, expect how to run local demo, no packaging instructions were found.

So, could you please guide how to generate a new version after personalized modification ?

Thanks!

Custom component in nested object

@crickford Using the advance demo, i am trying to use the rating component in a nested object. The default input box shows instead of the rating component. It appears only root object items are supported, any thoughts to nested obects?

Looks like it the code processing custom component is SchemaForm.vue:
<template v-for="(property, key) in schema.properties"> <slot :name="key" :item="{key: key, schema: property, value: items[key], update: updateValue}"> <component :is="element" :key="key" :schema="property" :value="items[key]" @input="updateValue($event, key)"></component> </slot> </template>

Schema Example:
{ "type": "object", "properties": { "test": { "type": "object", "properties" : { "teststring": { "type": "string", "title": "Test String" }, "rating": { "type": "number", "title": "Rating", "minimum": 0, "maximum": 5 } } } } }

can't update form-data with stored data

I want to make schema-form has stored data so that user can edit form-data whenever they want.
However once schema-form is created, I can't bind data through the method. ( I get the data from server through axios, and try to bind when vue page is created.)
plz check example below.

  1. giving data when form is created - It's working

<schema-form :schema="schema" v-model="obj" @submit="handleSubmit()" />
data () {
return {
schemaIsValid: true,
schema: baseSchema,
obj: {
"firstName": "11111",
"nickNames": [
{
"url": "111111111111",
"title": "1111111111111"
}
]
},
}

  1. (not-working) method driven way - click button, form data isn't updated.

<schema-form :schema="schema" v-model="obj" @submit="handleSubmit()" />
<button type="button" class="button" @click="UpdateData()">Update form Data

data () {
return {
schemaIsValid: true,
schema: baseSchema,
obj: {}
}
},
methods: {
handleSubmit() {
console.log(JSON.stringify(this.obj, null, 2))
}
,UpdateData() {
this.obj = baseData;
}
}

  1. (not-working) binding data through axios when it's created.

<schema-form :schema="schema" v-model="obj" @submit="handleSubmit()" />

data () {
return {
schemaIsValid: true,
schema: baseSchema,
obj: {},
}
},
created() {
this.$http
.get(URL,{ headers: { 'Content-Type' : 'application/json'}})
.then( res => {
this.obj = JSON.parse(res.data..obj);
}
,function() {
console.log('failed')
});
},

check image below.
as you can see in the image, data is binded after axios or click event, but the form is still empty and the data is removed when click submit button.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.