Skip to content

Commit ca783ba

Browse files
Merge branch 'lb_next'
# Conflicts: # dev/index.html # src/formGenerator.vue
2 parents 35be49e + acd1e22 commit ca783ba

14 files changed

+233
-40
lines changed

CHANGELOG.md

+41
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
<a name="0.6.1"></a>
2+
## 0.6.1 (2016-11-28)
3+
4+
* :package: Build v0.6.1 ([79580a2](https://github.com/icebob/vue-form-generator/commit/79580a2))
5+
* Add missing opening brace ([6842f1b](https://github.com/icebob/vue-form-generator/commit/6842f1b))
6+
* bump version ([1976b4a](https://github.com/icebob/vue-form-generator/commit/1976b4a))
7+
* 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)
8+
9+
10+
11+
<a name="0.6.0"></a>
12+
# 0.6.0 (2016-11-14)
13+
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)
15+
* :package: build ([51abcca](https://github.com/icebob/vue-form-generator/commit/51abcca))
16+
* :package: Build ([ce72dc4](https://github.com/icebob/vue-form-generator/commit/ce72dc4))
17+
* :package: bump version & build ([d56f93c](https://github.com/icebob/vue-form-generator/commit/d56f93c))
18+
* add bower ([ce44822](https://github.com/icebob/vue-form-generator/commit/ce44822))
19+
* add number prop to input field ([a40e23c](https://github.com/icebob/vue-form-generator/commit/a40e23c))
20+
* add step attribute to number field #92 ([ce64c4e](https://github.com/icebob/vue-form-generator/commit/ce64c4e))
21+
* Fix #82 ([7a83777](https://github.com/icebob/vue-form-generator/commit/7a83777)), closes [#82](https://github.com/icebob/vue-form-generator/issues/82)
22+
* Fix #84 ([2c36001](https://github.com/icebob/vue-form-generator/commit/2c36001)), closes [#84](https://github.com/icebob/vue-form-generator/issues/84)
23+
* Fix #84 ([58093c7](https://github.com/icebob/vue-form-generator/commit/58093c7)), closes [#84](https://github.com/icebob/vue-form-generator/issues/84)
24+
* fix lints ([1f8f3d9](https://github.com/icebob/vue-form-generator/commit/1f8f3d9))
25+
* Implement #78 ([f92b193](https://github.com/icebob/vue-form-generator/commit/f92b193))
26+
* 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)
27+
* remote customLabel prop from multiselect because give errors ([5dfc5bb](https://github.com/icebob/vue-form-generator/commit/5dfc5bb))
28+
* remove commit message package ([682c6ab](https://github.com/icebob/vue-form-generator/commit/682c6ab))
29+
* Update README.md ([8128a52](https://github.com/icebob/vue-form-generator/commit/8128a52))
30+
* docs: fix npms.io badge url ([475eb91](https://github.com/icebob/vue-form-generator/commit/475eb91))
31+
* test: add attr checker to switch field ([2ed434e](https://github.com/icebob/vue-form-generator/commit/2ed434e))
32+
* test: add file input attr test ([352fb20](https://github.com/icebob/vue-form-generator/commit/352fb20))
33+
* test: add test to #82 ([aefdbac](https://github.com/icebob/vue-form-generator/commit/aefdbac))
34+
* test: attr test to submit field ([1627c71](https://github.com/icebob/vue-form-generator/commit/1627c71))
35+
* test: lock multiselect version ([5b0a4d0](https://github.com/icebob/vue-form-generator/commit/5b0a4d0))
36+
* fix: customLabel return a basic function when undefined instead of null ([9b3d51d](https://github.com/icebob/vue-form-generator/commit/9b3d51d))
37+
* bug: fix quotes ([13d6e0f](https://github.com/icebob/vue-form-generator/commit/13d6e0f))
38+
* new: add form POST example ([08412c7](https://github.com/icebob/vue-form-generator/commit/08412c7))
39+
40+
41+
142
<a name="0.5.0"></a>
243
# 0.5.0 (2016-09-28)
344

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ A schema-based form generator component for Vue.js v1.x.x
44
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/912039aa815e40de8315032519aa7e6c)](https://www.codacy.com/app/mereg-norbert/vue-form-generator?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=icebob/vue-form-generator&amp;utm_campaign=Badge_Grade)
55
[![Build Status](https://travis-ci.org/icebob/vue-form-generator.svg?branch=master)](https://travis-ci.org/icebob/vue-form-generator)
66
[![Coverage Status](https://coveralls.io/repos/github/icebob/vue-form-generator/badge.svg?branch=master)](https://coveralls.io/github/icebob/vue-form-generator?branch=master)
7-
[![NPMS.io score](https://badges.npms.io/cross-spawn.svg)]()
7+
[![NPMS.io score](https://badges.npms.io/vue-form-generator.svg)]()
8+
[![Package Quality](http://npm.packagequality.com/shield/vue-form-generator.svg)](http://packagequality.com/#?package=vue-form-generator)
89

910
[![Dependency Status](https://david-dm.org/icebob/vue-form-generator.svg)](https://david-dm.org/icebob/vue-form-generator)
1011
[![devDependency Status](https://david-dm.org/icebob/vue-form-generator/dev-status.svg)](https://david-dm.org/icebob/vue-form-generator#info=devDependencies)
1112
[![Downloads](https://img.shields.io/npm/dt/vue-form-generator.svg)](https://www.npmjs.com/package/vue-form-generator)
1213

13-
**Vue v2.x is not supported!**
14+
**Vue v2.x support is under development!**
1415

1516
## Demo
1617
[JSFiddle simple example](https://jsfiddle.net/icebob/0mg1v81e/)
@@ -65,7 +66,7 @@ Vue.use(VueFormGenerator);
6566
export default {
6667
data: {
6768
68-
model:
69+
model: {
6970
id: 1,
7071
name: "John Doe",
7172
password: "J0hnD03!x4",

bower.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "vue-form-generator",
3+
"version": "0.6.1",
4+
"homepage": "https://github.com/icebob/vue-form-generator",
5+
"authors": [
6+
"Icebob"
7+
],
8+
"description": "A schema-based form generator component for Vue.js",
9+
"main": [
10+
"dist/vue-form-generator.js",
11+
"dist/vue-form-generator.css"
12+
],
13+
"moduleType": [
14+
"amd"
15+
],
16+
"keywords": [
17+
"vue",
18+
"vuejs",
19+
"form",
20+
"generator",
21+
"schema",
22+
"json"
23+
],
24+
"license": "MIT",
25+
"ignore": [
26+
"**/.*",
27+
"node_modules",
28+
"bower_components",
29+
"test",
30+
"tests"
31+
]
32+
}

dev/schema.js

+57-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ module.exports = {
135135
type: "input",
136136
inputType: "range",
137137
label: "Range",
138-
model: "age",
138+
model: "rank",
139+
min: 0,
140+
max: 10,
139141
styleClasses: "half-width"
140142
},
141143
{
@@ -265,11 +267,63 @@ module.exports = {
265267
rows: 4,
266268
validator: validators.string
267269
},
270+
{
271+
type: "text",
272+
label: "Field with buttons",
273+
model: "address.geo",
274+
disabled: false,
275+
get(model) {
276+
if (model && model.address && model.address.geo)
277+
return model.address.geo.latitude + ", " + model.address.geo.longitude;
278+
},
279+
set(model, val) {
280+
let values = val.split(",");
281+
if (!model.address)
282+
model.address = {};
283+
if (!model.address.geo)
284+
model.address.geo = {};
285+
if (values.length > 0 && values[0].trim() != "")
286+
model.address.geo.latitude = parseFloat(values[0].trim());
287+
else
288+
model.address.geo.latitude = 0
289+
if (values.length > 1 && values[1].trim() != "")
290+
model.address.geo.longitude = parseFloat(values[1].trim());
291+
else
292+
model.address.geo.longitude = 0
293+
},
294+
buttons: [{
295+
classes: "btn-location",
296+
label: "Current location",
297+
onclick: function(model) {
298+
if (navigator.geolocation) {
299+
navigator.geolocation.getCurrentPosition((pos) => {
300+
if (!model.address)
301+
model.address = {};
302+
if (!model.address.geo)
303+
model.address.geo = {};
304+
model.address.geo.latitude = pos.coords.latitude.toFixed(5);
305+
model.address.geo.longitude = pos.coords.longitude.toFixed(5);
306+
});
307+
} else {
308+
alert("Geolocation is not supported by this browser.");
309+
}
310+
}
311+
}, {
312+
classes: "btn-clear",
313+
label: "Clear",
314+
onclick: function(model) {
315+
model.address.geo = {
316+
latitude: 0,
317+
longitude: 0
318+
};
319+
}
320+
}]
321+
},
268322
{
269323
type: "staticMap",
270324
label: "Map",
271325
model: "address.geo",
272-
visible: true,
326+
visible: false,
273327
staticMapOptions: {
274328
lat: "latitude",
275329
lng: "longitude",
@@ -496,7 +550,7 @@ module.exports = {
496550
format: "YYYY-MM-DD"
497551
},
498552
onChanged(model, newVal, oldVal, field) {
499-
model.age = moment().year() - moment(newVal).year();
553+
//model.age = moment().year() - moment(newVal).year();
500554
}
501555
},
502556
{

dist/vue-form-generator.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-form-generator.js

+20-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "vue-form-generator",
3-
"version": "0.5.0",
3+
"version": "0.6.1",
44
"description": "A schema-based form generator component for Vue.js",
55
"homepage": "https://github.com/icebob/vue-form-generator",
66
"main": "dist/vue-form-generator.js",
77
"scripts": {
88
"prebuild": "npm run test",
9-
"build": "webpack --progress -p --config webpack.build.config.js",
9+
"build": "webpack --progress --config webpack.build.config.js",
1010
"dev": "webpack-dev-server --config webpack.dev.config.js --inline --hot --content-base dev/",
1111
"lint": "eslint --ext=.js,.vue src test/unit/specs",
1212
"coverall": "cat ./test/unit/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
@@ -56,7 +56,6 @@
5656
"eslint-plugin-vue": "0.1.1",
5757
"extract-text-webpack-plugin": "1.0.1",
5858
"fakerator": "0.3.0",
59-
"git-commit-message-convention": "git://github.com/kazupon/git-commit-message-convention.git#065dfffbe2de5f6f16150aac9d4db7fdf5515e56",
6059
"gitbook-cli": "2.3.0",
6160
"inject-loader": "2.0.1",
6261
"isparta-loader": "2.0.0",

src/fields/fieldInput.vue

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
input.form-control(
44
:type="schema.inputType",
55
v-model="value",
6+
number="schema.inputType == 'number'"
67
:disabled="disabled",
78

89
:accept="schema.accept",
@@ -59,12 +60,10 @@
5960
this.schema.inputType === "datetime" ||
6061
this.schema.inputType === "datetimelocal") {
6162
return new Date(value).getTime();
62-
}else{
63-
return value;
6463
}
65-
} else {
66-
return value;
6764
}
65+
66+
return value;
6867
}
6968
}
7069
};

src/fields/fieldNumber.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template lang="jade">
2-
input.form-control(type="number", v-model="value", number, :autocomplete="schema.autocomplete", :disabled="disabled", :max="schema.max", :min="schema.min", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
2+
input.form-control(type="number", v-model="value", number, :autocomplete="schema.autocomplete", :disabled="disabled", :max="schema.max", :min="schema.min", :step="schema.step", :placeholder="schema.placeholder", :readonly="schema.readonly", :name="schema.inputName")
33
</template>
44

55
<script>

src/formGenerator.vue

+26-8
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,31 @@ div
3333
export default {
3434
components: fieldComponents,
3535
36-
props: [
37-
"schema",
38-
"options",
39-
"model",
40-
"multiple",
41-
"isNewModel"
42-
],
36+
props: {
37+
schema: Object,
38+
39+
model: Object,
40+
41+
options: {
42+
type: Object,
43+
default() {
44+
return {
45+
validateAfterLoad: false,
46+
validateAfterChanged: false
47+
};
48+
}
49+
},
50+
51+
multiple: {
52+
type: Boolean,
53+
default: false
54+
},
55+
56+
isNewModel: {
57+
type: Boolean,
58+
default: false
59+
}
60+
},
4361
4462
data () {
4563
return {
@@ -77,7 +95,7 @@ div
7795
7896
mounted() {
7997
// First load, running validation if neccessary
80-
if (this.options && this.options.validateAfterLoad === true && this.isNewModel !== true){
98+
if (this.options.validateAfterLoad === true && this.isNewModel !== true){
8199
this.validate();
82100
} else {
83101
this.clearValidationErrors();

test/unit/karma.conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = function(config) {
2020
"https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js",
2121
"https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js",
2222
"https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js",
23-
"https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js",
23+
"https://rawgit.com/monterail/vue-multiselect/v1.1.4/lib/vue-multiselect.min.js",
2424
"https://rawgit.com/nosir/cleave.js/master/dist/cleave.js",
2525
"https://nosir.github.io/cleave.js/lib/cleave-phone.i18n.js",
2626
"https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/8.5.1/nouislider.js",

test/unit/specs/VueFormGenerator.spec.js

+34-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Vue.use(VueFormGenerator);
77

88
let el, vm;
99

10-
function createFormGenerator(schema = {}, model = null, options = {}, multiple = false) {
10+
function createFormGenerator(schema = {}, model = null, options, multiple) {
1111
el = document.createElement("div");
1212
// eslint-disable-next-line quotes
1313
el.innerHTML = `<vue-form-generator :schema="schema" :model="model" :options="options" :multiple="multiple" ref="form"></vue-form-generator>`;
@@ -417,6 +417,39 @@ describe("VueFormGenerator.vue", () => {
417417

418418
});
419419

420+
describe("check if option null", () => {
421+
let schema = {
422+
fields: [
423+
{
424+
type: "text",
425+
label: "Name",
426+
model: "name"
427+
}
428+
]
429+
};
430+
431+
let model = { name: "Me" };
432+
let form, el, vm;
433+
434+
before( () => {
435+
[el, vm] = createFormGenerator(schema, model);
436+
form = vm.$refs.form;
437+
document.body.appendChild(el);
438+
});
439+
440+
after( () => {
441+
document.body.removeChild(el);
442+
});
443+
444+
it("should be validation error at ready()", (done) => {
445+
vm.$nextTick( () => {
446+
expect(form).to.be.defined;
447+
expect(form.options).to.be.defined;
448+
done();
449+
});
450+
});
451+
});
452+
420453
describe("check validateAfterLoad option", () => {
421454
let schema = {
422455
fields: [

test/unit/specs/fields/fieldNumber.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ describe("fieldNumber.vue", function() {
6060
});
6161
});
6262

63+
it("check step attribute", (done) => {
64+
vm.$set("schema.step", 0.1);
65+
vm.$nextTick(() => {
66+
expect(input.step).to.be.equal("0.1");
67+
vm.$set("schema.step", null);
68+
done();
69+
});
70+
});
71+
6372
it("input value should be the model value after changed", (done) => {
6473
model.age = 35;
6574
vm.$nextTick( () => {
@@ -75,6 +84,7 @@ describe("fieldNumber.vue", function() {
7584

7685
vm.$nextTick( () => {
7786
expect(model.age).to.be.equal(50);
87+
expect(model.age).to.be.a("number");
7888
done();
7989
});
8090

test/unit/specs/fields/fieldVueMultiSelect.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function createField(test, schema = {}, model = null, disabled = false, options)
1313
[ el, vm, field ] = createVueField(test, "fieldVueMultiSelect", schema, model, disabled, options);
1414
}
1515

16-
describe.skip("fieldVueMultiSelect.vue", function() {
16+
describe("fieldVueMultiSelect.vue", function() {
1717

1818
describe("check template", () => {
1919
let schema = {

0 commit comments

Comments
 (0)