diff --git a/.babelrc b/.babelrc index f05d90d9..f1c00cea 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,5 @@ { - "presets": ["es2015", "stage-0"], + "presets": ["es2015", "stage-2"], "plugins": ["transform-runtime"], "comments": false } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7afb6e7e..554e77ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,44 @@ + +## 0.6.1 (2016-11-28) + +* :package: Build v0.6.1 ([79580a2](https://github.com/icebob/vue-form-generator/commit/79580a2)) +* Add missing opening brace ([6842f1b](https://github.com/icebob/vue-form-generator/commit/6842f1b)) +* bump version ([1976b4a](https://github.com/icebob/vue-form-generator/commit/1976b4a)) +* Fixed bower file syntax error #98 ([06b0022](https://github.com/icebob/vue-form-generator/commit/06b0022)), closes [#98](https://github.com/icebob/vue-form-generator/issues/98) + + + + +# 0.6.0 (2016-11-14) + +* :bug: Fix options prop default #91 ([3d2e821](https://github.com/icebob/vue-form-generator/commit/3d2e821)), closes [#91](https://github.com/icebob/vue-form-generator/issues/91) +* :package: build ([51abcca](https://github.com/icebob/vue-form-generator/commit/51abcca)) +* :package: Build ([ce72dc4](https://github.com/icebob/vue-form-generator/commit/ce72dc4)) +* :package: bump version & build ([d56f93c](https://github.com/icebob/vue-form-generator/commit/d56f93c)) +* add bower ([ce44822](https://github.com/icebob/vue-form-generator/commit/ce44822)) +* add number prop to input field ([a40e23c](https://github.com/icebob/vue-form-generator/commit/a40e23c)) +* add step attribute to number field #92 ([ce64c4e](https://github.com/icebob/vue-form-generator/commit/ce64c4e)) +* Fix #82 ([7a83777](https://github.com/icebob/vue-form-generator/commit/7a83777)), closes [#82](https://github.com/icebob/vue-form-generator/issues/82) +* Fix #84 ([2c36001](https://github.com/icebob/vue-form-generator/commit/2c36001)), closes [#84](https://github.com/icebob/vue-form-generator/issues/84) +* Fix #84 ([58093c7](https://github.com/icebob/vue-form-generator/commit/58093c7)), closes [#84](https://github.com/icebob/vue-form-generator/issues/84) +* fix lints ([1f8f3d9](https://github.com/icebob/vue-form-generator/commit/1f8f3d9)) +* Implement #78 ([f92b193](https://github.com/icebob/vue-form-generator/commit/f92b193)) +* quick fix for #85 ([cad76da](https://github.com/icebob/vue-form-generator/commit/cad76da)), closes [#85](https://github.com/icebob/vue-form-generator/issues/85) +* remote customLabel prop from multiselect because give errors ([5dfc5bb](https://github.com/icebob/vue-form-generator/commit/5dfc5bb)) +* remove commit message package ([682c6ab](https://github.com/icebob/vue-form-generator/commit/682c6ab)) +* Update README.md ([8128a52](https://github.com/icebob/vue-form-generator/commit/8128a52)) +* docs: fix npms.io badge url ([475eb91](https://github.com/icebob/vue-form-generator/commit/475eb91)) +* test: add attr checker to switch field ([2ed434e](https://github.com/icebob/vue-form-generator/commit/2ed434e)) +* test: add file input attr test ([352fb20](https://github.com/icebob/vue-form-generator/commit/352fb20)) +* test: add test to #82 ([aefdbac](https://github.com/icebob/vue-form-generator/commit/aefdbac)) +* test: attr test to submit field ([1627c71](https://github.com/icebob/vue-form-generator/commit/1627c71)) +* test: lock multiselect version ([5b0a4d0](https://github.com/icebob/vue-form-generator/commit/5b0a4d0)) +* fix: customLabel return a basic function when undefined instead of null ([9b3d51d](https://github.com/icebob/vue-form-generator/commit/9b3d51d)) +* bug: fix quotes ([13d6e0f](https://github.com/icebob/vue-form-generator/commit/13d6e0f)) +* new: add form POST example ([08412c7](https://github.com/icebob/vue-form-generator/commit/08412c7)) + + + # 0.5.0 (2016-09-28) diff --git a/README.md b/README.md index 93b02a7f..c5c5dfe8 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,14 @@ A schema-based form generator component for Vue.js v1.x.x [](https://www.codacy.com/app/mereg-norbert/vue-form-generator?utm_source=github.com&utm_medium=referral&utm_content=icebob/vue-form-generator&utm_campaign=Badge_Grade) [](https://travis-ci.org/icebob/vue-form-generator) [](https://coveralls.io/github/icebob/vue-form-generator?branch=master) -[]() +[]() +[](http://packagequality.com/#?package=vue-form-generator) [](https://david-dm.org/icebob/vue-form-generator) [](https://david-dm.org/icebob/vue-form-generator#info=devDependencies) [](https://www.npmjs.com/package/vue-form-generator) -**Vue v2.x is not supported!** +**Vue v2.x support is under development!** ## Demo [JSFiddle simple example](https://jsfiddle.net/icebob/0mg1v81e/) @@ -65,7 +66,7 @@ Vue.use(VueFormGenerator); export default { data: { - model: + model: { id: 1, name: "John Doe", password: "J0hnD03!x4", diff --git a/bower.json b/bower.json new file mode 100644 index 00000000..b98ed1a4 --- /dev/null +++ b/bower.json @@ -0,0 +1,32 @@ +{ + "name": "vue-form-generator", + "version": "0.6.1", + "homepage": "https://github.com/icebob/vue-form-generator", + "authors": [ + "Icebob" + ], + "description": "A schema-based form generator component for Vue.js", + "main": [ + "dist/vue-form-generator.js", + "dist/vue-form-generator.css" + ], + "moduleType": [ + "amd" + ], + "keywords": [ + "vue", + "vuejs", + "form", + "generator", + "schema", + "json" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/dev/app.vue b/dev/app.vue index ff01b560..8de5b70d 100644 --- a/dev/app.vue +++ b/dev/app.vue @@ -1,31 +1,27 @@ - - .row - .col-md-10.col-md-offset-1 - data-table(:rows="rows", :selected="selected", :select="selectRow") - - .row(v-show="model") - .col-md-5.col-md-offset-1 - .control-buttons.text-center - button.btn.btn-default.new(@click="newModel") - i.fa.fa-plus - | New - button.btn.btn-primary.save(@click="saveModel") - i.fa.fa-floppy-o - | Save - i.fa.fa-warning(v-if="showWarning()") - button.btn.btn-danger.delete(@click="deleteModel") - i.fa.fa-trash - | Delete - - .errors.text-center - div.alert.alert-danger(v-for="item in validationErrors", track-by="$index") {{ item.field.label}}: - strong {{ item.error }} - - vue-form-generator(:schema='schema', :model='model', :options='formOptions', :multiple="selected.length > 1", v-ref:form, :is-new-model="isNewModel") - - - .col-md-6 - pre(v-if='model') {{{ model | prettyJSON }}} + + + + + + + + + + + New + Save + Delete + + + {{ item.field.label}}: {{ item.error }} + + + + + + + + @@ -82,6 +78,9 @@ return this.$refs.form.errors; return []; + }, + prettyModel(){ + return filters.prettyJSON(this.model); } }, @@ -95,10 +94,12 @@ selectRow(event, row, add) { this.isNewModel = false; if ( (add || (event && event.ctrlKey))) { - if (this.selected.indexOf(row) != -1) - this.selected.$remove(row); - else + if (this.selected.indexOf(row) != -1){ + var index = this.selected.indexOf(row); + this.selected.splice(index, 1); + } else { this.selected.push(row); + } } else { this.clearSelection(); this.selected.push(row); @@ -114,12 +115,11 @@ generateModel() { if (this.selected.length == 1) { this.model = cloneDeep(this.selected[0]); - } - else if (this.selected.length > 1) { + } else if (this.selected.length > 1) { this.model = VueFormGenerator.schema.mergeMultiObjectFields(Schema, this.selected); - } - else + } else { this.model = null; + } }, newModel() { @@ -146,6 +146,7 @@ } } else { + console.warn("Error saving model..."); // Validation error } }, @@ -162,7 +163,8 @@ deleteModel() { if (this.selected.length > 0) { each(this.selected, (row) => { - this.rows.$remove(row); + let index = this.rows.indexOf(row); + this.rows.splice(index, 1) }) this.clearSelection(); } @@ -180,22 +182,30 @@ }, validate() { + console.log("validate", this.$refs.form, this.$refs.form.validate()); return this.$refs.form.validate(); + }, + + modelUpdated(newVal, schema) { + console.log("main model has updated", newVal, schema); + // this.model[schema] = newVal; } }, - ready() { - window.app = this; + mounted() { + this.$nextTick(function () { + window.app = this; - if (users.length > 0) { - this.selectRow(null, fakerator.random.arrayElement(users)); - } + if (users.length > 0) { + this.selectRow(null, fakerator.random.arrayElement(users)); + } - // Localize validate errors - VueFormGenerator.validators.resources.fieldIsRequired = "Ezt a mezőt kötelező kitölteni!"; - VueFormGenerator.validators.resources.textTooSmall = "A szöveg túl rövid! Jelenleg: {0}, minimum: {1}"; + // Localize validate errors + // VueFormGenerator.validators.resources.fieldIsRequired = "Ezt a mezőt kötelező kitölteni!"; + // VueFormGenerator.validators.resources.textTooSmall = "A szöveg túl rövid! Jelenleg: {0}, minimum: {1}"; + }) } } diff --git a/dev/index.html b/dev/index.html index 3575d9e4..b3751254 100644 --- a/dev/index.html +++ b/dev/index.html @@ -3,39 +3,39 @@ vue-form-generator development - - - - + + + + - + - - - + + + - - - + + + - + - + - +