diff options
author | jdlugosz963 <jdlugosz963@gmail.com> | 2021-12-14 06:22:57 +0100 |
---|---|---|
committer | jdlugosz963 <jdlugosz963@gmail.com> | 2021-12-14 06:22:57 +0100 |
commit | 193a6b59425ab45004f4178fc3f5b5bad5b4c660 (patch) | |
tree | 334bdb11345889967c45888bb11a129b03a67697 /src | |
parent | 98bec5686da0c4b7d0279b94968040b01e3218fa (diff) | |
download | lom_frontend-193a6b59425ab45004f4178fc3f5b5bad5b4c660.tar.gz lom_frontend-193a6b59425ab45004f4178fc3f5b5bad5b4c660.zip |
make group searcher works
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Searcher.vue | 19 | ||||
-rw-r--r-- | src/components/Sugestion.vue | 13 | ||||
-rw-r--r-- | src/services/CommandsService.js | 18 | ||||
-rw-r--r-- | src/views/Home.vue | 2 |
4 files changed, 35 insertions, 17 deletions
diff --git a/src/components/Searcher.vue b/src/components/Searcher.vue index a1093a2..df6dd9e 100644 --- a/src/components/Searcher.vue +++ b/src/components/Searcher.vue | |||
@@ -11,9 +11,9 @@ | |||
11 | 11 | ||
12 | <Sugestion | 12 | <Sugestion |
13 | v-for="sugestion in sugestions" | 13 | v-for="sugestion in sugestions" |
14 | :key="sugestion[0]" | 14 | :key="sugestion[0]" |
15 | :command="sugestion[1]" | 15 | :sugestion="sugestion" |
16 | :class="{selected: sugestion[0] === current[0]}" | 16 | :class="{selected: sugestion[0] === current[0]}" |
17 | /> | 17 | /> |
18 | </div> | 18 | </div> |
19 | </template> | 19 | </template> |
@@ -64,7 +64,6 @@ export default { | |||
64 | async execute_current() { | 64 | async execute_current() { |
65 | let out = await this.current[1](this) | 65 | let out = await this.current[1](this) |
66 | 66 | ||
67 | console.log(out) | ||
68 | if(out instanceof Object) { | 67 | if(out instanceof Object) { |
69 | this.search = '' | 68 | this.search = '' |
70 | this.commands = out | 69 | this.commands = out |
@@ -72,25 +71,29 @@ export default { | |||
72 | }, | 71 | }, |
73 | 72 | ||
74 | hotkeys(e) { | 73 | hotkeys(e) { |
75 | e.preventDefault() | ||
76 | |||
77 | switch(e.code) { | 74 | switch(e.code) { |
78 | case 'Escape': | 75 | case 'Escape': |
79 | this.close() | 76 | e.preventDefault() |
80 | break | 77 | this.close() |
78 | break | ||
81 | case 'ArrowDown': | 79 | case 'ArrowDown': |
80 | e.preventDefault() | ||
82 | this.change_current(1) | 81 | this.change_current(1) |
83 | break | 82 | break |
84 | case 'ArrowUp': | 83 | case 'ArrowUp': |
84 | e.preventDefault() | ||
85 | this.change_current(-1) | 85 | this.change_current(-1) |
86 | break | 86 | break |
87 | case 'Tab': | 87 | case 'Tab': |
88 | e.preventDefault() | ||
88 | this.change_current(1) | 89 | this.change_current(1) |
89 | break | 90 | break |
90 | case 'Enter': | 91 | case 'Enter': |
92 | e.preventDefault() | ||
91 | this.execute_current() | 93 | this.execute_current() |
92 | break | 94 | break |
93 | case 'ShiftLeft': | 95 | case 'ShiftLeft': |
96 | e.preventDefault() | ||
94 | this.commands = CommandsService | 97 | this.commands = CommandsService |
95 | break | 98 | break |
96 | } | 99 | } |
diff --git a/src/components/Sugestion.vue b/src/components/Sugestion.vue index cfbcd93..4721ca2 100644 --- a/src/components/Sugestion.vue +++ b/src/components/Sugestion.vue | |||
@@ -1,14 +1,19 @@ | |||
1 | <template> | 1 | <template> |
2 | <div class="sugestion"> | 2 | <div class="sugestion"> |
3 | <span>{{command.name}}</span> | 3 | <span>{{sugestion[0]}}</span> |
4 | </div> | 4 | </div> |
5 | </template> | 5 | </template> |
6 | 6 | ||
7 | <script> | 7 | <script> |
8 | export default { | 8 | export default { |
9 | props: { | 9 | props: { |
10 | command: Function | 10 | sugestion: Array |
11 | } | 11 | }, |
12 | |||
13 | created() { | ||
14 | this.$nextTick(function () { | ||
15 | }) | ||
16 | } | ||
12 | 17 | ||
13 | } | 18 | } |
14 | </script> | 19 | </script> |
@@ -24,4 +29,4 @@ export default { | |||
24 | padding: 5px; | 29 | padding: 5px; |
25 | padding-right: 0px; | 30 | padding-right: 0px; |
26 | } | 31 | } |
27 | </style> \ No newline at end of file | 32 | </style> |
diff --git a/src/services/CommandsService.js b/src/services/CommandsService.js index e21c8f7..cc5bdf2 100644 --- a/src/services/CommandsService.js +++ b/src/services/CommandsService.js | |||
@@ -4,9 +4,20 @@ import store from "@/store/index.js" | |||
4 | import router from '@/router/index.js' | 4 | import router from '@/router/index.js' |
5 | 5 | ||
6 | function set_groups(data) { | 6 | function set_groups(data) { |
7 | return {[data.name.replace(" ", "_")]() {console.log(data.name)}} | 7 | function group_command(group) { |
8 | console.log(group) | ||
9 | } | ||
10 | |||
11 | let groups = {} | ||
12 | |||
13 | data.forEach((group) => { | ||
14 | groups[group.name] = () => group_command(group) | ||
15 | }) | ||
16 | |||
17 | return groups | ||
8 | } | 18 | } |
9 | 19 | ||
20 | |||
10 | export default { | 21 | export default { |
11 | groups() { | 22 | groups() { |
12 | return { | 23 | return { |
@@ -14,9 +25,8 @@ export default { | |||
14 | const {data, status} = await ChatService.get_all_user_groups() | 25 | const {data, status} = await ChatService.get_all_user_groups() |
15 | if (status!==200) | 26 | if (status!==200) |
16 | return {} | 27 | return {} |
17 | const test1 = set_groups(data[0]) | 28 | const groups = set_groups(data) |
18 | const test2 = set_groups(data[0]) | 29 | return groups |
19 | return {test1, test2} | ||
20 | }, | 30 | }, |
21 | 31 | ||
22 | make(searcher) { | 32 | make(searcher) { |
diff --git a/src/views/Home.vue b/src/views/Home.vue index 5355520..abf6fc8 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue | |||
@@ -38,7 +38,7 @@ export default { | |||
38 | }, | 38 | }, |
39 | 39 | ||
40 | toogleSearcherShow() { this.popups.searcher_show = !this.popups.searcher_show }, | 40 | toogleSearcherShow() { this.popups.searcher_show = !this.popups.searcher_show }, |
41 | hideSearcher() { this.popups.searcher_show = true }, | 41 | hideSearcher() { this.popups.searcher_show = false }, |
42 | 42 | ||
43 | toogleGroupShow() { this.popups.group_maker_show = !this.popups.group_maker_show }, | 43 | toogleGroupShow() { this.popups.group_maker_show = !this.popups.group_maker_show }, |
44 | hideGroup() { this.popups.group_maker_show = false } | 44 | hideGroup() { this.popups.group_maker_show = false } |