0
0
Fork 0

Merge pull request 'feat: refs #7889 added shortcuts to modules' (!682) from 7889-KeyShortcuts into dev

Reviewed-on: verdnatura/salix-front#682
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Jon Elias 2024-09-10 04:46:52 +00:00
commit 24426c5d38
17 changed files with 64 additions and 6 deletions

View File

@ -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;
}
};

View File

@ -33,7 +33,12 @@ const itemComputed = computed(() => {
<QItemSection avatar v-if="!itemComputed.icon">
<QIcon name="disabled_by_default" />
</QItemSection>
<QItemSection>{{ t(itemComputed.title) }}</QItemSection>
<QItemSection>
{{ t(itemComputed.title) }}
<QTooltip>
{{ 'Ctrl + Alt + ' + item.keyBinding.toUpperCase() }}
</QTooltip>
</QItemSection>
<QItemSection side>
<slot name="side" :item="itemComputed" />
</QItemSection>

View File

@ -55,6 +55,15 @@ const pinnedModules = computed(() => navigation.getPinnedModules());
>
<div class="text-center text-primary button-text">
{{ t(item.title) }}
<div v-if="item.keyBinding">
{{ '(' + item.keyBinding + ')' }}
<QTooltip>
{{
'Ctrl + Alt + ' +
item.keyBinding.toUpperCase()
}}
</QTooltip>
</div>
</div>
</QBtn>
</div>

View File

@ -7,6 +7,7 @@ export default {
title: 'suppliers',
icon: 'vn:supplier',
moduleName: 'Supplier',
keyBinding: 'p',
},
component: RouterView,
redirect: { name: 'SupplierMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'users',
icon: 'face',
moduleName: 'Account',
keyBinding: 'u',
},
component: RouterView,
redirect: { name: 'AccountMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'claims',
icon: 'vn:claims',
moduleName: 'Claim',
keyBinding: 'r',
},
component: RouterView,
redirect: { name: 'ClaimMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'customers',
icon: 'vn:client',
moduleName: 'Customer',
keyBinding: 'c',
},
component: RouterView,
redirect: { name: 'CustomerMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'entries',
icon: 'vn:entry',
moduleName: 'Entry',
keyBinding: 'e',
},
component: RouterView,
redirect: { name: 'EntryMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'items',
icon: 'vn:item',
moduleName: 'Item',
keyBinding: 'a',
},
component: RouterView,
redirect: { name: 'ItemMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'monitors',
icon: 'grid_view',
moduleName: 'Monitor',
keyBinding: 'm',
},
component: RouterView,
redirect: { name: 'MonitorMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'order',
icon: 'vn:basket',
moduleName: 'Order',
keyBinding: 'o',
},
component: RouterView,
redirect: { name: 'OrderMain' },

View File

@ -7,7 +7,6 @@ export default {
title: 'routes',
icon: 'vn:delivery',
moduleName: 'Route',
keyBinding: 'r',
},
component: RouterView,
redirect: { name: 'RouteMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'tickets',
icon: 'vn:ticket',
moduleName: 'Ticket',
keyBinding: 't',
},
component: RouterView,
redirect: { name: 'TicketMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'workers',
icon: 'vn:worker',
moduleName: 'Worker',
keyBinding: 'w',
},
component: RouterView,
redirect: { name: 'WorkerMain' },

View File

@ -7,6 +7,7 @@ export default {
title: 'zones',
icon: 'vn:zone',
moduleName: 'Zone',
keyBinding: 'z',
},
component: RouterView,
redirect: { name: 'ZoneMain' },

View File

@ -72,6 +72,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
if (meta) {
item.title = `globals.pageTitles.${meta.title}`;
item.icon = meta.icon;
item.keyBinding = meta.keyBinding;
}
parent.push(item);

View File

@ -0,0 +1,33 @@
/// <reference types="cypress" />
describe('VnShortcuts', () => {
const modules = {
item: 'a',
customer: 'c',
ticket: 't',
claim: 'r',
worker: 'w',
monitor: 'm',
order: 'o',
supplier: 'p',
entry: 'e',
zone: 'z',
account: 'u',
};
beforeEach(() => {
cy.login('developer');
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);
});
}
});