Skip to content

Commit 1f51fd6

Browse files
committed
added a multiselect tag to allow for searching components in component list and sets selected component to active component
1 parent 4e4e400 commit 1f51fd6

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/components/HomeSideDropDownItems/ComponentList.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<template>
22
<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/>
314
<a
415
v-for="componentData in activeRouteDisplay"
516
:key="componentData.componentName"
@@ -29,18 +40,31 @@
2940
* TODO: Needs functionality to delete component, and (maybe) show child components
3041
*/
3142
import { mapState, mapActions } from 'vuex'
43+
import Multiselect from 'vue-multiselect'
3244
3345
export default {
46+
data () {
47+
return {
48+
value: ''
49+
}
50+
},
51+
components: { Multiselect },
3452
computed: {
3553
...mapState(['routes', 'activeRoute', 'activeComponent']),
3654
activeRouteDisplay () {
3755
let component = this.routes[this.activeRoute]
56+
console.log(component)
3857
return component
3958
},
4059
activeComponentData () {
4160
return this.activeRouteDisplay.filter(componentData => {
4261
return componentData.componentName === this.activeComponent
4362
})[0]
63+
},
64+
options () {
65+
const val = this.activeRouteDisplay.map(component => component.componentName)
66+
console.log('options', val)
67+
return val
4468
}
4569
},
4670
methods: {
@@ -50,7 +74,12 @@ export default {
5074
'deleteActiveComponent'
5175
]),
5276
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+
}
5483
this.activeComponentData.isActive = true
5584
},
5685
handleClick (componentData) {

0 commit comments

Comments
 (0)