From 585919a4d957b9d6cc03e8f34b47ea682b7eaf32 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 6 Sep 2024 09:19:38 +0200 Subject: [PATCH 1/5] feat: refs #7889 added shortcuts to modules --- src/boot/mainShortcutMixin.js | 1 - src/pages/Dashboard/DashboardMain.vue | 6 ++++++ src/router/modules/Supplier.js | 2 ++ src/router/modules/account.js | 2 ++ src/router/modules/claim.js | 2 ++ src/router/modules/customer.js | 2 ++ src/router/modules/entry.js | 2 ++ src/router/modules/item.js | 2 ++ src/router/modules/monitor.js | 2 ++ src/router/modules/order.js | 2 ++ src/router/modules/route.js | 1 - src/router/modules/ticket.js | 2 ++ src/router/modules/worker.js | 2 ++ src/router/modules/zone.js | 2 ++ src/stores/useNavigationStore.js | 1 + 15 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/boot/mainShortcutMixin.js b/src/boot/mainShortcutMixin.js index 3b5c604b7..c684fc924 100644 --- a/src/boot/mainShortcutMixin.js +++ b/src/boot/mainShortcutMixin.js @@ -15,7 +15,6 @@ export default { const handleKeyDown = (event) => { const { ctrlKey, altKey, key } = event; - if (ctrlKey && altKey && keyBindingMap[key] && !isNotified) { event.preventDefault(); router.push(keyBindingMap[key]); diff --git a/src/pages/Dashboard/DashboardMain.vue b/src/pages/Dashboard/DashboardMain.vue index 6da39ce25..eaeddb682 100644 --- a/src/pages/Dashboard/DashboardMain.vue +++ b/src/pages/Dashboard/DashboardMain.vue @@ -55,6 +55,12 @@ const pinnedModules = computed(() => navigation.getPinnedModules()); >
{{ t(item.title) }} +
+ {{ '(' + item.subtitle + ')' }} + + {{ 'Ctrl + Alt + ' + item.subtitle }} + +
diff --git a/src/router/modules/Supplier.js b/src/router/modules/Supplier.js index b711066b2..e620e485c 100644 --- a/src/router/modules/Supplier.js +++ b/src/router/modules/Supplier.js @@ -5,8 +5,10 @@ export default { name: 'Supplier', meta: { title: 'suppliers', + subtitle: 'P', icon: 'vn:supplier', moduleName: 'Supplier', + keyBinding: 'p', }, component: RouterView, redirect: { name: 'SupplierMain' }, diff --git a/src/router/modules/account.js b/src/router/modules/account.js index cfec2b95d..dbf641c4a 100644 --- a/src/router/modules/account.js +++ b/src/router/modules/account.js @@ -5,8 +5,10 @@ export default { name: 'Account', meta: { title: 'users', + subtitle: 'U', icon: 'face', moduleName: 'Account', + keyBinding: 'u', }, component: RouterView, redirect: { name: 'AccountMain' }, diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js index cced9e24d..eb7a348fe 100644 --- a/src/router/modules/claim.js +++ b/src/router/modules/claim.js @@ -5,8 +5,10 @@ export default { path: '/claim', meta: { title: 'claims', + subtitle: 'R', icon: 'vn:claims', moduleName: 'Claim', + keyBinding: 'r', }, component: RouterView, redirect: { name: 'ClaimMain' }, diff --git a/src/router/modules/customer.js b/src/router/modules/customer.js index 684b83b0f..1e74b77bd 100644 --- a/src/router/modules/customer.js +++ b/src/router/modules/customer.js @@ -5,8 +5,10 @@ export default { name: 'Customer', meta: { title: 'customers', + subtitle: 'C', icon: 'vn:client', moduleName: 'Customer', + keyBinding: 'c', }, component: RouterView, redirect: { name: 'CustomerMain' }, diff --git a/src/router/modules/entry.js b/src/router/modules/entry.js index 0d38ed626..d3639e2f1 100644 --- a/src/router/modules/entry.js +++ b/src/router/modules/entry.js @@ -5,8 +5,10 @@ export default { name: 'Entry', meta: { title: 'entries', + subtitle: 'E', icon: 'vn:entry', moduleName: 'Entry', + keyBinding: '€', }, component: RouterView, redirect: { name: 'EntryMain' }, diff --git a/src/router/modules/item.js b/src/router/modules/item.js index 4bd5df4e2..80dcf4ae0 100644 --- a/src/router/modules/item.js +++ b/src/router/modules/item.js @@ -5,8 +5,10 @@ export default { name: 'Item', meta: { title: 'items', + subtitle: 'A', icon: 'vn:item', moduleName: 'Item', + keyBinding: 'a', }, component: RouterView, redirect: { name: 'ItemMain' }, diff --git a/src/router/modules/monitor.js b/src/router/modules/monitor.js index 3353da3cf..74a2826e2 100644 --- a/src/router/modules/monitor.js +++ b/src/router/modules/monitor.js @@ -5,8 +5,10 @@ export default { name: 'Monitor', meta: { title: 'monitors', + subtitle: 'M', icon: 'grid_view', moduleName: 'Monitor', + keyBinding: 'm', }, component: RouterView, redirect: { name: 'MonitorMain' }, diff --git a/src/router/modules/order.js b/src/router/modules/order.js index 9ccdb820b..861eb7938 100644 --- a/src/router/modules/order.js +++ b/src/router/modules/order.js @@ -5,8 +5,10 @@ export default { name: 'Order', meta: { title: 'order', + subtitle: 'O', icon: 'vn:basket', moduleName: 'Order', + keyBinding: 'o', }, component: RouterView, redirect: { name: 'OrderMain' }, diff --git a/src/router/modules/route.js b/src/router/modules/route.js index 955fc9098..3c5c860cf 100644 --- a/src/router/modules/route.js +++ b/src/router/modules/route.js @@ -7,7 +7,6 @@ export default { title: 'routes', icon: 'vn:delivery', moduleName: 'Route', - keyBinding: 'r', }, component: RouterView, redirect: { name: 'RouteMain' }, diff --git a/src/router/modules/ticket.js b/src/router/modules/ticket.js index 4074f089f..9c9b2cbf3 100644 --- a/src/router/modules/ticket.js +++ b/src/router/modules/ticket.js @@ -5,8 +5,10 @@ export default { path: '/ticket', meta: { title: 'tickets', + subtitle: 'T', icon: 'vn:ticket', moduleName: 'Ticket', + keyBinding: 't', }, component: RouterView, redirect: { name: 'TicketMain' }, diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js index 2a523e7fe..4395319bf 100644 --- a/src/router/modules/worker.js +++ b/src/router/modules/worker.js @@ -5,8 +5,10 @@ export default { name: 'Worker', meta: { title: 'workers', + subtitle: 'W', icon: 'vn:worker', moduleName: 'Worker', + keyBinding: 'w', }, component: RouterView, redirect: { name: 'WorkerMain' }, diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js index 40358c58e..c82616286 100644 --- a/src/router/modules/zone.js +++ b/src/router/modules/zone.js @@ -5,8 +5,10 @@ export default { name: 'Zone', meta: { title: 'zones', + subtitle: 'Z', icon: 'vn:zone', moduleName: 'Zone', + keyBinding: 'z', }, component: RouterView, redirect: { name: 'ZoneMain' }, diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js index 961e80377..67b632b00 100644 --- a/src/stores/useNavigationStore.js +++ b/src/stores/useNavigationStore.js @@ -72,6 +72,7 @@ export const useNavigationStore = defineStore('navigationStore', () => { if (meta) { item.title = `globals.pageTitles.${meta.title}`; item.icon = meta.icon; + item.subtitle = meta.subtitle; } parent.push(item); -- 2.40.1 From 5d78f564ddc3f4a64e2627c6108e32fc388005e2 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 6 Sep 2024 10:00:07 +0200 Subject: [PATCH 2/5] refactor: refs #7889 deleted subtitle attr and use keyBinding instead --- src/boot/mainShortcutMixin.js | 1 + src/pages/Dashboard/DashboardMain.vue | 17 ++++++++++++++--- src/router/modules/Supplier.js | 1 - src/router/modules/account.js | 1 - src/router/modules/claim.js | 1 - src/router/modules/customer.js | 1 - src/router/modules/entry.js | 1 - src/router/modules/item.js | 1 - src/router/modules/monitor.js | 1 - src/router/modules/order.js | 1 - src/router/modules/ticket.js | 1 - src/router/modules/worker.js | 1 - src/router/modules/zone.js | 1 - src/stores/useNavigationStore.js | 2 +- 14 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/boot/mainShortcutMixin.js b/src/boot/mainShortcutMixin.js index c684fc924..3b5c604b7 100644 --- a/src/boot/mainShortcutMixin.js +++ b/src/boot/mainShortcutMixin.js @@ -15,6 +15,7 @@ export default { const handleKeyDown = (event) => { const { ctrlKey, altKey, key } = event; + if (ctrlKey && altKey && keyBindingMap[key] && !isNotified) { event.preventDefault(); router.push(keyBindingMap[key]); diff --git a/src/pages/Dashboard/DashboardMain.vue b/src/pages/Dashboard/DashboardMain.vue index eaeddb682..22073c6d8 100644 --- a/src/pages/Dashboard/DashboardMain.vue +++ b/src/pages/Dashboard/DashboardMain.vue @@ -55,10 +55,21 @@ const pinnedModules = computed(() => navigation.getPinnedModules()); >
{{ t(item.title) }} -
- {{ '(' + item.subtitle + ')' }} +
+ {{ + '(' + + (item.keyBinding == '€' + ? 'E' + : item.keyBinding) + + ')' + }} - {{ 'Ctrl + Alt + ' + item.subtitle }} + {{ + 'Ctrl + Alt + ' + + (item.keyBinding == '€' + ? 'E' + : item.keyBinding.toUpperCase()) + }}
diff --git a/src/router/modules/Supplier.js b/src/router/modules/Supplier.js index e620e485c..143d7c824 100644 --- a/src/router/modules/Supplier.js +++ b/src/router/modules/Supplier.js @@ -5,7 +5,6 @@ export default { name: 'Supplier', meta: { title: 'suppliers', - subtitle: 'P', icon: 'vn:supplier', moduleName: 'Supplier', keyBinding: 'p', diff --git a/src/router/modules/account.js b/src/router/modules/account.js index dbf641c4a..34f804b18 100644 --- a/src/router/modules/account.js +++ b/src/router/modules/account.js @@ -5,7 +5,6 @@ export default { name: 'Account', meta: { title: 'users', - subtitle: 'U', icon: 'face', moduleName: 'Account', keyBinding: 'u', diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js index eb7a348fe..d597267b2 100644 --- a/src/router/modules/claim.js +++ b/src/router/modules/claim.js @@ -5,7 +5,6 @@ export default { path: '/claim', meta: { title: 'claims', - subtitle: 'R', icon: 'vn:claims', moduleName: 'Claim', keyBinding: 'r', diff --git a/src/router/modules/customer.js b/src/router/modules/customer.js index 1e74b77bd..5b73ddc84 100644 --- a/src/router/modules/customer.js +++ b/src/router/modules/customer.js @@ -5,7 +5,6 @@ export default { name: 'Customer', meta: { title: 'customers', - subtitle: 'C', icon: 'vn:client', moduleName: 'Customer', keyBinding: 'c', diff --git a/src/router/modules/entry.js b/src/router/modules/entry.js index d3639e2f1..3dd97a7a6 100644 --- a/src/router/modules/entry.js +++ b/src/router/modules/entry.js @@ -5,7 +5,6 @@ export default { name: 'Entry', meta: { title: 'entries', - subtitle: 'E', icon: 'vn:entry', moduleName: 'Entry', keyBinding: '€', diff --git a/src/router/modules/item.js b/src/router/modules/item.js index 80dcf4ae0..48e19dd54 100644 --- a/src/router/modules/item.js +++ b/src/router/modules/item.js @@ -5,7 +5,6 @@ export default { name: 'Item', meta: { title: 'items', - subtitle: 'A', icon: 'vn:item', moduleName: 'Item', keyBinding: 'a', diff --git a/src/router/modules/monitor.js b/src/router/modules/monitor.js index 74a2826e2..7342a5904 100644 --- a/src/router/modules/monitor.js +++ b/src/router/modules/monitor.js @@ -5,7 +5,6 @@ export default { name: 'Monitor', meta: { title: 'monitors', - subtitle: 'M', icon: 'grid_view', moduleName: 'Monitor', keyBinding: 'm', diff --git a/src/router/modules/order.js b/src/router/modules/order.js index 861eb7938..bfa37fce5 100644 --- a/src/router/modules/order.js +++ b/src/router/modules/order.js @@ -5,7 +5,6 @@ export default { name: 'Order', meta: { title: 'order', - subtitle: 'O', icon: 'vn:basket', moduleName: 'Order', keyBinding: 'o', diff --git a/src/router/modules/ticket.js b/src/router/modules/ticket.js index 9c9b2cbf3..0f6fc9b22 100644 --- a/src/router/modules/ticket.js +++ b/src/router/modules/ticket.js @@ -5,7 +5,6 @@ export default { path: '/ticket', meta: { title: 'tickets', - subtitle: 'T', icon: 'vn:ticket', moduleName: 'Ticket', keyBinding: 't', diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js index 4395319bf..b2716474b 100644 --- a/src/router/modules/worker.js +++ b/src/router/modules/worker.js @@ -5,7 +5,6 @@ export default { name: 'Worker', meta: { title: 'workers', - subtitle: 'W', icon: 'vn:worker', moduleName: 'Worker', keyBinding: 'w', diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js index c82616286..1f27cc76f 100644 --- a/src/router/modules/zone.js +++ b/src/router/modules/zone.js @@ -5,7 +5,6 @@ export default { name: 'Zone', meta: { title: 'zones', - subtitle: 'Z', icon: 'vn:zone', moduleName: 'Zone', keyBinding: 'z', diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js index 67b632b00..4589426f8 100644 --- a/src/stores/useNavigationStore.js +++ b/src/stores/useNavigationStore.js @@ -72,7 +72,7 @@ export const useNavigationStore = defineStore('navigationStore', () => { if (meta) { item.title = `globals.pageTitles.${meta.title}`; item.icon = meta.icon; - item.subtitle = meta.subtitle; + item.keyBinding = meta.keyBinding; } parent.push(item); -- 2.40.1 From ef98f6048679fbcae010ce2f2ee05270211f9ea3 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 6 Sep 2024 10:30:32 +0200 Subject: [PATCH 3/5] 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 3b5c604b7..8e5f147db 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 f3f2315a3..9fe66e278 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 22073c6d8..a339120e2 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 3dd97a7a6..365615b87 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 000000000..3ab95340e --- /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('/'); + }); + }); +}); -- 2.40.1 From ba7497f055f9248b8bbf24032b6965abd3c4e8b0 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 9 Sep 2024 08:47:44 +0200 Subject: [PATCH 4/5] fix: refs #7889 fixed shortcut test --- .../integration/vnComponent/VnShortcut.spec.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/cypress/integration/vnComponent/VnShortcut.spec.js b/test/cypress/integration/vnComponent/VnShortcut.spec.js index 3ab95340e..59dd397c3 100644 --- a/test/cypress/integration/vnComponent/VnShortcut.spec.js +++ b/test/cypress/integration/vnComponent/VnShortcut.spec.js @@ -9,23 +9,23 @@ describe('VnShortcuts', () => { monitor: 'm', order: 'p', supplier: 'p', - entry: '€', + entry: 'e', zone: 'z', account: 'u', }; - beforeEach(() => { - cy.login('developer'); - cy.visit('/'); - }); it('should visit each module', () => { + cy.login('developer'); + cy.visit('/'); Object.keys(modules).forEach((module) => { const shortcut = modules[module]; - cy.get('body').type(`{ctrl}{alt}${shortcut}`); + cy.get('body').click(); + cy.get('body').type(`{ctrl+alt+${shortcut}}`); - cy.url().should('include', module); - cy.get('body').should('be.visible'); + if (shortcut != 'u' && shortcut != 'o') { + cy.get('.q-table__middle').should('be.visible'); + } cy.visit('/'); }); -- 2.40.1 From 2bd80b2ee7abf9cc4a3973a20dde1226ad021574 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 9 Sep 2024 09:45:30 +0200 Subject: [PATCH 5/5] perf: refs #7889 perf shortcut test --- .../vnComponent/VnShortcut.spec.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/cypress/integration/vnComponent/VnShortcut.spec.js b/test/cypress/integration/vnComponent/VnShortcut.spec.js index 59dd397c3..b49b4e964 100644 --- a/test/cypress/integration/vnComponent/VnShortcut.spec.js +++ b/test/cypress/integration/vnComponent/VnShortcut.spec.js @@ -1,4 +1,5 @@ /// + describe('VnShortcuts', () => { const modules = { item: 'a', @@ -7,27 +8,26 @@ describe('VnShortcuts', () => { claim: 'r', worker: 'w', monitor: 'm', - order: 'p', + order: 'o', supplier: 'p', entry: 'e', zone: 'z', account: 'u', }; - - it('should visit each module', () => { + beforeEach(() => { cy.login('developer'); cy.visit('/'); - Object.keys(modules).forEach((module) => { - const shortcut = modules[module]; - - cy.get('body').click(); - cy.get('body').type(`{ctrl+alt+${shortcut}}`); - - if (shortcut != 'u' && shortcut != 'o') { - cy.get('.q-table__middle').should('be.visible'); - } - - cy.visit('/'); - }); }); + + for (const [module, shortcut] of Object.entries(modules)) { + it(`should visit ${module} module`, () => { + cy.get('body').trigger('keydown', { + ctrlKey: true, + altKey: true, + code: `Key${shortcut.toUpperCase()}`, + }); + + cy.url().should('include', module); + }); + } }); -- 2.40.1