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)
1
+ <!--
2
+ LOCATION IN APP:
3
+ [left sidebar] COMPONENT > Update Component > Actions
4
+
5
+ FUNCTIONALITY:
6
+ - Displays dropdown selection of actions added to store
7
+ - Allows user to select actions and map them to current active component
7
8
-->
8
9
9
10
<template>
12
13
<VueMultiselect
13
14
v-model="selectAction"
14
15
class="multiselect"
15
- placeholder="Select Action for Component "
16
+ placeholder="Select action for component "
16
17
:multiple="true"
17
18
:close-on-select="false"
18
19
:max-height="180"
23
24
@search-change="stopDelete($event)"
24
25
>
25
26
</VueMultiselect>
26
- <br />
27
27
<q-btn
28
28
v-if="selectAction.length"
29
29
id="add-actions-btn"
33
33
@click="addActionToComp"
34
34
/>
35
35
</div>
36
- <p v-if="!(componentMap[activeComponent] as Component).actions.length">
37
- No actions in component
38
- </p>
39
36
<a
40
- v-else
41
37
v-for="action in (componentMap[activeComponent] as Component).actions"
42
38
:key="action"
43
39
>
59
55
</q-item>
60
56
</q-list>
61
57
</a>
62
- <br />
63
58
</div>
64
59
</template>
65
60
66
61
<script setup lang="ts">
67
- // new script for Composition API
68
-
62
+ /* IMPORTS */
69
63
import { computed } from "vue";
64
+ import VueMultiselect from "vue-multiselect";
70
65
import { useStore } from "../../../store/main.js";
71
66
import { Component } from "../../../../types";
72
- import VueMultiselect from "vue-multiselect";
73
67
68
+ /* COMPUTED VALUES */
74
69
const store = useStore();
75
-
76
- const selectedActions = computed(() => store.selectedActions);
77
- const userActions = computed(() => store.userActions);
78
70
const componentMap = computed(() => store.componentMap);
79
71
const activeComponent = computed(() => store.activeComponent);
80
-
81
- //getters
82
-
83
- const actionOptions = userActions;
84
- // actionOptions() {
85
- // return this.userActions;
86
- // },
87
-
72
+ const selectedActions = computed(() => store.selectedActions);
73
+ const userActions = computed(() => store.userActions);
88
74
const selectAction = computed({
89
75
get() {
90
76
return [...selectedActions.value];
@@ -94,8 +80,7 @@ const selectAction = computed({
94
80
},
95
81
});
96
82
97
- // Methods
98
-
83
+ /* STORE ACTIONS */
99
84
const addActionSelected: typeof store.addActionSelected = (payload) =>
100
85
store.addActionSelected(payload);
101
86
const addActionToComponent: typeof store.addActionToComponent = (payload) =>
@@ -104,64 +89,20 @@ const deleteActionFromComponent: typeof store.deleteActionFromComponent = (
104
89
payload
105
90
) => store.deleteActionFromComponent(payload);
106
91
92
+ /* COMPONENT METHODS */
107
93
const stopDelete = (e: KeyboardEvent) => {
108
94
if (e.code === "Backspace") e.stopPropagation();
109
95
};
96
+
110
97
const addActionToComp = () => {
111
98
addActionToComponent([...selectedActions.value]);
112
99
};
100
+
113
101
const deleteAction = (action: string) => {
114
102
deleteActionFromComponent(action);
115
103
};
116
104
</script>
117
105
118
- <!-- <script>
119
- import { mapState, mapActions } from "vuex";
120
- import VueMultiselect from "vue-multiselect";
121
-
122
- export default {
123
- name: "ActionsSubMenu",
124
- components: {
125
- VueMultiselect,
126
- },
127
- computed: {
128
- ...mapState(["selectedActions", "userActions", "componentMap", "activeComponent",]),
129
- actionOptions() {
130
- return this.userActions;
131
- },
132
- selectAction: {
133
- get() {
134
- console.log("Inside get!", this.selectedActions);
135
- return this.selectedActions;
136
- },
137
- set(value) {
138
- console.log("What is value?", value)
139
- this.addActionSelected(value);
140
- },
141
- },
142
- },
143
- methods: {
144
- ...mapActions([
145
- "addActionSelected",
146
- "addActionToComponent",
147
- "deleteActionFromComponent",
148
- ]),
149
- // Prevent Delete on changes to searchable multiselect
150
- stopDelete(e) {
151
- if (e.code === "Backspace") e.stopPropogation();
152
- },
153
- // adds an action to the currently selected component
154
- addActionToComp() {
155
- this.addActionToComponent(this.selectedActions);
156
- },
157
- // delete selected action from active component
158
- deleteAction(action) {
159
- this.deleteActionFromComponent(action);
160
- },
161
- },
162
- };
163
- </script> -->
164
-
165
106
<style lang="scss" scoped>
166
107
.selection-container {
167
108
padding: 30px 0;
0 commit comments