Skip to content
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

希望schema中list的items可以支持type="string" #851

Closed
wuxinzhe097 opened this issue Jul 13, 2022 · 14 comments
Closed

希望schema中list的items可以支持type="string" #851

wuxinzhe097 opened this issue Jul 13, 2022 · 14 comments
Assignees

Comments

@wuxinzhe097
Copy link

期望的新功能 (describe the expected new feature)

希望schema中list的items可以支持type="string",而不是只支持object类型

简述一下使用场景,便于开发者更好理解新功能的必要性 (describe your scenario for us to understand the need)

{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme's catalog",
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
这样一个基础的schema在form-render 中无法正常使用

@markqq
Copy link

markqq commented Aug 18, 2022

+1

@siyi98
Copy link
Collaborator

siyi98 commented Aug 25, 2022

想要达到什么样的效果呢?

@wuxinzhe097
Copy link
Author

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"title": "Product",
"description": "A product from Acme's catalog",
"type": "object",
"properties": {
"tags": {
"description": "Tags for the product",
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
}
}
就是上面这一段schema生成的数据类型应该是
{
tags: string[]
}

@siyi98
Copy link
Collaborator

siyi98 commented Sep 1, 2022

emmm...感觉怪怪的,list组件一般都会有多个表单项吧,换成string,想象不到会长成什么样,除非每一项只有一个input?

@wuxinzhe097
Copy link
Author

vue-json-schema实现的方式是一个带+/-按钮的输入框,每个输入框对应数组中的某一项,这样的话如果jsonschem的items中有min和max也可以控制+/-按钮来实现

@siyi98
Copy link
Collaborator

siyi98 commented Sep 1, 2022

好兄弟,要不来个PR吧

@siyi98
Copy link
Collaborator

siyi98 commented Sep 1, 2022

vue-json-schema实现的方式是一个带+/-按钮的输入框,每个输入框对应数组中的某一项,这样的话如果jsonschem的items中有min和max也可以控制+/-按钮来实现

截个图看看?

@wuxinzhe097
Copy link
Author

image

地址在:https://form.lljj.me/v3/#/demo?type=Simple&ui=VueAntForm&schema={%22$schema%22:%22https://json-schema.org/draft/2020-12/schema%22,%22$id%22:%22https://example.com/product.schema.json%22,%22title%22:%22Product%22,%22description%22:%22A+product+from+Acme's+catalog%22,%22type%22:%22object%22,%22properties%22:{%22tags%22:{%22description%22:%22Tags+for+the+product%22,%22type%22:%22array%22,%22items%22:{%22type%22:%22string%22},%22minItems%22:1,%22uniqueItems%22:true}}}&formData={%22tags%22:[null]}&uiSchema={%22ui:description%22:%22%E7%AE%80%E5%8D%95%E8%A1%A8%E5%8D%95%E4%BE%8B%E5%AD%90%EF%BC%88%E8%BF%99%E9%87%8C%E9%80%9A%E8%BF%87UiSchema%E8%A6%86%E7%9B%96%E4%BA%86%E9%BB%98%E8%AE%A4description%E6%8F%8F%E8%BF%B0%E9%85%8D%E7%BD%AE%EF%BC%89%22,%22firstName%22:{%22ui:title%22:%22%E5%90%8D%E5%AD%97%22,%22ui:description%22:%22%E6%AF%94%E5%A6%82%EF%BC%9A%E6%9D%8E%E7%99%BD%E5%A7%93%E6%9D%8E%E3%80%81%E5%AD%99%E5%B0%9A%E9%A6%99%E5%A7%93%E5%AD%99%E3%80%81%E9%A9%AC%E5%8F%AF%E6%B3%A2%E7%BD%97%E5%A7%93%E9%A9%AC%E5%8F%AF%E6%B3%A2%22,%22ui:emptyValue%22:%22%22,%22ui:options%22:{%22placeholder%22:%22%E8%AF%B7%E8%BE%93%E5%85%A5%E4%BD%A0%E7%9A%84%E5%A7%93%22,%22attrs%22:{%22autofocus%22:true}}},%22bio%22:{%22ui:options%22:{%22placeholder%22:%22%E8%AF%B7%E8%BE%93%E5%85%A5%E4%BD%A0%E7%9A%84%E7%AD%BE%E5%90%8D%22,%22type%22:%22textarea%22,%22rows%22:6}}}&errorSchema={%22bio%22:{%22err:minLength%22:%22%E7%AD%BE%E5%90%8D%E6%9C%80%E5%B0%8F%E9%95%BF%E5%BA%A610%E4%B8%AA%E5%AD%97%E7%AC%A6%E4%B8%B2%22}}&formFooter={%22formItemAttrs%22:{%22wrapperCol%22:{%22span%22:24,%22offset%22:0}}}&formProps={%22inline%22:false,%22labelPosition%22:%22top%22,%22inlineFooter%22:false,%22layoutColumn%22:1,%22labelCol%22:{%22span%22:6},%22wrapperCol%22:{%22span%22:16}}

@siyi98
Copy link
Collaborator

siyi98 commented Sep 1, 2022

image
@wuxinzhe097 是这个意思吗?

@wuxinzhe097
Copy link
Author

没错,input 的type根据items的type来 @siyi98

@siyi98
Copy link
Collaborator

siyi98 commented Sep 2, 2022

懂你的意思了,等下个版本吧。有时间的话,你也可以提PR

@siyi98
Copy link
Collaborator

siyi98 commented Sep 20, 2022

基于现版本的架构,改造成本太大,放到XRender2.0做吧,我先把这个需求放到discussion里面去。 #770

@siyi98 siyi98 closed this as completed Sep 20, 2022
@flearc
Copy link

flearc commented Jun 1, 2023

请求有支持这个功能的计划吗?在2.x的playground试了一下,似乎仍然不支持 @siyi98

@wuxinzhe097
Copy link
Author

我后来自己实现了自定义组件,只要确保value和onchange是你要的值就行

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

4 participants