feat: #8410 added new feature to module searchbar #1272
|
@ -25,7 +25,6 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
const initialized = ref(false);
|
const initialized = ref(false);
|
||||||
const items = ref([]);
|
const items = ref([]);
|
||||||
const searchingValue = false;
|
|
||||||
const expansionItemElements = reactive({});
|
const expansionItemElements = reactive({});
|
||||||
const pinnedModules = computed(() => {
|
const pinnedModules = computed(() => {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
@ -177,17 +176,9 @@ function normalize(text) {
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
const searchModule = () => {
|
const searchModule = () => {
|
||||||
provira marked this conversation as resolved
Outdated
|
|||||||
const searching = ref(false);
|
const [item] = filteredItems.value;
|
||||||
items.value.some((item) => {
|
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
|
|||||||
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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -203,12 +194,11 @@ const searchModule = () => {
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
autofocus
|
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) : ''"
|
@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()"`
|
|||||||
@update:model-value="searchingValue = !!$event"
|
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<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
|
<LeftMenuItem
|
||||||
v-for="[key, pinnedModule] of filteredPinnedModules"
|
v-for="[key, pinnedModule] of filteredPinnedModules"
|
||||||
:key="key"
|
:key="key"
|
||||||
|
@ -234,9 +224,9 @@ const searchModule = () => {
|
||||||
</template>
|
</template>
|
||||||
<template v-for="(item, index) in filteredItems" :key="item.name">
|
<template v-for="(item, index) in filteredItems" :key="item.name">
|
||||||
<template
|
<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>
|
<template #side>
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="item.isPinned === true"
|
v-if="item.isPinned === true"
|
||||||
|
|
Loading…
Reference in New Issue
Estás haciendo 2 bucles, pasar a 1. Respuesta de copilot: