-
Notifications
You must be signed in to change notification settings - Fork 533
/
Copy pathmain.js
126 lines (121 loc) · 2.56 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var VueFormGenerator = window.VueFormGenerator;
var vm = new Vue({
el: "#app",
components: {
"vue-form-generator": VueFormGenerator.component
},
filters: {
prettyJSON: function(json) {
if (json) {
json = JSON.stringify(json, undefined, 4);
json = json.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = "number";
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = "key";
} else {
cls = "string";
}
} else if (/true|false/.test(match)) {
cls = "boolean";
} else if (/null/.test(match)) {
cls = "null";
}
return "<span class=\"" + cls + "\">" + match + "</span>";
});
}
}
},
data: {
model: {
id: 1,
name: "John Doe",
password: "J0hnD03!x4",
skills: "Javascript",
email: "[email protected]",
status: true
},
schema: {
fields: [
{
type: "text",
label: "ID",
model: "id",
inputName: "id",
readonly: true,
featured: false,
disabled: true
},
{
type: "text",
label: "Name",
model: "name",
inputName: "name",
readonly: false,
featured: true,
required: true,
disabled: false,
placeholder: "User's name",
validator: VueFormGenerator.validators.string
},
{
type: "password",
label: "Password",
model: "password",
inputName: "password",
min: 6,
required: true,
hint: "Minimum 6 characters",
validator: VueFormGenerator.validators.string
},
{
type: "email",
label: "E-mail",
model: "email",
inputName: "email",
placeholder: "User's e-mail address",
validator: VueFormGenerator.validators.email
},
{
type: "select",
label: "Skills",
model: "skills",
inputName: "skills",
required: true,
values: [
"HTML5",
"Javascript",
"CSS3",
"CoffeeScript",
"AngularJS",
"ReactJS",
"VueJS"
],
validator: VueFormGenerator.validators.string
},
{
type: "checkbox",
label: "Status",
model: "status",
inputName: "status",
multi: true,
readonly: false,
featured: false,
disabled: false,
default: true
},
{
type: "submit",
label: "",
buttonText: "Submit",
validateBeforeSubmit: true
}
]
},
formOptions: {
validateAfterLoad: false,
validateAfterChanged: false
}
}
});