fix: refs #8410 simplified searchModule function
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
PAU ROVIRA ROSALENY 2025-01-30 13:51:12 +01:00
parent b2414f861b
commit 860f92cb42
1 changed files with 7 additions and 17 deletions

View File

@ -25,7 +25,6 @@ const props = defineProps({
});
const initialized = ref(false);
const items = ref([]);
const searchingValue = false;
const expansionItemElements = reactive({});
const pinnedModules = computed(() => {
const map = new Map();
@ -177,17 +176,9 @@ function normalize(text) {
.toLowerCase();
}
const searchModule = () => {
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: item.name });
return true;
}
return false;
});
}
const [item] = filteredItems.value;
if (item) router.push({ name: item.name });
};
</script>
<template>
@ -203,12 +194,11 @@ const searchModule = () => {
filled
dense
autofocus
@keyup.enter.stop="searchingValue ? searchModule(search) : ''"
@update:model-value="searchingValue = !!$event"
@keyup.enter.stop="search ? searchModule(search) : ''"
/>
</QItem>
<QSeparator />
<template v-if="filteredPinnedModules.size && !searchingValue">
<template v-if="filteredPinnedModules.size && !search">
<LeftMenuItem
v-for="[key, pinnedModule] of filteredPinnedModules"
:key="key"
@ -234,9 +224,9 @@ const searchModule = () => {
</template>
<template v-for="(item, index) in filteredItems" :key="item.name">
<template
v-if="searchingValue ||item.children && !filteredPinnedModules.has(item.name)"
v-if="search ||item.children && !filteredPinnedModules.has(item.name)"
>
<LeftMenuItem :item="item" group="modules" :class="searchingValue && index === 0 ? 'searched' : ''">
<LeftMenuItem :item="item" group="modules" :class="search && index === 0 ? 'searched' : ''">
<template #side>
<QBtn
v-if="item.isPinned === true"