Skip to content

Commit 592e390

Browse files
authored
Merge pull request #20 from JojuOlaode/componentSort
Component sort
2 parents 6c45903 + 912c247 commit 592e390

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

src/components/HomeSideDropDownItems/ComponentList.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
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="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/>
316
<a
417
v-for="componentData in activeRouteDisplay"
518
:key="componentData.componentName"
@@ -29,18 +42,31 @@
2942
* TODO: Needs functionality to delete component, and (maybe) show child components
3043
*/
3144
import { mapState, mapActions } from 'vuex'
45+
import Multiselect from 'vue-multiselect'
3246
3347
export default {
48+
data () {
49+
return {
50+
value: ''
51+
}
52+
},
53+
components: { Multiselect },
3454
computed: {
3555
...mapState(['routes', 'activeRoute', 'activeComponent']),
3656
activeRouteDisplay () {
3757
let component = this.routes[this.activeRoute]
58+
console.log(component)
3859
return component
3960
},
4061
activeComponentData () {
4162
return this.activeRouteDisplay.filter(componentData => {
4263
return componentData.componentName === this.activeComponent
4364
})[0]
65+
},
66+
options () {
67+
const val = this.activeRouteDisplay.map(component => component.componentName)
68+
console.log('options', val)
69+
return val
4470
}
4571
},
4672
methods: {
@@ -56,6 +82,11 @@ export default {
5682
handleClick (componentData) {
5783
this.setActiveComponent(componentData.componentName)
5884
this.deleteActiveComponent(componentData.componentName)
85+
},
86+
handleSelect (componentName) {
87+
this.setActiveComponent(componentName)
88+
this.value = ''
89+
this.activeComponentData.isActive = true
5990
}
6091
}
6192
}

src/components/ParentMultiselect.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
:close-on-select="true"
99
:options="options"
1010
@input="handleSelect"
11-
:max-height="150"
11+
:max-height="90"
1212
:option-height="20"
1313
:searchable="true"
14-
></multiselect>
14+
>
15+
<span slot='noResult'>No components found.</span>
16+
</multiselect>
1517
</div>
1618
</template>
1719

@@ -65,7 +67,7 @@ export default {
6567

6668
<style src="vue-multiselect/dist/vue-multiselect.min.css"></style>
6769
<style scoped>
68-
#parent-select{
70+
#parent-select {
6971
height: 30px;
7072
margin: 0.75rem;
7173
width: 90%;

0 commit comments

Comments
 (0)