Skip to content

Commit 31d1861

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into form_name_attr
2 parents 352fb20 + f8db7b0 commit 31d1861

File tree

8 files changed

+320
-30
lines changed

8 files changed

+320
-30
lines changed

dev/schema.js

+32
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,38 @@ module.exports = {
220220
model: "",
221221
styleClasses: "alert alert-info"
222222
},
223+
{
224+
type: "radios",
225+
label: "RADIOS",
226+
model: "radios",
227+
values: [
228+
{name: "HTML5", value:"HTML5-123"},
229+
{name: "Javascript", value:"Javascript-123"},
230+
{name: "CSS3", value:"CSS3-123"},
231+
{name: "CoffeeScript", value:"CoffeeScript-123"},
232+
{name: "AngularJS", value:"AngularJS-123"},
233+
{name: "ReactJS", value:"ReactJS-123"},
234+
{name: "VueJS", value:"VueJS-123"}
235+
],
236+
radiosOptions: {
237+
value:"value",
238+
name:"name"
239+
}
240+
},
241+
{
242+
type: "radios",
243+
label: "RADIOS2",
244+
model: "radios2",
245+
values: [
246+
"HTML5",
247+
"Javascript",
248+
"CSS3",
249+
"CoffeeScript",
250+
"AngularJS",
251+
"ReactJS",
252+
"VueJS"
253+
]
254+
},
223255
{
224256
type: "image",
225257
label: "Avatar (image field)",

package.json

+19-19
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@
3939
"author": "Icebob",
4040
"license": "MIT",
4141
"devDependencies": {
42-
"babel-core": "6.13.2",
42+
"babel-core": "6.14.0",
4343
"babel-loader": "6.2.5",
44-
"babel-plugin-transform-runtime": "6.12.0",
45-
"babel-preset-es2015": "6.13.2",
44+
"babel-plugin-transform-runtime": "6.15.0",
45+
"babel-preset-es2015": "6.14.0",
4646
"babel-preset-stage-0": "6.5.0",
4747
"chai": "3.5.0",
4848
"conventional-changelog-cli": "1.2.0",
4949
"conventional-github-releaser": "1.1.3",
50-
"coveralls": "2.11.12",
51-
"css-loader": "0.23.1",
52-
"eslint": "3.3.1",
50+
"coveralls": "2.11.14",
51+
"css-loader": "0.25.0",
52+
"eslint": "3.6.1",
5353
"eslint-friendly-formatter": "2.0.6",
5454
"eslint-loader": "1.5.0",
55-
"eslint-plugin-html": "1.5.2",
55+
"eslint-plugin-html": "1.5.3",
5656
"eslint-plugin-vue": "0.1.1",
5757
"extract-text-webpack-plugin": "1.0.1",
5858
"fakerator": "0.3.0",
@@ -62,41 +62,41 @@
6262
"isparta-loader": "2.0.0",
6363
"jade": "1.11.0",
6464
"jade-loader": "0.8.0",
65-
"karma": "1.2.0",
65+
"karma": "1.3.0",
6666
"karma-chai": "0.1.0",
6767
"karma-chrome-launcher": "1.0.1",
6868
"karma-coverage": "1.1.1",
6969
"karma-coveralls": "1.1.2",
70-
"karma-mocha": "1.1.1",
71-
"karma-phantomjs-launcher": "1.0.1",
72-
"karma-sinon-chai": "1.2.3",
70+
"karma-mocha": "1.2.0",
71+
"karma-phantomjs-launcher": "1.0.2",
72+
"karma-sinon-chai": "1.2.4",
7373
"karma-sourcemap-loader": "0.3.7",
7474
"karma-spec-reporter": "0.0.26",
7575
"karma-webpack": "1.8.0",
76-
"lodash": "4.15.0",
76+
"lodash": "4.16.2",
7777
"lolex": "1.5.1",
7878
"mocha": "2.5.3",
7979
"mocha-generators": "1.2.0",
8080
"mocha-loader": "0.7.1",
81-
"moment": "2.14.1",
82-
"node-sass": "3.8.0",
81+
"moment": "2.15.1",
82+
"node-sass": "3.10.0",
8383
"phantomjs-prebuilt": "2.1.12",
8484
"sass-loader": "3.2.0",
85-
"sinon": "1.17.5",
85+
"sinon": "1.17.6",
8686
"sinon-chai": "2.8.0",
8787
"stats-webpack-plugin": "0.4.2",
8888
"style-loader": "0.13.1",
8989
"vue-hot-reload-api": "1.3.2",
9090
"vue-html-loader": "1.2.3",
91-
"vue-loader": "8.5.3",
91+
"vue-loader": "8.5.4",
9292
"vue-style-loader": "1.0.0",
9393
"webpack": "1.13.2",
94-
"webpack-dev-middleware": "1.6.1",
95-
"webpack-dev-server": "1.15.0",
94+
"webpack-dev-middleware": "1.8.3",
95+
"webpack-dev-server": "1.16.1",
9696
"webpack-merge": "0.14.1"
9797
},
9898
"dependencies": {
9999
"babel-runtime": "6.11.6",
100-
"vue": "1.0.26"
100+
"vue": "1.0.27"
101101
}
102102
}

src/fields/abstractField.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default {
2525
},
2626

2727
set(newValue) {
28-
2928
if (isFunction(this.formatValueToModel))
3029
newValue = this.formatValueToModel(newValue);
3130

@@ -40,7 +39,7 @@ export default {
4039

4140
watch: {
4241
value: function(newVal, oldVal) {
43-
//console.log("Changed", newVal, oldVal);
42+
// console.log("Changed", newVal, oldVal);
4443
if (isFunction(this.schema.onChanged)) {
4544
this.schema.onChanged(this.model, newVal, oldVal, this.schema);
4645
}

src/fields/fieldNoUiSlider.vue

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="slider" :disabled="disabled" :class="{ 'contain-pips': typeof schema.noUiSliderOptions.pips !== 'undefined', 'contain-tooltip': schema.noUiSliderOptions.tooltips }"></div>
2+
<div class="slider" :disabled="disabled" :class="{ 'contain-pips': containPips, 'contain-tooltip': containTooltip }"></div>
33
</template>
44

55
<script>
@@ -23,6 +23,15 @@
2323
}
2424
},
2525
26+
computed:{
27+
containPips(){
28+
return (this.schema.noUiSliderOptions && (typeof this.schema.noUiSliderOptions.pips) !== "undefined");
29+
},
30+
containTooltip(){
31+
return (this.schema.noUiSliderOptions && this.schema.noUiSliderOptions.tooltips);
32+
}
33+
},
34+
2635
methods: {
2736
onChange(value) {
2837
if (isArray(value)) {
@@ -38,9 +47,8 @@
3847
this.slider.noUiSlider.set(value);
3948
}
4049
},
41-
formatValueToModel() {
50+
formatValueToModel(val) {
4251
if(typeof this.slider.noUiSlider !== "undefined"){
43-
let val = this.slider.noUiSlider.get();
4452
if (val instanceof Array) {
4553
return [Number(val[0]), Number(val[1])];
4654
}else{

src/fields/fieldRadios.vue

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<template lang="jade">
2+
.radio-list(:disabled="disabled")
3+
label(v-for="item in items")
4+
input(type="radio", :disabled="disabled", :name="id", @click="onSelection(item)", :value="getItemValue(item)", :checked="isItemChecked(item)" )
5+
| {{ getItemName(item) }}
6+
7+
</template>
8+
9+
<script>
10+
import {isObject} from "lodash";
11+
import abstractField from "./abstractField";
12+
13+
export default {
14+
mixins: [ abstractField ],
15+
16+
computed: {
17+
items() {
18+
let values = this.schema.values;
19+
if (typeof(values) == "function") {
20+
return values.apply(this, [this.model, this.schema]);
21+
} else {
22+
return values;
23+
}
24+
},
25+
id(){
26+
return this.schema.model;
27+
}
28+
},
29+
30+
methods: {
31+
onSelection(item) {
32+
if (isObject(item) && this.schema.radiosOptions.value && item[this.schema.radiosOptions.value]){
33+
this.value = item[this.schema.radiosOptions.value];
34+
} else{
35+
this.value = item;
36+
}
37+
},
38+
getItemValue(item) {
39+
if (isObject(item) && this.schema.radiosOptions.value && item[this.schema.radiosOptions.value]){
40+
return item[this.schema.radiosOptions.value];
41+
}
42+
43+
return item;
44+
},
45+
getItemName(item) {
46+
if (isObject(item) && this.schema.radiosOptions.name && item[this.schema.radiosOptions.name]){
47+
return item[this.schema.radiosOptions.name];
48+
}
49+
50+
return item;
51+
},
52+
isItemChecked(item) {
53+
let currentValue;
54+
if (isObject(item) && this.schema.radiosOptions.value && item[this.schema.radiosOptions.value]){
55+
currentValue = item[this.schema.radiosOptions.value];
56+
} else{
57+
currentValue = item;
58+
}
59+
return (currentValue === this.value);
60+
},
61+
}
62+
};
63+
</script>
64+
65+
<style lang="sass">
66+
.vue-form-generator .field-radios {
67+
68+
.radio-list {
69+
label {
70+
display: block;
71+
input[type="radio"]{
72+
margin-right: 5px;
73+
}
74+
}
75+
}
76+
77+
}
78+
</style>

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ describe("fieldNoUiSlider.vue", function() {
5555
});
5656

5757
it("should contain the value", (done) => {
58-
vm.$nextTick( () => {
58+
setTimeout( () => {
5959
let origin = input.querySelector(".noUi-origin");
6060
expect(origin.style.left).to.be.within("70%", "90%");
6161
done();
62-
});
62+
}, 100);
6363
});
6464

6565
it("handle value should be the model value after changed", (done) => {
@@ -71,11 +71,10 @@ describe("fieldNoUiSlider.vue", function() {
7171
}, 100);
7272
});
7373

74-
it.skip("model value should be the handle value after changed", (done) => {
75-
// `field.slider.noUiSlider.set(3);` - It doesn't fired the onChange event
74+
it("model value should be the handle value after changed", (done) => {
7675
field.onChange(3);
7776
setTimeout( () => {
78-
expect(vm.model.rating).to.be.equal(3);
77+
expect(field.model.rating).to.be.equal(3);
7978
done();
8079
}, 100);
8180
});

0 commit comments

Comments
 (0)