feat: #8410 added new feature to module searchbar #1272
|
@ -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 = () => {
|
||||
provira marked this conversation as resolved
Outdated
|
||||
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 });
|
||||
jorgep marked this conversation as resolved
Outdated
jorgep
commented
No es necesario que sea ref, usar variable normal. No es necesario que sea ref, usar variable normal.
provira
commented
arreglado arreglado
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -203,12 +194,11 @@ const searchModule = () => {
|
|||
filled
|
||||
dense
|
||||
autofocus
|
||||
provira marked this conversation as resolved
Outdated
jorgep
commented
Solo gastas esta función en 1 sitio, es innecesaria. Solo gastas esta función en 1 sitio, es innecesaria.
|
||||
@keyup.enter.stop="searchingValue ? searchModule(search) : ''"
|
||||
@update:model-value="searchingValue = !!$event"
|
||||
@keyup.enter.stop="search ? searchModule(search) : ''"
|
||||
jorgep marked this conversation as resolved
Outdated
jorgep
commented
llamar solo a la fn searchModule() llamar solo a la fn **searchModule()** `@keyup.enter.stop="searchModule()"`
|
||||
/>
|
||||
</QItem>
|
||||
<QSeparator />
|
||||
jorgep marked this conversation as resolved
Outdated
jorgep
commented
Las variables ponlas juntas y las funciones lo mismo. Las variables ponlas juntas y las funciones lo mismo.
|
||||
<template v-if="filteredPinnedModules.size && !searchingValue">
|
||||
<template v-if="filteredPinnedModules.size && !search">
|
||||
provira marked this conversation as resolved
Outdated
jorgep
commented
Solo gastas esta función en 1 sitio, es innecesaria. Solo gastas esta función en 1 sitio, es innecesaria.
|
||||
<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"
|
||||
|
|
Loading…
Reference in New Issue
Estás haciendo 2 bucles, pasar a 1. Respuesta de copilot: