|
| 1 | +<!-- this will display the active/selected component's state. Functionality will include being able to add more state and delete state --> |
| 2 | +<!-- Functions: |
| 3 | +- display all the component's state as a list |
| 4 | + - maybe with a delete button similar to props right now |
| 5 | +- dropdown to add more state to component (multiselect) |
| 6 | +- submit button (like props) |
| 7 | +--> |
| 8 | + |
| 9 | +<template> |
| 10 | + <div> |
| 11 | + <div id="action-select"> |
| 12 | + <multiselect |
| 13 | + v-model="selectAction" |
| 14 | + class="multiselect" |
| 15 | + placeholder="Select Action for Component" |
| 16 | + :multiple="true" |
| 17 | + :close-on-select="false" |
| 18 | + :max-height="180" |
| 19 | + :option-height="20" |
| 20 | + open-direction="top" |
| 21 | + :options="actionOptions" |
| 22 | + :searchable="false" |
| 23 | + @search-change="stopDelete($event)" |
| 24 | + > |
| 25 | + <span slot="noResult">No actions found.</span> |
| 26 | + </multiselect> |
| 27 | + <br/> |
| 28 | + <q-btn |
| 29 | + v-if="selectAction.length" |
| 30 | + id="add-actions-btn" |
| 31 | + class="add-btn" |
| 32 | + color="secondary" |
| 33 | + label="Map Action(s)" |
| 34 | + @click="addActionToComp" |
| 35 | + /> |
| 36 | + </div> |
| 37 | + <p v-if="!this.activeComponentObj.actions.length"> |
| 38 | + No actions in component |
| 39 | + </p> |
| 40 | + <a |
| 41 | + v-else |
| 42 | + v-for="action in this.activeComponentData.actions" |
| 43 | + :key="action" |
| 44 | + > |
| 45 | + <q-list class="list-item" dense bordered separator> |
| 46 | + <q-item clickable v-ripple class="list-item"> |
| 47 | + <q-item-section> |
| 48 | + <div class="component-container"> |
| 49 | + <div class="component-info"> |
| 50 | + {{action}} |
| 51 | + </div> |
| 52 | + <q-btn round flat icon="highlight_off" v-on:click.stop="deleteAction(action)" /> |
| 53 | + </div> |
| 54 | + </q-item-section> |
| 55 | + </q-item> |
| 56 | + </q-list> |
| 57 | + </a> |
| 58 | + <br/> |
| 59 | + </div> |
| 60 | +</template> |
| 61 | + |
| 62 | +<script> |
| 63 | +import { mapState, mapActions } from "vuex"; |
| 64 | +import Multiselect from 'vue-multiselect'; |
| 65 | +
|
| 66 | +export default { |
| 67 | + name: "ComponentActions", |
| 68 | + components: { |
| 69 | + Multiselect |
| 70 | + }, |
| 71 | + computed: { |
| 72 | + ...mapState([ |
| 73 | + "activeComponentObj", |
| 74 | + "selectedActions", |
| 75 | + "userActions", |
| 76 | + ]), |
| 77 | + activeComponentData () { |
| 78 | + return this.activeComponentObj |
| 79 | + }, |
| 80 | + compObj: { |
| 81 | + get() { |
| 82 | + return this.activeComponentObj; |
| 83 | + } |
| 84 | + }, |
| 85 | + actionOptions () { |
| 86 | + return this.userActions |
| 87 | + }, |
| 88 | + selectAction: { |
| 89 | + get () { |
| 90 | + return this.selectedActions |
| 91 | + }, |
| 92 | + set (value) { |
| 93 | + this.addActionSelected(value) |
| 94 | + } |
| 95 | + } |
| 96 | + }, |
| 97 | + methods: { |
| 98 | + ...mapActions([ |
| 99 | + 'addActionSelected', |
| 100 | + 'addActionToComponent', |
| 101 | + 'deleteActionFromComponent', |
| 102 | + ]), |
| 103 | + // Prevent Delete on changes to searchable multiselect |
| 104 | + stopDelete (e) { |
| 105 | + if (e.code === 'Backspce') e.stopPropogation(); |
| 106 | + // console.log(e); |
| 107 | + }, |
| 108 | + // adds an action to the currently selected component |
| 109 | + addActionToComp () { |
| 110 | + this.addActionToComponent(this.selectedActions); |
| 111 | + }, |
| 112 | + // delete selected action from active component |
| 113 | + deleteAction (action) { |
| 114 | + this.deleteActionFromComponent(action); |
| 115 | + // console.log(this.activeComponentObj); |
| 116 | + }, |
| 117 | +
|
| 118 | + } |
| 119 | +} |
| 120 | +</script> |
0 commit comments