|
1 | 1 | <template lang="pug">
|
2 | 2 | div
|
3 | 3 | fieldset.vue-form-generator(v-if='schema != null', :is='tag')
|
4 |
| - legend(v-if='schema.legend') {{ schema.legend }} |
5 |
| - template(v-for='field in fields') |
| 4 | + template(v-for='field in fields' v-if='fields') |
6 | 5 | .form-group(v-if='fieldVisible(field)', :class='getFieldRowClasses(field)')
|
7 | 6 | label(v-if="fieldTypeHasLabel(field)", :for="getFieldID(field)")
|
8 | 7 | | {{ field.label }}
|
|
16 | 15 | .hint(v-if='field.hint') {{ field.hint }}
|
17 | 16 | .errors.help-block(v-if='fieldErrors(field).length > 0')
|
18 | 17 | span(v-for='(error, index) in fieldErrors(field)', track-by='index') {{ error }}
|
| 18 | + template(v-for='group in groups' v-if='groups') |
| 19 | + legend(v-if='group.legend') {{ group.legend }} |
| 20 | + template(v-for='field in group.fields') |
| 21 | + .form-group(v-if='fieldVisible(field)', :class='getFieldRowClasses(field)') |
| 22 | + label(v-if="fieldTypeHasLabel(field)", :for="getFieldID(field)") |
| 23 | + | {{ field.label }} |
| 24 | + span.help(v-if='field.help') |
| 25 | + i.icon |
| 26 | + .helpText(v-html='field.help') |
| 27 | + .field-wrap |
| 28 | + component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema.sync='field', @model-updated='modelUpdated', @validated="onFieldValidated") |
| 29 | + .buttons(v-if='buttonVisibility(field)') |
| 30 | + button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }} |
| 31 | + .hint(v-if='field.hint') {{ field.hint }} |
| 32 | + .errors.help-block(v-if='fieldErrors(field).length > 0') |
| 33 | + span(v-for='(error, index) in fieldErrors(field)', track-by='index') {{ error }} |
19 | 34 | </template>
|
20 | 35 |
|
21 | 36 | <script>
|
|
92 | 107 | },
|
93 | 108 |
|
94 | 109 | computed: {
|
95 |
| - fields() { |
96 |
| - let res = []; |
97 |
| - if (this.schema) { |
98 |
| - each(this.schema.fields, (field) => { |
99 |
| - if (!this.multiple || field.multi === true) |
100 |
| - res.push(field); |
101 |
| - }); |
102 |
| - } |
103 |
| -
|
104 |
| - return res; |
105 |
| - } |
| 110 | + fields() { |
| 111 | + let res = []; |
| 112 | + if (this.schema && this.schema.fields) { |
| 113 | + each(this.schema.fields, (field) => { |
| 114 | + if (!this.multiple || field.multi === true) |
| 115 | + res.push(field); |
| 116 | + }); |
| 117 | + } |
| 118 | +
|
| 119 | + return res; |
| 120 | + }, |
| 121 | + groups() { |
| 122 | + let res = []; |
| 123 | + if (this.schema && this.schema.groups) { |
| 124 | + each(this.schema.groups, (group) => { |
| 125 | + res.push(group); |
| 126 | + }); |
| 127 | + } |
| 128 | +
|
| 129 | + return res; |
| 130 | + } |
106 | 131 | },
|
107 | 132 |
|
108 | 133 | watch: {
|
|
0 commit comments