From 193a6b59425ab45004f4178fc3f5b5bad5b4c660 Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Tue, 14 Dec 2021 06:22:57 +0100 Subject: make group searcher works --- src/components/Searcher.vue | 19 +++++++++++-------- src/components/Sugestion.vue | 13 +++++++++---- src/services/CommandsService.js | 18 ++++++++++++++---- 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 @@ @@ -64,7 +64,6 @@ export default { async execute_current() { let out = await this.current[1](this) - console.log(out) if(out instanceof Object) { this.search = '' this.commands = out @@ -72,25 +71,29 @@ export default { }, hotkeys(e) { - e.preventDefault() - switch(e.code) { case 'Escape': - this.close() - break + e.preventDefault() + this.close() + break case 'ArrowDown': + e.preventDefault() this.change_current(1) break case 'ArrowUp': + e.preventDefault() this.change_current(-1) break case 'Tab': + e.preventDefault() this.change_current(1) break case 'Enter': + e.preventDefault() this.execute_current() break case 'ShiftLeft': + e.preventDefault() this.commands = CommandsService break } 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 @@ @@ -24,4 +29,4 @@ export default { padding: 5px; padding-right: 0px; } - \ No newline at end of file + 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" import router from '@/router/index.js' function set_groups(data) { - return {[data.name.replace(" ", "_")]() {console.log(data.name)}} + function group_command(group) { + console.log(group) + } + + let groups = {} + + data.forEach((group) => { + groups[group.name] = () => group_command(group) + }) + + return groups } + export default { groups() { return { @@ -14,9 +25,8 @@ export default { const {data, status} = await ChatService.get_all_user_groups() if (status!==200) return {} - const test1 = set_groups(data[0]) - const test2 = set_groups(data[0]) - return {test1, test2} + const groups = set_groups(data) + return groups }, 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 { }, toogleSearcherShow() { this.popups.searcher_show = !this.popups.searcher_show }, - hideSearcher() { this.popups.searcher_show = true }, + hideSearcher() { this.popups.searcher_show = false }, toogleGroupShow() { this.popups.group_maker_show = !this.popups.group_maker_show }, hideGroup() { this.popups.group_maker_show = false } -- cgit v1.2.3