5
5
<div class =" col-sm-12" >
6
6
<vue-form-generator :schema =" schema" :model =" model" :options =" formOptions" tag =" section" >
7
7
8
- <template slot="label" slot-scope="{ field }">
9
- <h1 >Custom label : {{ field.label }}</h1 >
8
+ <template slot="label" slot-scope="{ field, getValueFromOption }">
9
+ <h3 >< i :class = " `fa fa-${getIcon(field, getValueFromOption)}` " ></ i > {{ field.label }}</h3 >
10
10
</template >
11
11
12
12
<template slot="help" slot-scope="{ field }">
13
13
<span v-if =' field.help' class =" help" >
14
- <span @click.prevent =" testClick(field.help, $event)" >Custom help</span >
15
- <i class =" icon" ></i >
14
+ <span @click.prevent =" testClick(field.help, $event)" >Need help</span >
15
+ <i class =" fa fa-question" ></i >
16
+ <vue-markdown class =" helpText" :source =" field.help" ></vue-markdown >
16
17
</span >
17
18
</template >
18
19
19
20
<template slot="hint" slot-scope="{ field, getValueFromOption }">
20
- <span >Custom hint</span >
21
- <div class =" hint" v-html =" getValueFromOption(field, 'hint', undefined)" ></div >
21
+ <div class =" hint hint--info" >
22
+ <i class =" fa fa-info-circle" ></i >
23
+ <span v-html =" getValueFromOption(field, 'hint', undefined)" ></span >
24
+ </div >
22
25
</template >
23
26
24
27
<template slot="errors" slot-scope="{ errors, field, getValueFromOption }">
25
28
<span >Custom errors</span >
26
29
<table class =" errors help-block" >
27
30
<tbody >
28
- <tr >
29
- <td v-for =" (error, index) in errors" :key =" index" v-html =" error" ></td >
30
- </tr >
31
+ <thead >
32
+ <tr >
33
+ <th scope =" col" id =" " >Index</th >
34
+ <th scope =" col" id =" " >Error</th >
35
+ </tr >
36
+ </thead >
37
+ <tbody >
38
+ <tr v-for =" (error, index) in errors" :key =" index" >
39
+ <td >{{index}}</td >
40
+ <td v-html =" error" ></td >
41
+ </tr >
42
+ </tbody >
31
43
</tbody >
32
44
</table >
33
45
</template >
45
57
46
58
<script >
47
59
import mixinUtils from " ../../mixins/utils.js" ;
60
+ import VueMarkdown from " vue-markdown" ;
48
61
49
62
export default {
50
63
mixins: [mixinUtils],
51
-
64
+ components: {
65
+ VueMarkdown
66
+ },
52
67
data () {
53
68
return {
54
69
model: {
55
70
name: " Brian Blessed" ,
56
71
email: " brian@hawkman.mongo" ,
57
72
others: {
58
- more: " More " ,
59
- things: " Things "
73
+ more: " " ,
74
+ things: 2
60
75
},
61
76
single: " blah" ,
62
- subname : " "
77
+ color : " "
63
78
},
64
79
65
80
schema: {
@@ -87,10 +102,10 @@ export default {
87
102
fields: [
88
103
{
89
104
type: " input" ,
90
- model: " subname " ,
91
- label: " Name " ,
105
+ model: " color " ,
106
+ label: " Some color " ,
92
107
fieldOptions: {
93
- inputType: " text "
108
+ inputType: " color "
94
109
},
95
110
required: true ,
96
111
validator: [" required" ]
@@ -101,6 +116,7 @@ export default {
101
116
type: " input" ,
102
117
model: " email" ,
103
118
label: " Email" ,
119
+ hint: " We will not share your email with third-party" ,
104
120
fieldOptions: {
105
121
inputType: " email"
106
122
}
@@ -125,16 +141,30 @@ export default {
125
141
type: " input" ,
126
142
model: " others.more" ,
127
143
label: " More" ,
144
+ help: `
145
+ Welcome to this *custom help*
146
+
147
+ some code example
148
+
149
+
150
+ You need a modern browser to fill this field in the best condition.
151
+ * test1
152
+ * test2
153
+
154
+ https://google.com/
155
+
156
+ # Markdown !
157
+ ` ,
128
158
fieldOptions: {
129
- inputType: " text "
159
+ inputType: " date "
130
160
}
131
161
},
132
162
{
133
163
type: " input" ,
134
164
model: " others.things" ,
135
165
label: " Things" ,
136
166
fieldOptions: {
137
- inputType: " text "
167
+ inputType: " number "
138
168
}
139
169
}
140
170
]
@@ -153,6 +183,25 @@ export default {
153
183
methods: {
154
184
testClick (helpText , event ) {
155
185
console .log (helpText, event );
186
+ },
187
+ getIcon (field , getValueFromOption ) {
188
+ let fieldType = getValueFromOption (field, " type" );
189
+ let fieldOptions = getValueFromOption (field, " fieldOptions" );
190
+
191
+ if (fieldType === " input" ) {
192
+ switch (fieldOptions .inputType ) {
193
+ case " email" :
194
+ return " at" ;
195
+ case " number" :
196
+ return " calculator" ;
197
+ case " date" :
198
+ return " calendar-alt" ;
199
+ case " color" :
200
+ return " palette" ;
201
+ default :
202
+ return " file-alt" ;
203
+ }
204
+ }
156
205
}
157
206
},
158
207
@@ -175,4 +224,28 @@ export default {
175
224
color : #00268d ;
176
225
}
177
226
}
227
+ .hint {
228
+ & --info {
229
+ color : #339af0 ;
230
+ }
231
+ }
232
+
233
+ table {
234
+ border-collapse : collapse ;
235
+ border-spacing : 0 ;
236
+ }
237
+ thead th {
238
+ background-color : #efdddd ;
239
+ border : solid 1px #eedddd ;
240
+ color : #6b3333 ;
241
+ padding : 10px ;
242
+ text-align : left ;
243
+ text-shadow : 1px 1px 1px #fff ;
244
+ }
245
+ tbody td {
246
+ border : solid 1px #eedddd ;
247
+ color : #333 ;
248
+ padding : 10px ;
249
+ text-shadow : 1px 1px 1px #fff ;
250
+ }
178
251
</style >
0 commit comments