diff --git a/src/boot/keyShortcut.js b/src/boot/keyShortcut.js new file mode 100644 index 000000000..5afb5b74a --- /dev/null +++ b/src/boot/keyShortcut.js @@ -0,0 +1,34 @@ +export default { + mounted: function (el, binding) { + const shortcut = binding.value ?? '+'; + + const { key, ctrl, alt, callback } = + typeof shortcut === 'string' + ? { + key: shortcut, + ctrl: true, + alt: true, + callback: () => + document + .querySelector(`button[shortcut="${shortcut}"]`) + ?.click(), + } + : binding.value; + + const handleKeydown = (event) => { + if (event.key === key && (!ctrl || event.ctrlKey) && (!alt || event.altKey)) { + callback(); + } + }; + + // Attach the event listener to the window + window.addEventListener('keydown', handleKeydown); + + el._handleKeydown = handleKeydown; + }, + unmounted: function (el) { + if (el._handleKeydown) { + window.removeEventListener('keydown', el._handleKeydown); + } + }, +}; diff --git a/src/boot/quasar.js b/src/boot/quasar.js index caf573ac7..e2035c880 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -1,8 +1,10 @@ import { boot } from 'quasar/wrappers'; import qFormMixin from './qformMixin'; import mainShortcutMixin from './mainShortcutMixin'; +import keyShortcut from './keyShortcut'; export default boot(({ app }) => { app.mixin(qFormMixin); app.mixin(mainShortcutMixin); + app.directive('shortcut', keyShortcut); }); diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index e80a293c6..00faaebc2 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -24,7 +24,13 @@ const pinnedModulesRef = ref(); - + {{ createForm.title }} diff --git a/src/components/common/RightMenu.vue b/src/components/common/RightMenu.vue index 732e5367d..3aa1891f9 100644 --- a/src/components/common/RightMenu.vue +++ b/src/components/common/RightMenu.vue @@ -37,7 +37,7 @@ const stateStore = useStateStore(); @click="stateStore.toggleRightDrawer()" round dense - icon="menu" + icon="dock_to_left" > {{ t('globals.collapseMenu') }} diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 88c5ee293..51cd20071 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -5,7 +5,7 @@ const quasar = useQuasar(); - + {{ t('New payment') }} diff --git a/src/pages/Customer/Card/CustomerCreditContracts.vue b/src/pages/Customer/Card/CustomerCreditContracts.vue index 568adcf0b..12719b2cf 100644 --- a/src/pages/Customer/Card/CustomerCreditContracts.vue +++ b/src/pages/Customer/Card/CustomerCreditContracts.vue @@ -193,6 +193,7 @@ const updateData = () => { color="primary" fab icon="add" + shortcut="+" /> {{ t('New contract') }} diff --git a/src/pages/Item/ItemList.vue b/src/pages/Item/ItemList.vue index 2e829c6a1..e3fcceb3a 100644 --- a/src/pages/Item/ItemList.vue +++ b/src/pages/Item/ItemList.vue @@ -562,7 +562,13 @@ onUnmounted(() => (stateStore.rightDrawer = false)); - + {{ t('New item') }} diff --git a/src/pages/Item/ItemTypeList.vue b/src/pages/Item/ItemTypeList.vue index 125672d60..d874a5dcb 100644 --- a/src/pages/Item/ItemTypeList.vue +++ b/src/pages/Item/ItemTypeList.vue @@ -99,7 +99,13 @@ const exprBuilder = (param, value) => { - + {{ t('New item type') }} diff --git a/src/pages/Shelving/ShelvingList.vue b/src/pages/Shelving/ShelvingList.vue index 3f16f8ef7..d29f6ff15 100644 --- a/src/pages/Shelving/ShelvingList.vue +++ b/src/pages/Shelving/ShelvingList.vue @@ -87,7 +87,7 @@ function exprBuilder(param, value) { - + {{ t('shelving.list.newShelving') }} diff --git a/src/pages/Supplier/Card/SupplierAddresses.vue b/src/pages/Supplier/Card/SupplierAddresses.vue index 735b50625..4bb6d5622 100644 --- a/src/pages/Supplier/Card/SupplierAddresses.vue +++ b/src/pages/Supplier/Card/SupplierAddresses.vue @@ -81,7 +81,13 @@ const redirectToUpdateView = (addressData) => { - + {{ t('New address') }} @@ -93,3 +99,4 @@ const redirectToUpdateView = (addressData) => { es: New address: Nueva dirección +s diff --git a/src/pages/Supplier/Card/SupplierAgencyTerm.vue b/src/pages/Supplier/Card/SupplierAgencyTerm.vue index 26a410e8c..99b672cc4 100644 --- a/src/pages/Supplier/Card/SupplierAgencyTerm.vue +++ b/src/pages/Supplier/Card/SupplierAgencyTerm.vue @@ -109,7 +109,13 @@ const redirectToCreateView = () => { - + {{ t('supplier.agencyTerms.addRow') }} diff --git a/src/pages/Ticket/Card/TicketPurchaseRequest.vue b/src/pages/Ticket/Card/TicketPurchaseRequest.vue index 281dc46a1..8d84e2b46 100644 --- a/src/pages/Ticket/Card/TicketPurchaseRequest.vue +++ b/src/pages/Ticket/Card/TicketPurchaseRequest.vue @@ -252,7 +252,13 @@ const openCreateModal = () => createTicketRequestDialogRef.value.show(); - + {{ t('purchaseRequest.newRequest') }} diff --git a/src/pages/Ticket/Card/TicketTracking.vue b/src/pages/Ticket/Card/TicketTracking.vue index 53f59adf9..f7cbb14e9 100644 --- a/src/pages/Ticket/Card/TicketTracking.vue +++ b/src/pages/Ticket/Card/TicketTracking.vue @@ -82,7 +82,7 @@ const openCreateModal = () => createTrackingDialogRef.value.show(); data-key="TicketTracking" :filter="paginateFilter" url="TicketTrackings" - auto-load + auto-load order="created DESC" :limit="0" > @@ -114,7 +114,13 @@ const openCreateModal = () => createTrackingDialogRef.value.show(); - + {{ t('tracking.addState') }} diff --git a/src/pages/Travel/Card/TravelThermographs.vue b/src/pages/Travel/Card/TravelThermographs.vue index 9f224154c..6d83581ee 100644 --- a/src/pages/Travel/Card/TravelThermographs.vue +++ b/src/pages/Travel/Card/TravelThermographs.vue @@ -196,6 +196,7 @@ const removeThermograph = async (id) => { icon="add" color="primary" @click="redirectToThermographForm('create')" + shortcut="+" /> {{ t('Add thermograph') }} diff --git a/src/pages/Wagon/Type/WagonTypeList.vue b/src/pages/Wagon/Type/WagonTypeList.vue index 3ecca1ea3..b7bbf8c5d 100644 --- a/src/pages/Wagon/Type/WagonTypeList.vue +++ b/src/pages/Wagon/Type/WagonTypeList.vue @@ -74,7 +74,7 @@ async function remove(row) { - + diff --git a/src/pages/Wagon/WagonList.vue b/src/pages/Wagon/WagonList.vue index a8b6728c3..c4824b861 100644 --- a/src/pages/Wagon/WagonList.vue +++ b/src/pages/Wagon/WagonList.vue @@ -94,7 +94,7 @@ async function remove(row) { - + diff --git a/src/pages/Worker/Card/WorkerPda.vue b/src/pages/Worker/Card/WorkerPda.vue index 4e0abc20c..a53aac270 100644 --- a/src/pages/Worker/Card/WorkerPda.vue +++ b/src/pages/Worker/Card/WorkerPda.vue @@ -116,7 +116,7 @@ function reloadData() { - + (stateStore.rightDrawer = false));