diff --git a/src/boot/axios.js b/src/boot/axios.js index 5da26a404..aee38e887 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -4,8 +4,9 @@ import { Router } from 'src/router'; import useNotify from 'src/composables/useNotify.js'; import { useStateQueryStore } from 'src/stores/useStateQueryStore'; -let session, notify, stateQuery; - +const session = useSession(); +const { notify } = useNotify(); +const stateQuery = useStateQueryStore(); const baseUrl = '/api/'; axios.defaults.baseURL = baseUrl; @@ -50,15 +51,9 @@ const onResponseError = (error) => { return Promise.reject(error); }; -export function setupAxios() { - session = useSession(); - notify = useNotify().notify; - stateQuery = useStateQueryStore(); - - axios.interceptors.request.use(onRequest, onRequestError); - axios.interceptors.response.use(onResponse, onResponseError); - axiosNoError.interceptors.request.use(onRequest); - axiosNoError.interceptors.response.use(onResponse); -} +axios.interceptors.request.use(onRequest, onRequestError); +axios.interceptors.response.use(onResponse, onResponseError); +axiosNoError.interceptors.request.use(onRequest); +axiosNoError.interceptors.response.use(onResponse); export { onRequest, onResponseError, axiosNoError }; diff --git a/src/boot/quasar.js b/src/boot/quasar.js index 1cc2e82cf..01fe68d8b 100644 --- a/src/boot/quasar.js +++ b/src/boot/quasar.js @@ -1,7 +1,6 @@ import { boot } from 'quasar/wrappers'; import qFormMixin from './qformMixin'; import keyShortcut from './keyShortcut'; -import { setupAxios } from 'src/boot/axios'; import useNotify from 'src/composables/useNotify.js'; import { CanceledError } from 'axios'; @@ -49,5 +48,4 @@ export default boot(({ app }) => { notify(message ?? 'globals.error', 'negative', 'error'); }; - setupAxios(); }); diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index a4cb55a2c..0de5d3aa2 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -77,7 +77,7 @@ const isLoading = ref(false); const hasChanges = ref(false); const originalData = ref(); const vnPaginateRef = ref(); -const formData = ref(); +const formData = ref([]); const saveButtonRef = ref(null); const watchChanges = ref(); const formUrl = computed(() => $props.url); diff --git a/src/components/LeftMenu.vue b/src/components/LeftMenu.vue index 6e0ae5907..ab2931dfd 100644 --- a/src/components/LeftMenu.vue +++ b/src/components/LeftMenu.vue @@ -22,7 +22,7 @@ const props = defineProps({ default: 'main', }, }); - +const initialized = ref(false); const items = ref([]); const expansionItemElements = reactive({}); const pinnedModules = computed(() => { @@ -34,18 +34,26 @@ const search = ref(null); const filteredItems = computed(() => { if (!search.value) return items.value; + const normalizedSearch = normalize(search.value); return items.value.filter((item) => { - const locale = t(item.title).toLowerCase(); - return locale.includes(search.value.toLowerCase()); + const locale = normalize(t(item.title)); + return locale.includes(normalizedSearch); }); }); const filteredPinnedModules = computed(() => { if (!search.value) return pinnedModules.value; + const normalizedSearch = search.value + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, '') + .toLowerCase(); const map = new Map(); for (const [key, pinnedModule] of pinnedModules.value) { - const locale = t(pinnedModule.title).toLowerCase(); - if (locale.includes(search.value.toLowerCase())) map.set(key, pinnedModule); + const locale = t(pinnedModule.title) + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, '') + .toLowerCase(); + if (locale.includes(normalizedSearch)) map.set(key, pinnedModule); } return map; }); @@ -53,11 +61,13 @@ const filteredPinnedModules = computed(() => { onMounted(async () => { await navigation.fetchPinned(); getRoutes(); + initialized.value = true; }); watch( () => route.matched, () => { + if (!initialized.value) return; items.value = []; getRoutes(); }, @@ -147,6 +157,13 @@ async function togglePinned(item, event) { const handleItemExpansion = (itemName) => { expansionItemElements[itemName].scrollToLastElement(); }; + +function normalize(text) { + return text + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, '') + .toLowerCase(); +}