0
0
Fork 0

Merge pull request '#7911 - Add Shortcut keyboard when press Ctrl+Alt++' (!653) from plus_key_shortcut into dev

Reviewed-on: verdnatura/salix-front#653
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Javier Segarra 2024-09-05 13:52:03 +00:00
commit a48c293a9a
23 changed files with 153 additions and 28 deletions

34
src/boot/keyShortcut.js Normal file
View File

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

View File

@ -1,8 +1,10 @@
import { boot } from 'quasar/wrappers'; import { boot } from 'quasar/wrappers';
import qFormMixin from './qformMixin'; import qFormMixin from './qformMixin';
import mainShortcutMixin from './mainShortcutMixin'; import mainShortcutMixin from './mainShortcutMixin';
import keyShortcut from './keyShortcut';
export default boot(({ app }) => { export default boot(({ app }) => {
app.mixin(qFormMixin); app.mixin(qFormMixin);
app.mixin(mainShortcutMixin); app.mixin(mainShortcutMixin);
app.directive('shortcut', keyShortcut);
}); });

View File

@ -24,7 +24,13 @@ const pinnedModulesRef = ref();
<template> <template>
<QHeader color="white" elevated> <QHeader color="white" elevated>
<QToolbar class="q-py-sm q-px-md"> <QToolbar class="q-py-sm q-px-md">
<QBtn @click="stateStore.toggleLeftDrawer()" icon="menu" round dense flat> <QBtn
@click="stateStore.toggleLeftDrawer()"
icon="dock_to_right"
round
dense
flat
>
<QTooltip bottom anchor="bottom right"> <QTooltip bottom anchor="bottom right">
{{ t('globals.collapseMenu') }} {{ t('globals.collapseMenu') }}
</QTooltip> </QTooltip>

View File

@ -617,7 +617,7 @@ defineExpose({
</template> </template>
</CrudModel> </CrudModel>
<QPageSticky v-if="create" :offset="[20, 20]" style="z-index: 2"> <QPageSticky v-if="create" :offset="[20, 20]" style="z-index: 2">
<QBtn @click="showForm = !showForm" color="primary" fab icon="add" /> <QBtn @click="showForm = !showForm" color="primary" fab icon="add" shortcut="+" />
<QTooltip> <QTooltip>
{{ createForm.title }} {{ createForm.title }}
</QTooltip> </QTooltip>

View File

@ -37,7 +37,7 @@ const stateStore = useStateStore();
@click="stateStore.toggleRightDrawer()" @click="stateStore.toggleRightDrawer()"
round round
dense dense
icon="menu" icon="dock_to_left"
> >
<QTooltip bottom anchor="bottom right"> <QTooltip bottom anchor="bottom right">
{{ t('globals.collapseMenu') }} {{ t('globals.collapseMenu') }}

View File

@ -5,7 +5,7 @@ const quasar = useQuasar();
</script> </script>
<template> <template>
<QLayout view="hHh LpR fFf"> <QLayout view="hHh LpR fFf" v-shortcut>
<Navbar /> <Navbar />
<RouterView></RouterView> <RouterView></RouterView>
<QFooter v-if="quasar.platform.is.mobile"></QFooter> <QFooter v-if="quasar.platform.is.mobile"></QFooter>

View File

@ -169,7 +169,13 @@ onMounted(async () => await getAccountData(false));
<AccountMailAliasCreateForm @on-submit-create-alias="createMailAlias" /> <AccountMailAliasCreateForm @on-submit-create-alias="createMailAlias" />
</QDialog> </QDialog>
<QPageSticky position="bottom-right" :offset="[18, 18]"> <QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn fab icon="add" color="primary" @click="openCreateMailAliasForm()"> <QBtn
fab
icon="add"
color="primary"
@click="openCreateMailAliasForm()"
shortcut="+"
>
<QTooltip>{{ t('warehouses.add') }}</QTooltip> <QTooltip>{{ t('warehouses.add') }}</QTooltip>
</QBtn> </QBtn>
</QPageSticky> </QPageSticky>

View File

@ -218,7 +218,13 @@ const toCustomerAddressEdit = (addressId) => {
</div> </div>
<QPageSticky :offset="[18, 18]"> <QPageSticky :offset="[18, 18]">
<QBtn @click.stop="toCustomerAddressCreate()" color="primary" fab icon="add" /> <QBtn
@click.stop="toCustomerAddressCreate()"
color="primary"
fab
icon="add"
shortcut="+"
/>
<QTooltip> <QTooltip>
{{ t('New consignee') }} {{ t('New consignee') }}
</QTooltip> </QTooltip>

View File

@ -292,7 +292,13 @@ const showBalancePdf = ({ id }) => {
</template> </template>
</VnTable> </VnTable>
<QPageSticky :offset="[18, 18]" style="z-index: 2"> <QPageSticky :offset="[18, 18]" style="z-index: 2">
<QBtn @click.stop="showNewPaymentDialog()" color="primary" fab icon="add" /> <QBtn
@click.stop="showNewPaymentDialog()"
color="primary"
fab
icon="add"
shortcut="+"
/>
<QTooltip> <QTooltip>
{{ t('New payment') }} {{ t('New payment') }}
</QTooltip> </QTooltip>

View File

@ -193,6 +193,7 @@ const updateData = () => {
color="primary" color="primary"
fab fab
icon="add" icon="add"
shortcut="+"
/> />
<QTooltip> <QTooltip>
{{ t('New contract') }} {{ t('New contract') }}

View File

@ -562,7 +562,13 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</VnPaginate> </VnPaginate>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<QBtn @click="redirectToItemCreate()" color="primary" fab icon="add" /> <QBtn
@click="redirectToItemCreate()"
color="primary"
fab
icon="add"
shortcut="+"
/>
<QTooltip class="text-no-wrap"> <QTooltip class="text-no-wrap">
{{ t('New item') }} {{ t('New item') }}
</QTooltip> </QTooltip>

View File

@ -99,7 +99,13 @@ const exprBuilder = (param, value) => {
</div> </div>
</QPage> </QPage>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<QBtn fab icon="add" color="primary" @click="redirectToCreateView()" /> <QBtn
fab
icon="add"
color="primary"
@click="redirectToCreateView()"
shortcut="+"
/>
<QTooltip> <QTooltip>
{{ t('New item type') }} {{ t('New item type') }}
</QTooltip> </QTooltip>

View File

@ -87,7 +87,7 @@ function exprBuilder(param, value) {
</div> </div>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<RouterLink :to="{ name: 'ShelvingCreate' }"> <RouterLink :to="{ name: 'ShelvingCreate' }">
<QBtn fab icon="add" color="primary" /> <QBtn fab icon="add" color="primary" shortcut="+" />
<QTooltip> <QTooltip>
{{ t('shelving.list.newShelving') }} {{ t('shelving.list.newShelving') }}
</QTooltip> </QTooltip>

View File

@ -81,7 +81,13 @@ const redirectToUpdateView = (addressData) => {
</VnPaginate> </VnPaginate>
</div> </div>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<QBtn fab icon="add" color="primary" @click="redirectToCreateView()" /> <QBtn
fab
icon="add"
color="primary"
@click="redirectToCreateView()"
shortcut="+"
/>
<QTooltip> <QTooltip>
{{ t('New address') }} {{ t('New address') }}
</QTooltip> </QTooltip>
@ -93,3 +99,4 @@ const redirectToUpdateView = (addressData) => {
es: es:
New address: Nueva dirección New address: Nueva dirección
</i18n> </i18n>
s

View File

@ -109,7 +109,13 @@ const redirectToCreateView = () => {
</template> </template>
</CrudModel> </CrudModel>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<QBtn fab icon="add" color="primary" @click="redirectToCreateView()" /> <QBtn
fab
icon="add"
color="primary"
@click="redirectToCreateView()"
shortcut="+"
/>
<QTooltip> <QTooltip>
{{ t('supplier.agencyTerms.addRow') }} {{ t('supplier.agencyTerms.addRow') }}
</QTooltip> </QTooltip>

View File

@ -252,7 +252,13 @@ const openCreateModal = () => createTicketRequestDialogRef.value.show();
<TicketCreateRequest @on-request-created="crudModelRef.reload()" /> <TicketCreateRequest @on-request-created="crudModelRef.reload()" />
</QDialog> </QDialog>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<QBtn @click="openCreateModal()" color="primary" fab icon="add" /> <QBtn
@click="openCreateModal()"
color="primary"
fab
icon="add"
shortcut="+"
/>
<QTooltip class="text-no-wrap"> <QTooltip class="text-no-wrap">
{{ t('purchaseRequest.newRequest') }} {{ t('purchaseRequest.newRequest') }}
</QTooltip> </QTooltip>

View File

@ -82,7 +82,7 @@ const openCreateModal = () => createTrackingDialogRef.value.show();
data-key="TicketTracking" data-key="TicketTracking"
:filter="paginateFilter" :filter="paginateFilter"
url="TicketTrackings" url="TicketTrackings"
auto-load auto-load
order="created DESC" order="created DESC"
:limit="0" :limit="0"
> >
@ -114,7 +114,13 @@ const openCreateModal = () => createTrackingDialogRef.value.show();
<TicketCreateTracking @on-request-created="paginateRef.fetch()" /> <TicketCreateTracking @on-request-created="paginateRef.fetch()" />
</QDialog> </QDialog>
<QPageSticky :offset="[20, 20]"> <QPageSticky :offset="[20, 20]">
<QBtn @click="openCreateModal()" color="primary" fab icon="add" /> <QBtn
@click="openCreateModal()"
color="primary"
fab
icon="add"
shortcut="+"
/>
<QTooltip class="text-no-wrap"> <QTooltip class="text-no-wrap">
{{ t('tracking.addState') }} {{ t('tracking.addState') }}
</QTooltip> </QTooltip>

View File

@ -196,6 +196,7 @@ const removeThermograph = async (id) => {
icon="add" icon="add"
color="primary" color="primary"
@click="redirectToThermographForm('create')" @click="redirectToThermographForm('create')"
shortcut="+"
/> />
<QTooltip class="text-no-wrap"> <QTooltip class="text-no-wrap">
{{ t('Add thermograph') }} {{ t('Add thermograph') }}

View File

@ -74,7 +74,7 @@ async function remove(row) {
</VnPaginate> </VnPaginate>
</div> </div>
<QPageSticky position="bottom-right" :offset="[18, 18]"> <QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn @click="create" fab icon="add" color="primary" /> <QBtn @click="create" fab icon="add" color="primary" shortcut="+" />
</QPageSticky> </QPageSticky>
</QPage> </QPage>
</template> </template>

View File

@ -94,7 +94,7 @@ async function remove(row) {
</VnPaginate> </VnPaginate>
</div> </div>
<QPageSticky position="bottom-right" :offset="[18, 18]"> <QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn @click="create" fab icon="add" color="primary" /> <QBtn @click="create" fab icon="add" color="primary" shortcut="+" />
</QPageSticky> </QPageSticky>
</QPage> </QPage>
</template> </template>

View File

@ -116,7 +116,7 @@ function reloadData() {
</template> </template>
</VnPaginate> </VnPaginate>
<QPageSticky :offset="[18, 18]"> <QPageSticky :offset="[18, 18]">
<QBtn @click.stop="dialog.show()" color="primary" fab icon="add"> <QBtn @click.stop="dialog.show()" color="primary" fab icon="add" shortcut="+">
<QDialog ref="dialog"> <QDialog ref="dialog">
<FormModelPopup <FormModelPopup
:title="t('Add new device')" :title="t('Add new device')"

View File

@ -44,15 +44,34 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</script> </script>
<template> <template>
<Teleport to="#right-panel" v-if="useStateStore().isHeaderMounted()"> <template v-if="stateStore.isHeaderMounted()">
<ZoneEventsPanel <Teleport to="#actions-append">
:first-day="firstDay" <div class="row q-gutter-x-sm">
:last-day="lastDay" <QBtn
:events="events" flat
v-model:formModeName="formModeName" @click="stateStore.toggleRightDrawer()"
@open-zone-form="openForm" round
/> dense
</Teleport> icon="dock_to_left"
>
<QTooltip bottom anchor="bottom right">
{{ t('globals.collapseMenu') }}
</QTooltip>
</QBtn>
</div>
</Teleport>
</template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8">
<ZoneEventsPanel
:first-day="firstDay"
:last-day="lastDay"
:events="events"
v-model:formModeName="formModeName"
@open-zone-form="openForm"
/>
</QScrollArea>
</QDrawer>
<QPage class="q-pa-md flex justify-center"> <QPage class="q-pa-md flex justify-center">
<ZoneCalendarGrid <ZoneCalendarGrid
v-model:events="events" v-model:events="events"
@ -83,6 +102,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
color="primary" color="primary"
fab fab
icon="add" icon="add"
shortcut="+"
/> />
<QTooltip class="text-no-wrap"> <QTooltip class="text-no-wrap">
{{ t('eventsInclusionForm.addEvent') }} {{ t('eventsInclusionForm.addEvent') }}

View File

@ -111,7 +111,13 @@ const openCreateWarehouseForm = () => createWarehouseDialogRef.value.show();
<ZoneCreateWarehouse @on-submit-create-warehouse="createZoneWarehouse" /> <ZoneCreateWarehouse @on-submit-create-warehouse="createZoneWarehouse" />
</QDialog> </QDialog>
<QPageSticky position="bottom-right" :offset="[18, 18]"> <QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn fab icon="add" color="primary" @click="openCreateWarehouseForm()"> <QBtn
fab
icon="add"
color="primary"
@click="openCreateWarehouseForm()"
shortcut="+"
>
<QTooltip>{{ t('warehouses.add') }}</QTooltip> <QTooltip>{{ t('warehouses.add') }}</QTooltip>
</QBtn> </QBtn>
</QPageSticky> </QPageSticky>