Skip to content

Commit 7e3472d

Browse files
author
Lionel Bijaoui
committed
Remove dependency from vue-multiselect. Make it optional and check if loaded. Add it to dev files.
1 parent 24c49d9 commit 7e3472d

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

dev/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.js"></script>
2121
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.js"></script>
2222
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.1.4/js/ion.rangeSlider.js"></script>
23+
<script type="text/javascript" src="https://rawgit.com/monterail/vue-multiselect/master/lib/vue-multiselect.min.js"></script>
2324
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.min.js"></script>
2425
</head>
2526
<body>

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,5 @@
9696
"dependencies": {
9797
"babel-runtime": "6.9.2",
9898
"vue": "1.0.24",
99-
"vue-multiselect": "^1.0.1"
10099
}
101-
}
100+
}

src/fields/fieldVueMultiSelect.vue

+9-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,9 @@
3232
<script>
3333
// import { isObject } from "lodash";
3434
import abstractField from "./abstractField";
35-
import Multiselect from "vue-multiselect";
3635
3736
export default {
3837
mixins: [abstractField],
39-
components: {
40-
Multiselect
41-
},
4238
computed: {
4339
options() {
4440
let values = this.schema.values;
@@ -82,5 +78,14 @@ export default {
8278
console.log("onClose", value, id);
8379
}
8480
}
81+
created() {
82+
// Check if the component is loaded
83+
if (window.VueMultiselect) {
84+
Vue.component("multiselect", window.VueMultiselect.default);
85+
} else {
86+
console.error("'vue-multiselect' is missing. Please download from https://github.com/monterail/vue-multiselect and load the script in the HTML head section!");
87+
}
88+
}
8589
};
8690
</script>
91+

0 commit comments

Comments
 (0)