chore(playground): 优化 templates 更新

This commit is contained in:
Gcaufy
2020-12-05 12:43:54 +08:00
committed by Dmitry Nagibin
parent 81f5d51050
commit 39f7e90ae4
21 changed files with 1018 additions and 1004 deletions
@@ -0,0 +1,45 @@
{
"type": "object",
"properties": {
"user": {
"type": "array",
"items": {
"type": "object",
"properties": {
"adult": {
"type": "boolean",
"ui": {
"label": "Adult",
"help": {
"show": true,
"text": "?"
}
}
},
"gameName": {
"type": "string",
"ui": {
"label": "Like games",
"disabled": "dx: !{{$root.user[i].adult}}"
}
},
"gameAge": {
"type": "integer",
"ui": {
"label": "Game age",
"disabled": "dx: !{{$root.user[i].adult}}"
}
}
}
},
"ui": {
"showLegend": false,
"noLabelSpace": true,
"widget": "array-table",
"widgetConfig": {
"showOneIfEmpty": true
}
}
}
}
}
@@ -0,0 +1,72 @@
{
"type": "object",
"properties": {
"isRequired": {
"type": "boolean",
"ui": {
"label": "Required",
"linkFields": [
{
"fieldPath": "num_1",
"rules": [
"required"
]
},
{
"fieldPath": "num_2",
"rules": [
"required"
]
}
]
}
},
"num_1": {
"type": "number",
"ui": {
"description": "num_1 >= num_2",
"columns": 6,
"linkFields": [
{
"fieldPath": "num_2",
"rules": [
"maximum"
]
}
]
},
"rules": {
"required": {
"value": "dx: {{$root.isRequired}}"
},
"minimum": {
"value": "dx: {{$root.num_2}} || 0",
"errMsg": "num_1 >= num_2"
}
}
},
"num_2": {
"type": "number",
"ui": {
"columns": 6,
"linkFields": [
{
"fieldPath": "num_1",
"rules": [
"minimum"
]
}
]
},
"rules": {
"required": {
"value": "dx: {{$root.isRequired}}"
},
"maximum": {
"value": "dx: {{$root.num_1}} || 0",
"errMsg": "num_2 <= num_1"
}
}
}
}
}
@@ -0,0 +1,35 @@
{
"type": "object",
"properties": {
"age": {
"type": "integer",
"ui": {
"label": "Age",
"description": "More than 18 years old to continue filling"
}
},
"gameInfo": {
"type": "object",
"properties": {
"game": {
"type": "string",
"ui": {
"label": "Like games",
"description": "Fill in and unlock"
}
},
"gameAge": {
"type": "integer",
"ui": {
"label": "Game age",
"disabled": "dx: !{{$root.gameInfo.game}}"
}
}
},
"ui": {
"legend": "Game info",
"hidden": "dx: !{{$root.age}} || {{$root.age}} < 18"
}
}
}
}
@@ -0,0 +1,102 @@
{
"type": "object",
"properties": {
"startTime": {
"type": "string",
"ui": {
"widget": "date-picker"
},
"rules": {
"customRule": [
{
"script": "dx: !{{$root.endTime}} || {{$root.endTime}} >= {{$root.startTime}}",
"errMsg": "Start date must be less than or equal to the end date",
"linkItems": [
{
"fieldPath": "endTime",
"customRuleIdx": 0
}
]
}
]
}
},
"endTime": {
"type": "string",
"ui": {
"widget": "date-picker"
},
"rules": {
"customRule": [
{
"script": "dx: !{{$root.startTime}} || {{$root.endTime}} >= {{$root.startTime}}",
"errMsg": "End date must be greater than or equal to the start date",
"linkItems": [
{
"fieldPath": "startTime",
"customRuleIdx": 0
}
]
}
]
}
},
"arrayItems": {
"type": "array",
"items": {
"type": "object",
"properties": {
"startTime": {
"type": "string",
"ui": {
"widget": "date-picker"
},
"rules": {
"customRule": [
{
"script": "dx: !{{$root.arrayItems[i].endTime}} || {{$root.arrayItems[i].endTime}} >= {{$root.arrayItems[i].startTime}}",
"errMsg": "Start date must be less than or equal to the end date",
"linkItems": [
{
"fieldPath": "arrayItems[i].endTime",
"customRuleIdx": 0
}
]
}
]
}
},
"endTime": {
"type": "string",
"ui": {
"widget": "date-picker"
},
"rules": {
"customRule": [
{
"script": "dx: !{{$root.arrayItems[i].startTime}} || {{$root.arrayItems[i].endTime}} >= {{$root.arrayItems[i].startTime}}",
"errMsg": "End date must be greater than or equal to the start date",
"linkItems": [
{
"fieldPath": "arrayItems[i].startTime",
"customRuleIdx": 0
}
]
}
]
}
}
}
},
"ui": {
"showLabel": false,
"legend": "Array item",
"widget": "array-table",
"widgetConfig": {
"collapsed": false,
"showOneIfEmpty": true
}
}
}
}
}
@@ -0,0 +1,24 @@
{
"type": "object",
"properties": {
"firstname": {
"type": "string",
"ui": {
"columns": 6
}
},
"lastname": {
"type": "string",
"ui": {
"columns": 6
}
},
"fullname": {
"type": "string",
"valueTemplate": "dx: {{$root.firstname}} + \" \" + {{$root.lastname}}",
"ui": {
"columns": 12
}
}
}
}
@@ -0,0 +1,24 @@
{
"type": "object",
"properties": {
"age": {
"type": "string",
"ui": {
"placeholder": "dx: \"Age must be greater than \" + {{$const.ageLimit}}"
},
"rules": {
"customRule": [
{
"script": "dx: {{$root.age}} > {{$const.ageLimit}}",
"errMsg": "Please fill in the correct age"
}
]
}
}
},
"globalConfig": {
"constants": {
"ageLimit": 18
}
}
}
@@ -0,0 +1,38 @@
{
"type": "object",
"properties": {
"province": {
"type": "string",
"ui": {
"label": "Province",
"widget": "select",
"widgetConfig": {
"itemLabelField": "name",
"itemValueField": "id",
"enumSourceRemote": {
"remoteUrl": "/api/test/getProvinces",
"paramName": "keyword"
}
}
}
},
"city": {
"type": "string",
"ui": {
"label": "City",
"widget": "select",
"widgetConfig": {
"itemLabelField": "name",
"itemValueField": "id",
"enumSourceRemote": {
"remoteUrl": "/api/test/getCities",
"paramName": "keyword",
"otherParams": {
"provinceId": "dx: {{$root.province}}"
}
}
}
}
}
}
}
@@ -0,0 +1,30 @@
{
"type": "object",
"properties": {
"item": {
"type": "string",
"ui": {
"description": "Currently only select, radio, checkbox supports this feature.",
"widget": "select",
"widgetConfig": {
"itemDataKey": "selectedItem",
"enumSource": [
{
"value": "1",
"label": "ncform",
"desc": "ncform is a very nice configuration generation way to develop forms"
},
{
"value": "2",
"label": "daniel",
"desc": "Daniel is the author of ncform"
}
]
}
}
},
"desc": {
"valueTemplate": "dx: {{$temp.selectedItem.desc}} || \"\""
}
}
}
@@ -0,0 +1,61 @@
{
"type": "object",
"properties": {
"user": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"ui": {
"label": "Name",
"description": "Please fill in your name",
"placeholder": "Name"
},
"rules": {
"required": true
}
},
"email": {
"type": "string",
"ui": {
"label": "Email"
},
"rules": {
"required": true,
"email": true
}
},
"age": {
"type": "integer",
"ui": {
"label": "Age"
}
},
"adult": {
"type": "boolean",
"ui": {
"label": "Adult",
"help": {
"show": true,
"text": "?",
"content": "Adults can play games"
}
}
}
},
"ui": {
"label": "User"
}
},
"ui": {
"showLegend": false,
"noLabelSpace": true,
"widgetConfig": {
"showOneIfEmpty": true
}
}
}
}
}
@@ -0,0 +1,47 @@
{
"type": "object",
"properties": {
"firstname": {
"type": "string",
"ui": {
"label": "Name",
"placeholder": "First name"
}
},
"lastname": {
"type": "string",
"ui": {
"showLabel": false,
"placeholder": "Last name"
}
},
"email": {
"type": "string",
"ui": {
"label": "Email"
}
},
"age": {
"type": "integer",
"ui": {
"label": "Age"
}
},
"adult": {
"type": "boolean",
"ui": {
"label": "Adult",
"help": {
"show": true,
"text": "?",
"content": "Adults can play games"
}
}
}
},
"ui": {
"widgetConfig": {
"layout": "h"
}
}
}
@@ -0,0 +1,56 @@
{
"type": "object",
"properties": {
"image": {
"type": "string",
"default": "https://upload-images.jianshu.io/upload_images/2195795-e3c500e4b7d17b2c.png?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240",
"ui": {
"label": "Image",
"columns": 6,
"preview": {
"type": "image",
"value": "dx: {{$self}}",
"clearable": true,
"outward": {
"width": 150,
"height": 150,
"shape": "circle"
}
}
}
},
"video": {
"type": "string",
"default": "https://www.w3schools.com/html/mov_bbb.mp4",
"ui": {
"label": "Video",
"columns": 6,
"preview": {
"type": "video"
}
}
},
"audio": {
"type": "string",
"default": "https://www.w3schools.com/html/mov_bbb.mp4",
"ui": {
"label": "Audio",
"columns": 6,
"preview": {
"type": "audio"
}
}
},
"link": {
"type": "string",
"default": "https://www.baidu.com",
"ui": {
"label": "Link",
"columns": 6,
"preview": {
"type": "link"
}
}
}
}
}
@@ -0,0 +1,47 @@
{
"type": "object",
"properties": {
"firstname": {
"type": "string",
"ui": {
"columns": 3,
"label": "Name",
"placeholder": "First name"
}
},
"lastname": {
"type": "string",
"ui": {
"columns": 3,
"showLabel": false,
"placeholder": "Last name"
}
},
"email": {
"type": "string",
"ui": {
"columns": 6,
"label": "Email"
}
},
"age": {
"type": "integer",
"ui": {
"columns": 6,
"label": "Age"
}
},
"adult": {
"type": "boolean",
"ui": {
"columns": 6,
"label": "adult",
"help": {
"show": true,
"text": "?",
"content": "Adults can play games"
}
}
}
}
}
@@ -0,0 +1,37 @@
{
"type": "object",
"properties": {
"name": {
"type": "string",
"ui": {
"label": "Name",
"description": "Please fill in your name.",
"placeholder": "Name"
}
},
"email": {
"type": "string",
"ui": {
"label": "Email"
}
},
"age": {
"type": "integer",
"default": 18,
"ui": {
"label": "Age"
}
},
"adult": {
"type": "boolean",
"ui": {
"label": "Adult",
"help": {
"show": true,
"text": "?",
"content": "Adults can play games."
}
}
}
}
}
@@ -0,0 +1,45 @@
{
"type": "object",
"properties": {
"_line1": {
"type": "HTML",
"value": "<div style=\"border-left: 4px solid orange; padding-left: 6px; color: orange\"> Basic Information</div>"
},
"name": {
"type": "string",
"ui": {
"label": "Name",
"description": "Please fill in your name",
"placeholder": "Name"
}
},
"email": {
"type": "string",
"ui": {
"label": "Email"
}
},
"_line2": {
"type": "HTML",
"value": "<div style=\"border-left: 4px solid orange; margin-top:10px; padding-left: 6px; color: orange\"> Other Information</div>"
},
"age": {
"type": "integer",
"default": 18,
"ui": {
"label": "Age"
}
},
"adult": {
"type": "boolean",
"ui": {
"label": "Adult",
"help": {
"show": true,
"text": "?",
"content": "Adults can play games"
}
}
}
}
}
@@ -0,0 +1,60 @@
{
"type": "object",
"properties": {
"user": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"ui": {
"label": "Name",
"description": "Please fill in your name",
"placeholder": "Name"
},
"rules": {
"required": true
}
},
"email": {
"type": "string",
"ui": {
"label": "Email"
},
"rules": {
"required": true,
"email": true
}
},
"age": {
"type": "integer",
"ui": {
"label": "Age"
}
},
"adult": {
"type": "boolean",
"ui": {
"label": "Adult",
"help": {
"show": true,
"text": "?",
"content": "Adults can play games"
}
}
}
}
},
"ui": {
"showLegend": false,
"noLabelSpace": true,
"widget": "array-table",
"widgetConfig": {
"disableCollapse": true,
"showOneIfEmpty": true
}
}
}
}
}
@@ -0,0 +1,60 @@
{
"type": "object",
"properties": {
"user": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"ui": {
"label": "Name",
"description": "Please fill in your name",
"placeholder": "Name"
},
"rules": {
"required": true
}
},
"email": {
"type": "string",
"ui": {
"label": "Email"
},
"rules": {
"required": true,
"email": true
}
},
"age": {
"type": "integer",
"ui": {
"label": "Age"
}
},
"adult": {
"type": "boolean",
"ui": {
"label": "Adult",
"help": {
"show": true,
"text": "?",
"content": "Adults can play games"
}
}
}
}
},
"ui": {
"showLegend": false,
"noLabelSpace": true,
"widget": "array-table",
"widgetConfig": {
"disableCollapse": true,
"showOneIfEmpty": true
}
}
}
}
}
@@ -0,0 +1,47 @@
{
"type": "object",
"properties": {
"name": {
"type": "string",
"ui": {
"label": "Name",
"description": "Please fill in your name",
"placeholder": "Name"
},
"rules": {
"required": true,
"minLength": 10
}
},
"email": {
"type": "string",
"ui": {
"label": "Email"
},
"rules": {
"required": true,
"email": {
"value": true,
"errMsg": "Please fill in a valid email address"
}
}
},
"age": {
"type": "integer",
"ui": {
"label": "Age"
}
},
"adult": {
"type": "boolean",
"ui": {
"label": "Adult",
"help": {
"show": true,
"text": "?",
"content": "Adults can play games"
}
}
}
}
}
@@ -0,0 +1,17 @@
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"age": {
"type": "integer"
},
"adult": {
"type": "boolean"
}
}
}
@@ -0,0 +1,138 @@
/**
* Fixtures added here.
* Please make sure the value name is the same with json file name.
*/
const fixtures = [
{
value: "basic",
label: {
cn: "基础使用",
en: "Basic"
}
},
{
value: "basic-rich-display",
label: {
cn: "基础使用-丰富显示",
en: "Basic-Rich Display"
}
},
{
value: "basic-multi-columns",
label: {
cn: "基础使用-多列布局",
en: "Basic-Multi Columns"
}
},
{
value: "basic-media-preview",
label: {
cn: "基础使用-媒体预览",
en: "Basic-Media Preview"
}
},
{
value: "basic-label-left",
label: {
cn: "基础使用-标签居左",
en: "Basic-Label Left"
}
},
{
value: "basic-verification-rule",
label: {
cn: "基础使用-校验规则",
en: "Basic-Verification Rule"
}
},
{
value: "basic-array-type",
label: {
cn: "基础使用-数组类型",
en: "Basic-Array Type"
}
},
{
value: "basic-table-array",
label: {
cn: "基础使用-表格数组",
en: "Basic-Table Array"
}
},
{
value: "basic-tabs-array",
label: {
cn: "基础使用-标签数组",
en: "Basic-Tabs Array"
}
},
{
value: "basic-separator",
label: {
cn: "基础使用-分隔栏",
en: "Basic-Separator"
}
},
{
value: "adv-control-interaction",
label: {
cn: "高级玩法-控件交互 dx表达式",
en: "Adv-Control Interaction [dx expression]"
}
},
{
value: "adv-array-item-interaction",
label: {
cn: "高级玩法-数组项交互 dx表达式",
en: "Adv-Array Item Interaction [dx expression]"
}
},
{
value: "adv-selector-interaction",
label: {
cn: "高级玩法-下拉框值交互 dx表达式",
en: "Adv-Selector Interaction [dx expression]"
}
},
{
value: "adv-check-association",
label: {
cn: "高级玩法-校验关联 dx表达式",
en: "Adv-Check Association [dx expression]"
}
},
{
value: "adv-custom-rule",
label: {
cn: "高级玩法-自定义校验规则 dx表达式",
en: "Adv-Custom Rule [dx expression]"
}
},
{
value: "adv-global-constant",
label: {
cn: "高级玩法-全局常量 dx表达式",
en: "Adv-Global Constant [dx expression]"
}
},
{
value: "adv-follow",
label: {
cn: "高级玩法-跟随 dx表达式",
en: "Adv-Follow [dx expression]"
}
},
{
value: "adv-temp-value",
label: {
cn: "高级玩法-临时变量 dx表达式",
en: "Adv-Temp Value [dx expression]"
}
}
];
fixtures.map(item => {
item.schema = require('./' + item.value + '.json');
});
export default fixtures;
@@ -8,7 +8,7 @@
{{i18n.template}}
<el-select v-model="selectVal" placeholder="please choose" @change="templateChange">
<el-option v-for="item in listOptions" :key="item.value" :label="item.label" :value="item.value">
<el-option v-for="item in listOptions" :key="item.value" :label="item.label" :value="item">
</el-option>
</el-select>
<el-button type="primary" @click="createForm">{{i18n.genForm}}</el-button>
File diff suppressed because it is too large Load Diff