Skip to content

Commit cef52cb

Browse files
author
Lionel Bijaoui
committed
🆕 new: new field type: Vue Multiselect
1 parent 236e9d0 commit cef52cb

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

dev/schema.js

+29
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,35 @@ module.exports = {
7777
hint: "Minimum 6 characters",
7878
styleClasses: "half-width",
7979
validator: validators.string
80+
},
81+
82+
{
83+
type: "vueMultiSelect",
84+
label: "Skills (vue-multiSelect field)",
85+
model: "skills",
86+
multi: true,
87+
required: true,
88+
multiSelect: true,
89+
selectOptions: {
90+
// https://silviomoreto.github.io/bootstrap-select/options/
91+
liveSearch: true,
92+
//maxOptions: 3,
93+
//size: 4,
94+
//actionsBox: true,
95+
selectedTextFormat: "count > 3"
96+
},
97+
values: [
98+
"HTML5",
99+
"Javascript",
100+
"CSS3",
101+
"CoffeeScript",
102+
"AngularJS",
103+
"ReactJS",
104+
"VueJS"
105+
],
106+
min: 2,
107+
max: 4,
108+
validator: validators.array
80109
},
81110

82111
{

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
},
9696
"dependencies": {
9797
"babel-runtime": "6.9.2",
98-
"vue": "1.0.24"
98+
"vue": "1.0.24",
99+
"vue-multiselect": "^1.0.1"
99100
}
100101
}

src/fields/fieldVueMultiSelect.vue

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template lang="jade">
2+
multiselect( :selected="selected", :options="options", @update="updateSelected" )
3+
</template>
4+
<script>
5+
import { isObject } from "lodash";
6+
import abstractField from "./abstractField";
7+
import Multiselect from 'vue-multiselect';
8+
9+
export default {
10+
mixins: [abstractField],
11+
components: { Multiselect },
12+
computed: {
13+
options() {
14+
let values = this.schema.values;
15+
if (typeof(values) == "function") {
16+
return values.apply(this, [this.model, this.schema]);
17+
} else
18+
return values;
19+
}
20+
},
21+
22+
methods: {
23+
updateSelected (newSelected) {
24+
console.log(newSelected, this.selected)
25+
this.selected = newSelected
26+
}
27+
}
28+
};
29+
</script>

0 commit comments

Comments
 (0)