Skip to content

Commit

Permalink
remove .sync
Browse files Browse the repository at this point in the history
add options prop to abstractField
remove beforeMount
  • Loading branch information
icebob committed May 25, 2017
1 parent b4dc972 commit d008869
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dev/grouping/app.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="html">
<form>
<vue-form-generator :schema="schema" :model="model" :options="formOptions"></vue-form-generator>
<vue-form-generator :schema="schema" :model="model" :options="formOptions" tag="section"></vue-form-generator>
<pre>{{ model }}</pre>
</form>
</template>
Expand Down
6 changes: 4 additions & 2 deletions src/fields/abstractField.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default {
props: [
"model",
"schema",
"options",
"disabled"
],

Expand Down Expand Up @@ -163,14 +164,15 @@ export default {
},

getFieldID(schema) {
const idPrefix = this.options && this.options.fieldIdPrefix ? this.options.fieldIdPrefix : "";
// Try to get a reasonable default id from the schema,
// then slugify it.
if (typeof schema.id !== "undefined") {
// If an ID's been explicitly set, use it unchanged
return schema.idPrefix + schema.id;
return idPrefix + schema.id;
} else {
// Return the slugified version of either:
return schema.idPrefix + (schema.inputName || schema.label || schema.model)
return idPrefix + (schema.inputName || schema.label || schema.model)
// NB: This is a very simple, conservative, slugify function,
// avoiding extra dependencies.
.toString()
Expand Down
20 changes: 2 additions & 18 deletions src/formGenerator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ div.vue-form-generator(v-if='schema != null')
i.icon
.helpText(v-html='field.help')
.field-wrap
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema.sync='field', @model-updated='modelUpdated', @validated="onFieldValidated")
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :options='options', @model-updated='modelUpdated', @validated="onFieldValidated")
.buttons(v-if='buttonVisibility(field)')
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }}
.hint(v-if='field.hint') {{ field.hint }}
Expand All @@ -27,7 +27,7 @@ div.vue-form-generator(v-if='schema != null')
i.icon
.helpText(v-html='field.help')
.field-wrap
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema.sync='field', @model-updated='modelUpdated', @validated="onFieldValidated")
component(:is='getFieldType(field)', :disabled='fieldDisabled(field)', :model='model', :schema='field', :options='options',@model-updated='modelUpdated', @validated="onFieldValidated")
.buttons(v-if='buttonVisibility(field)')
button(v-for='btn in field.buttons', @click='buttonClickHandler(btn, field)', :class='btn.classes') {{ btn.label }}
.hint(v-if='field.hint') {{ field.hint }}
Expand Down Expand Up @@ -150,22 +150,6 @@ div.vue-form-generator(v-if='schema != null')
}
},
beforeMount() {
// Add idPrefix to fields if fieldIdPrefix is set
if ("groups" in this.schema) {
for (let group of this.schema.groups) {
for (let field of group.fields) {
field.idPrefix = this.options.fieldIdPrefix || "";
}
}
}
if ("fields" in this.schema) {
for (let field of this.schema.fields) {
field.idPrefix = this.options.fieldIdPrefix || "";
}
}
},
mounted() {
this.$nextTick(() => {
if (this.model) {
Expand Down

0 comments on commit d008869

Please sign in to comment.