feat: #8410 added new feature to module searchbar #1272
|
@ -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();
|
||||
}
|
||||
provira marked this conversation as resolved
Outdated
|
||||
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);
|
||||
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
|
||||
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;
|
||||
provira marked this conversation as resolved
Outdated
jorgep
commented
Quitar Quitar
|
||||
});
|
||||
}
|
||||
jorgep
commented
si no se usa quitar si no se usa quitar
provira
commented
quitado quitado
|
||||
</script>
|
||||
|
||||
|
@ -212,14 +196,15 @@ function searchingFunction(evt) {
|
|||
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
||||
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.
|
||||
<QItem class="q-pb-md">
|
||||
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()"`
|
||||
<VnInput
|
||||
ref="searchInput"
|
||||
v-model="search"
|
||||
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.
|
||||
:label="t('Search modules')"
|
||||
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.
|
||||
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 />
|
||||
|
|
Loading…
Reference in New Issue
Estás haciendo 2 bucles, pasar a 1. Respuesta de copilot: