|
| 1 | +<template> |
| 2 | + <div id="child-select" style="min-width: 500px; min-height: 500px;"> |
| 3 | + <br /> |
| 4 | + <multiselect |
| 5 | + placeholder="Select child components" |
| 6 | + :multiple="true" |
| 7 | + :close-on-select="false" |
| 8 | + :options="options" |
| 9 | + :value="componentChildrenMultiselectValue" |
| 10 | + @input="handleSelect" |
| 11 | + :max-height="150" |
| 12 | + :option-height="20" |
| 13 | + :searchable="false" |
| 14 | + ></multiselect> |
| 15 | + <!-- <q-select |
| 16 | + :options="options" |
| 17 | + label="Select children" |
| 18 | + multiple |
| 19 | + /> --> |
| 20 | + </div> |
| 21 | +</template> |
| 22 | + |
| 23 | +<script> |
| 24 | +import { mapState, mapActions } from 'vuex' |
| 25 | +import Multiselect from 'vue-multiselect' |
| 26 | +
|
| 27 | +export default { |
| 28 | + components: { |
| 29 | + Multiselect |
| 30 | + }, |
| 31 | + computed: { |
| 32 | + ...mapState([ |
| 33 | + 'routes', |
| 34 | + // comes from store/state/index.js |
| 35 | + 'componentMap', |
| 36 | + 'activeComponent', |
| 37 | + 'componentChildrenMultiselectValue', |
| 38 | + 'modalOpen' |
| 39 | + ]), |
| 40 | + options () { |
| 41 | + const routes = Object.keys(this.routes) |
| 42 | + const exceptions = new Set(['App', this.activeComponent, ...routes]) |
| 43 | + console.log('exceptions', exceptions) |
| 44 | + return Object.keys(this.componentMap).filter(component => { |
| 45 | + if (!exceptions.has(component)) return component |
| 46 | + }) |
| 47 | + } |
| 48 | + }, |
| 49 | + methods: { |
| 50 | + ...mapActions([ |
| 51 | + 'updateComponentChildrenMultiselectValue', |
| 52 | + 'updateActiveComponentChildrenValue' |
| 53 | + ]), |
| 54 | + // |
| 55 | + handleSelect (value) { |
| 56 | + // if (this.modalOpen) this.updateActiveComponentChildrenValue(value) |
| 57 | + console.log('Multiselect: ', value) |
| 58 | + this.updateActiveComponentChildrenValue(value) |
| 59 | + this.updateComponentChildrenMultiselectValue(value) |
| 60 | + } |
| 61 | + } |
| 62 | +} |
| 63 | +</script> |
| 64 | + |
| 65 | +<!-- New step! |
| 66 | + Add Multiselect CSS. Can be added as a static asset or inside a component. --> |
| 67 | +<style src="vue-multiselect/dist/vue-multiselect.min.css"></style> |
| 68 | +<style scoped> |
| 69 | +/* your styles */ |
| 70 | +</style> |
0 commit comments