refactor: refs #8410 restructured code

This commit is contained in:
PAU ROVIRA ROSALENY 2025-01-30 13:06:28 +01:00
parent 6cba927ebc
commit 3e8b35e2e1
1 changed files with 12 additions and 27 deletions

View File

@ -25,6 +25,7 @@ const props = defineProps({
});
const initialized = ref(false);
const items = ref([]);
const searchingValue = ref(false);
const expansionItemElements = reactive({});
const pinnedModules = computed(() => {
const map = new Map();
@ -176,33 +177,16 @@ function normalize(text) {
.toLowerCase();
}
const searchModule = () => {
const moduleArrays = ref([]);
items.value.forEach((item) => {
moduleArrays.value.push({
title: getLocale(item.title).normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase(),
name: item.name
});
})
const searching = ref(false)
moduleArrays.value.find((module) => {
console.log(module.title);
if (module.title.includes(search.value.toLowerCase()) && !searching.value) {
const searching = ref(false);
items.value.some((item) => {
const title = normalize(t(item.title));
if (title.includes(search.value.toLowerCase()) && !searching.value) {
searching.value = true;
router.push({ name: module.name });
router.push({ name: item.name });
return true;
}
})
}
const getLocale = (label) => {
const globalLocale = t(label);
return globalLocale;
};
const searchingValue = ref(false);
function searchingFunction(evt) {
searchingValue.value = true;
if(evt === null) {
searchingValue.value = false;
}
return false;
});
}
</script>
@ -212,14 +196,15 @@ function searchingFunction(evt) {
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
<QItem class="q-pb-md">
<VnInput
ref="searchInput"
v-model="search"
:label="t('Search modules')"
class="full-width"
filled
dense
autofocus
@keyup.enter.stop="searchModule(search)"
@update:model-value="searchingFunction($event)"
@keyup.enter.stop="searchingValue ? searchModule(search) : ''"
@update:model-value="searchingValue = !!$event"
/>
</QItem>
<QSeparator />