WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
This repository was archived by the owner on Oct 10, 2018. It is now read-only.
This repository was archived by the owner on Oct 10, 2018. It is now read-only.

model 给到 schema 后,再次序列化会导致 model给定的字段丢失 #41

@liweitao92

Description

@liweitao92

Bug Report or Feature Request (mark with an x)


[ ] Bug report -> please search issues before submitting
[x] Feature request
[ ] Documentation issue or request

Reproduction link

image

Steps to reproduce

Schema

{
    "span_label": 4,
    "span": 8,
    "properties": {
        "email": {
            "type": "string",
            "title": "邮箱",
            "format": "email",
            "placeholder": "请输入邮箱,最多20个字符",
            "maxLength": 20,
            "debug": true
        },
        "name": {
            "type": "string",
            "title": "姓名",
            "placeholder": "请输入姓名",
            "description": "必须大写开头且3个字以上",
            "minLength": 3,
            "debug": true
        },
        "age": {
            "type": "number",
            "title": "年龄"
        },
        "remark": {
            "type": "string",
            "title": "描述"
        },
        "products": {
            "type": "array",
            "title": "产品清单",
            "maxItems": 2,
            "items": {
                "type": "object",
                "properties": {
                    "pn": {
                        "title": "产品名称",
                        "type": "string"
                    },
                    "num": {
                        "title": "件数",
                        "type": "number",
                        "minimum": 1,
                        "maximum": 1000
                    },
                    "price": {
                        "title": "金额",
                        "type": "number"
                    }
                },
                "required": ["pn", "num", "price"]
            }
        }
    },
    "button": {
        "style": { "text-align": "center" },
        "items": [
            {
                "label": "Send",
                "id": "send",
                "submit": true,
                "offset": 4
            },
            {
                "label": "Reset",
                "id": "reset"
            }
        ]
    }
}

Model

{
    "email": "[email protected]",
    "id": "1",
    "sex": "1",
    "name": "zhangsan"
}

从服务器获取到的 json 字符串可能是很长的,可能很多属性都没有在Schema 中,通过 model 将值绑定到 Schema 后,在通过编辑表单得到的结果不会包含那些没有在Schema中定义的属性

例如

//服务端 json
{"username":"admin","email":"[email protected]","sex":"1"}

//Schema 中定义的属性
"username": {
            "type": "string",
            "title": " 用户名"
},
"email": {
            "type": "string",
            "title": "邮箱"
},

//最后通过表单获取到的 json
{"username":"xxx","email":"xxx"}

What is expected?

根据传入的 model 值,在表单序列化 json 的时候,保留 model 原有的字段,进行部分字段的更改

What is actually happening?

表单序列化出的 json 不会保留 model 原有的 字段属性

Environment


ng-alain version: X.Y.Z
Angular version: X.Y.Z
Browser:
- [ ] Chrome (desktop) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] IE version XX

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions