From ef98f6048679fbcae010ce2f2ee05270211f9ea3 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 6 Sep 2024 10:30:32 +0200 Subject: [PATCH] refactor: refs #7889 modified shortcut and dashboard, and added tootlip in LeftMenu --- src/boot/mainShortcutMixin.js | 8 ++--- src/components/LeftMenuItem.vue | 7 +++- src/pages/Dashboard/DashboardMain.vue | 12 ++----- src/router/modules/entry.js | 2 +- .../vnComponent/VnShortcut.spec.js | 33 +++++++++++++++++++ 5 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 test/cypress/integration/vnComponent/VnShortcut.spec.js diff --git a/src/boot/mainShortcutMixin.js b/src/boot/mainShortcutMixin.js index 3b5c604b79..8e5f147dbf 100644 --- a/src/boot/mainShortcutMixin.js +++ b/src/boot/mainShortcutMixin.js @@ -9,16 +9,16 @@ export default { const keyBindingMap = routes .filter((route) => route.meta.keyBinding) .reduce((map, route) => { - map[route.meta.keyBinding.toLowerCase()] = route.path; + map['Key' + route.meta.keyBinding.toUpperCase()] = route.path; return map; }, {}); const handleKeyDown = (event) => { - const { ctrlKey, altKey, key } = event; + const { ctrlKey, altKey, code } = event; - if (ctrlKey && altKey && keyBindingMap[key] && !isNotified) { + if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) { event.preventDefault(); - router.push(keyBindingMap[key]); + router.push(keyBindingMap[code]); isNotified = true; } }; diff --git a/src/components/LeftMenuItem.vue b/src/components/LeftMenuItem.vue index f3f2315a33..9fe66e2782 100644 --- a/src/components/LeftMenuItem.vue +++ b/src/components/LeftMenuItem.vue @@ -33,7 +33,12 @@ const itemComputed = computed(() => { - {{ t(itemComputed.title) }} + + {{ t(itemComputed.title) }} + + {{ 'Ctrl + Alt + ' + item.keyBinding.toUpperCase() }} + + diff --git a/src/pages/Dashboard/DashboardMain.vue b/src/pages/Dashboard/DashboardMain.vue index 22073c6d81..a339120e29 100644 --- a/src/pages/Dashboard/DashboardMain.vue +++ b/src/pages/Dashboard/DashboardMain.vue @@ -56,19 +56,11 @@ const pinnedModules = computed(() => navigation.getPinnedModules());
{{ t(item.title) }}
- {{ - '(' + - (item.keyBinding == '€' - ? 'E' - : item.keyBinding) + - ')' - }} + {{ '(' + item.keyBinding + ')' }} {{ 'Ctrl + Alt + ' + - (item.keyBinding == '€' - ? 'E' - : item.keyBinding.toUpperCase()) + item.keyBinding.toUpperCase() }}
diff --git a/src/router/modules/entry.js b/src/router/modules/entry.js index 3dd97a7a6e..365615b87e 100644 --- a/src/router/modules/entry.js +++ b/src/router/modules/entry.js @@ -7,7 +7,7 @@ export default { title: 'entries', icon: 'vn:entry', moduleName: 'Entry', - keyBinding: '€', + keyBinding: 'e', }, component: RouterView, redirect: { name: 'EntryMain' }, diff --git a/test/cypress/integration/vnComponent/VnShortcut.spec.js b/test/cypress/integration/vnComponent/VnShortcut.spec.js new file mode 100644 index 0000000000..3ab95340ec --- /dev/null +++ b/test/cypress/integration/vnComponent/VnShortcut.spec.js @@ -0,0 +1,33 @@ +/// +describe('VnShortcuts', () => { + const modules = { + item: 'a', + customer: 'c', + ticket: 't', + claim: 'r', + worker: 'w', + monitor: 'm', + order: 'p', + supplier: 'p', + entry: '€', + zone: 'z', + account: 'u', + }; + beforeEach(() => { + cy.login('developer'); + cy.visit('/'); + }); + + it('should visit each module', () => { + Object.keys(modules).forEach((module) => { + const shortcut = modules[module]; + + cy.get('body').type(`{ctrl}{alt}${shortcut}`); + + cy.url().should('include', module); + cy.get('body').should('be.visible'); + + cy.visit('/'); + }); + }); +});