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 =" false"
9
+ :max-height =" 150"
10
+ :option-height =" 20"
11
+ @input =" onActivated(value)"
12
+ placeholder =" Select a component" ></multiselect >
13
+ <br />
3
14
<a
4
15
v-for =" componentData in activeRouteDisplay"
5
16
:key =" componentData.componentName"
29
40
* TODO: Needs functionality to delete component, and (maybe) show child components
30
41
*/
31
42
import { mapState , mapActions } from ' vuex'
43
+ import Multiselect from ' vue-multiselect'
32
44
33
45
export default {
46
+ data () {
47
+ return {
48
+ value: ' '
49
+ }
50
+ },
51
+ components: { Multiselect },
34
52
computed: {
35
53
... mapState ([' routes' , ' activeRoute' , ' activeComponent' ]),
36
54
activeRouteDisplay () {
37
55
let component = this .routes [this .activeRoute ]
56
+ console .log (component)
38
57
return component
39
58
},
40
59
activeComponentData () {
41
60
return this .activeRouteDisplay .filter (componentData => {
42
61
return componentData .componentName === this .activeComponent
43
62
})[0 ]
63
+ },
64
+ options () {
65
+ const val = this .activeRouteDisplay .map (component => component .componentName )
66
+ console .log (' options' , val)
67
+ return val
44
68
}
45
69
},
46
70
methods: {
@@ -50,7 +74,12 @@ export default {
50
74
' deleteActiveComponent'
51
75
]),
52
76
onActivated (componentData ) {
53
- this .setActiveComponent (componentData .componentName )
77
+ if (! componentData .componentName ) {
78
+ this .setActiveComponent (componentData)
79
+ this .value = ' '
80
+ } else {
81
+ this .setActiveComponent (componentData .componentName )
82
+ }
54
83
this .activeComponentData .isActive = true
55
84
},
56
85
handleClick (componentData ) {
0 commit comments