diff --git a/quasar.config.js b/quasar.config.js index 8b6125a90..df2cf246d 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -31,6 +31,7 @@ export default configure(function (/* ctx */) { // --> boot files are part of "main.js" // https://v2.quasar.dev/quasar-cli/boot-files boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar', 'quasar.defaults'], + // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css css: ['app.scss'], diff --git a/src/boot/defaults/constants.js b/src/boot/defaults/constants.js deleted file mode 100644 index c96ceb2d1..000000000 --- a/src/boot/defaults/constants.js +++ /dev/null @@ -1,2 +0,0 @@ -export const langs = ['en', 'es']; -export const decimalPlaces = 2; diff --git a/src/boot/keyShortcut.js b/src/boot/keyShortcut.js index 6da06c8bf..5afb5b74a 100644 --- a/src/boot/keyShortcut.js +++ b/src/boot/keyShortcut.js @@ -1,6 +1,6 @@ export default { - mounted(el, binding) { - const shortcut = binding.value || '+'; + mounted: function (el, binding) { + const shortcut = binding.value ?? '+'; const { key, ctrl, alt, callback } = typeof shortcut === 'string' @@ -8,24 +8,25 @@ export default { key: shortcut, ctrl: true, alt: true, - callback: () => el?.click(), + callback: () => + document + .querySelector(`button[shortcut="${shortcut}"]`) + ?.click(), } : binding.value; - if (!el.hasAttribute('shortcut')) { - el.setAttribute('shortcut', key); - } - 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(el) { + unmounted: function (el) { if (el._handleKeydown) { window.removeEventListener('keydown', el._handleKeydown); } diff --git a/src/boot/qformMixin.js b/src/boot/qformMixin.js index 182c51e47..97d80c670 100644 --- a/src/boot/qformMixin.js +++ b/src/boot/qformMixin.js @@ -9,19 +9,19 @@ export default { if (!form) return; try { const inputsFormCard = form.querySelectorAll( - `input:not([disabled]):not([type="checkbox"])`, + `input:not([disabled]):not([type="checkbox"])` ); if (inputsFormCard.length) { focusFirstInput(inputsFormCard[0]); } const textareas = document.querySelectorAll( - 'textarea:not([disabled]), [contenteditable]:not([disabled])', + 'textarea:not([disabled]), [contenteditable]:not([disabled])' ); if (textareas.length) { focusFirstInput(textareas[textareas.length - 1]); } const inputs = document.querySelectorAll( - 'form#formModel input:not([disabled]):not([type="checkbox"])', + 'form#formModel input:not([disabled]):not([type="checkbox"])' ); const input = inputs[0]; if (!input) return; @@ -30,5 +30,22 @@ export default { } catch (error) { console.error(error); } + form.addEventListener('keyup', function (evt) { + if (evt.key === 'Enter' && !that.$attrs['prevent-submit']) { + const input = evt.target; + if (input.type == 'textarea' && evt.shiftKey) { + evt.preventDefault(); + let { selectionStart, selectionEnd } = input; + input.value = + input.value.substring(0, selectionStart) + + '\n' + + input.value.substring(selectionEnd); + selectionStart = selectionEnd = selectionStart + 1; + return; + } + evt.preventDefault(); + that.onSubmit(); + } + }); }, }; diff --git a/src/boot/quasar.js b/src/boot/quasar.js index a8c397b83..547517682 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -51,5 +51,4 @@ export default boot(({ app }) => { await useCau(response, message); }; - app.provide('app', app); }); diff --git a/src/components/CreateBankEntityForm.vue b/src/components/CreateBankEntityForm.vue index 7c4b94a6a..2da3aa994 100644 --- a/src/components/CreateBankEntityForm.vue +++ b/src/components/CreateBankEntityForm.vue @@ -14,7 +14,7 @@ const { t } = useI18n(); const bicInputRef = ref(null); const state = useState(); -const customer = computed(() => state.get('Customer')); +const customer = computed(() => state.get('customer')); const countriesFilter = { fields: ['id', 'name', 'code'], diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 93a2ac96a..d569dfda1 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -64,10 +64,6 @@ const $props = defineProps({ type: Function, default: null, }, - beforeSaveFn: { - type: Function, - default: null, - }, goTo: { type: String, default: '', @@ -180,11 +176,7 @@ async function saveChanges(data) { hasChanges.value = false; return; } - let changes = data || getChanges(); - if ($props.beforeSaveFn) { - changes = await $props.beforeSaveFn(changes, getChanges); - } - + const changes = data || getChanges(); try { await axios.post($props.saveUrl || $props.url + '/crud', changes); } finally { @@ -237,12 +229,12 @@ async function remove(data) { componentProps: { title: t('globals.confirmDeletion'), message: t('globals.confirmDeletionMessage'), - data: { deletes: ids }, + newData, ids, - promise: saveChanges, }, }) .onOk(async () => { + await saveChanges({ deletes: ids }); newData = newData.filter((form) => !ids.some((id) => id == form[pk])); fetch(newData); }); @@ -382,8 +374,6 @@ watch(formUrl, async () => { @click="onSubmit" :disable="!hasChanges" :title="t('globals.save')" - v-shortcut="'s'" - shortcut="s" data-cy="crudModelDefaultSaveBtn" /> diff --git a/src/components/FilterTravelForm.vue b/src/components/FilterTravelForm.vue index 765d97763..4d43c3810 100644 --- a/src/components/FilterTravelForm.vue +++ b/src/components/FilterTravelForm.vue @@ -181,7 +181,6 @@ const selectTravel = ({ id }) => { color="primary" :disabled="isLoading" :loading="isLoading" - data-cy="save-filter-travel-form" /> { :no-data-label="t('Enter a new search')" class="q-mt-lg" @row-click="(_, row) => selectTravel(row)" - data-cy="table-filter-travel-form" > diff --git a/src/components/ItemsFilterPanel.vue b/src/components/ItemsFilterPanel.vue index f73753a6b..36123b834 100644 --- a/src/components/ItemsFilterPanel.vue +++ b/src/components/ItemsFilterPanel.vue @@ -281,7 +281,7 @@ const setCategoryList = (data) => { { return locale.includes(normalizedSearch); }); }); + const filteredPinnedModules = computed(() => { if (!search.value) return pinnedModules.value; const normalizedSearch = search.value @@ -71,7 +72,7 @@ watch( items.value = []; getRoutes(); }, - { deep: true }, + { deep: true } ); function findMatches(search, item) { @@ -103,40 +104,33 @@ function addChildren(module, route, parent) { } function getRoutes() { - const handleRoutes = { - main: getMainRoutes, - card: getCardRoutes, - }; - try { - handleRoutes[props.source](); - } catch (error) { - throw new Error(`Method is not defined`); - } -} -function getMainRoutes() { - const modules = Object.assign([], navigation.getModules().value); + if (props.source === 'main') { + const modules = Object.assign([], navigation.getModules().value); - for (const item of modules) { - const moduleDef = routes.find( - (route) => toLowerCamel(route.name) === item.module, + for (const item of modules) { + const moduleDef = routes.find( + (route) => toLowerCamel(route.name) === item.module + ); + if (!moduleDef) continue; + item.children = []; + + addChildren(item.module, moduleDef, item.children); + } + + items.value = modules; + } + + if (props.source === 'card') { + const currentRoute = route.matched[1]; + const currentModule = toLowerCamel(currentRoute.name); + let moduleDef = routes.find( + (route) => toLowerCamel(route.name) === currentModule ); - if (!moduleDef) continue; - item.children = []; - addChildren(item.module, moduleDef, item.children); + if (!moduleDef) return; + if (!moduleDef?.menus) moduleDef = betaGetRoutes(); + addChildren(currentModule, moduleDef, items.value); } - - items.value = modules; -} - -function getCardRoutes() { - const currentRoute = route.matched[1]; - const currentModule = toLowerCamel(currentRoute.name); - let moduleDef = routes.find((route) => toLowerCamel(route.name) === currentModule); - - if (!moduleDef) return; - if (!moduleDef?.menus) moduleDef = betaGetRoutes(); - addChildren(currentModule, moduleDef, items.value); } function betaGetRoutes() { @@ -229,16 +223,9 @@ const searchModule = () => {