Skip to content

Commit

Permalink
add every component to the body
Browse files Browse the repository at this point in the history
If not, the ready() was not called.
  • Loading branch information
icebob committed Aug 25, 2016
1 parent 2be0307 commit 8e528b4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/fields/fieldCleave.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export default {
} else {
console.warn("Cleave is missing. Please download from https://github.com/nosir/cleave.js/ and load the script in the HTML head section!");
}
},
beforeDestroy() {
if (this.cleave)
this.cleave.destroy();
}
};
</script>
Expand Down
6 changes: 4 additions & 2 deletions src/fields/fieldDateTime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* global $ */
import abstractField from "./abstractField";
import moment from "moment";
import { defaults } from "lodash";
let inputFormat = "YYYY-MM-DD HH:mm:ss";
Expand Down Expand Up @@ -46,11 +47,12 @@
},
ready() {
if ($.fn.datetimepicker)
if ($.fn.datetimepicker) {
$(this.$el).datetimepicker(this.schema.dateTimePickerOptions);
//$(this.$el).data("DateTimePicker").date(this.formatValueToField(this.value));
}
else
console.warn("Bootstrap datetimepicker library is missing. Please download from https://eonasdan.github.io/bootstrap-datetimepicker/ and load the script and CSS in the HTML head section!");
}
};
</script>
Expand Down
5 changes: 3 additions & 2 deletions src/fields/fieldSpectrum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
ready() {
if ($.fn.spectrum)
if ($.fn.spectrum) {
$(this.$el).spectrum("destroy").spectrum(defaults(this.schema.colorOptions || {}, {
showInput: true,
showAlpha: true,
Expand All @@ -29,8 +29,9 @@
this.value = color ? color.toString() : null;
}
}));
else
} else {
console.warn("Spectrum color library is missing. Please download from http://bgrins.github.io/spectrum/ and load the script and CSS in the HTML head section!");
}
}
};
Expand Down
9 changes: 7 additions & 2 deletions test/unit/specs/fields/fieldDateTime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function createField(schema = {}, model = null, disabled = false, options) {
[ el, vm, field ] = createVueField("fieldDateTime", schema, model, disabled, options);
}

describe("fieldDateTime.vue", () => {
describe.only("fieldDateTime.vue", () => {

describe("check template", () => {
let schema = {
Expand Down Expand Up @@ -50,7 +50,12 @@ describe("fieldDateTime.vue", () => {
field.disabled = true;
vm.$nextTick( () => {
expect(input.disabled).to.be.true;
done();

// Rollback
field.disabled = false;
vm.$nextTick( () => {
done();
});
});
});

Expand Down
1 change: 0 additions & 1 deletion test/unit/specs/fields/fieldMasked.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe("fieldMasked.vue", () => {

before( () => {
createField(schema, model, false);
vm.$appendTo(document.body);
input = el.getElementsByTagName("input")[0];
});

Expand Down
1 change: 0 additions & 1 deletion test/unit/specs/fields/fieldNoUiSlider.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe("fieldNoUiSlider.vue", () => {

before( () => {
createField(schema, model, false);
vm.$appendTo(document.body);
input = el.getElementsByClassName("slider")[0];
});

Expand Down
1 change: 0 additions & 1 deletion test/unit/specs/fields/fieldVueMultiSelect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe("fieldVueMultiSelect.vue", () => {

before( () => {
createField(schema, model, false);
vm.$appendTo(document.body);
input = el.querySelector(".multiselect");
});

Expand Down
3 changes: 2 additions & 1 deletion test/unit/specs/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function trigger (el, event, args) {
export function createVueField(type, schema = {}, model = null, disabled = false, options) {
let elName = Vue.util.hyphenate(type);
let el = document.createElement("div");
document.body.appendChild(el);
el.innerHTML = `<${elName} :schema.sync="schema" :model.sync="model" :disabled="disabled" v-ref:field></${elName}>`;
let vm = new Vue({
el: el,
Expand All @@ -31,6 +32,6 @@ export function createVueField(type, schema = {}, model = null, disabled = false
}
});
let field = vm.$refs.field;

return [ el, vm, field ];
}

0 comments on commit 8e528b4

Please sign in to comment.