diff --git a/src/boot/mainShortcutMixin.js b/src/boot/mainShortcutMixin.js new file mode 100644 index 000000000..c4d37fd73 --- /dev/null +++ b/src/boot/mainShortcutMixin.js @@ -0,0 +1,23 @@ +import routes from 'src/router/modules'; + +import { useRouter } from 'vue-router'; +export default { + mounted: function () { + const router = useRouter(); + const keyBindingMap = routes + .filter((route) => route.meta.keyBinding) + .reduce((map, route) => { + map[route.meta.keyBinding.toLowerCase()] = route.path; + return map; + }, {}); + const handleKeyDown = (event) => { + const { ctrlKey, altKey, key } = event; + event.preventDefault(); + if (ctrlKey && altKey && keyBindingMap[key]) { + router.push(keyBindingMap[key]); + } + }; + + window.addEventListener('keydown', handleKeyDown); + }, +}; diff --git a/src/boot/quasar.js b/src/boot/quasar.js index a8d9b7ad9..caf573ac7 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -1,6 +1,8 @@ import { boot } from 'quasar/wrappers'; import qFormMixin from './qformMixin'; +import mainShortcutMixin from './mainShortcutMixin'; export default boot(({ app }) => { app.mixin(qFormMixin); + app.mixin(mainShortcutMixin); }); diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index 22ef1622c..05f947cf3 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -22,7 +22,7 @@ const { t } = useI18n(); const { validate } = useValidator(); const { notify } = useNotify(); const route = useRoute(); - +const myForm = ref(null); const $props = defineProps({ url: { type: String, @@ -109,11 +109,14 @@ const defaultButtons = computed(() => ({ color: 'primary', icon: 'save', label: 'globals.save', + click: () => myForm.value.submit(), + type: 'submit', }, reset: { color: 'primary', icon: 'restart_alt', label: 'globals.reset', + click: () => reset(), }, ...$props.defaultButtons, })); @@ -276,7 +279,14 @@ defineExpose({