1
1
<template >
2
2
<div class =" home-sidebar" >
3
+ <multiselect
4
+ class =' multiselect'
5
+ v-model =" value"
6
+ :options =' options'
7
+ :searchable =" true"
8
+ :close-on-select =" true"
9
+ :max-height =" 90"
10
+ :option-height =" 20"
11
+ @input =" handleSelect(value)"
12
+ placeholder =" Select a component" >
13
+ <span slot =' noResult' >No components found.</span >
14
+ </multiselect >
15
+ <br />
3
16
<a
4
17
v-for =" componentData in activeRouteDisplay"
5
18
:key =" componentData.componentName"
29
42
* TODO: Needs functionality to delete component, and (maybe) show child components
30
43
*/
31
44
import { mapState , mapActions } from ' vuex'
45
+ import Multiselect from ' vue-multiselect'
32
46
33
47
export default {
48
+ data () {
49
+ return {
50
+ value: ' '
51
+ }
52
+ },
53
+ components: { Multiselect },
34
54
computed: {
35
55
... mapState ([' routes' , ' activeRoute' , ' activeComponent' ]),
36
56
activeRouteDisplay () {
37
57
let component = this .routes [this .activeRoute ]
58
+ console .log (component)
38
59
return component
39
60
},
40
61
activeComponentData () {
41
62
return this .activeRouteDisplay .filter (componentData => {
42
63
return componentData .componentName === this .activeComponent
43
64
})[0 ]
65
+ },
66
+ options () {
67
+ const val = this .activeRouteDisplay .map (component => component .componentName )
68
+ console .log (' options' , val)
69
+ return val
44
70
}
45
71
},
46
72
methods: {
@@ -56,6 +82,11 @@ export default {
56
82
handleClick (componentData ) {
57
83
this .setActiveComponent (componentData .componentName )
58
84
this .deleteActiveComponent (componentData .componentName )
85
+ },
86
+ handleSelect (componentName ) {
87
+ this .setActiveComponent (componentName)
88
+ this .value = ' '
89
+ this .activeComponentData .isActive = true
59
90
}
60
91
}
61
92
}
0 commit comments