forked from verdnatura/salix-front
refactor: refs #8410 restructured code
This commit is contained in:
parent
6cba927ebc
commit
3e8b35e2e1
|
@ -25,6 +25,7 @@ const props = defineProps({
|
||||||
});
|
});
|
||||||
const initialized = ref(false);
|
const initialized = ref(false);
|
||||||
const items = ref([]);
|
const items = ref([]);
|
||||||
|
const searchingValue = ref(false);
|
||||||
const expansionItemElements = reactive({});
|
const expansionItemElements = reactive({});
|
||||||
const pinnedModules = computed(() => {
|
const pinnedModules = computed(() => {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
@ -176,33 +177,16 @@ function normalize(text) {
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
}
|
}
|
||||||
const searchModule = () => {
|
const searchModule = () => {
|
||||||
const moduleArrays = ref([]);
|
const searching = ref(false);
|
||||||
items.value.forEach((item) => {
|
items.value.some((item) => {
|
||||||
moduleArrays.value.push({
|
const title = normalize(t(item.title));
|
||||||
title: getLocale(item.title).normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase(),
|
if (title.includes(search.value.toLowerCase()) && !searching.value) {
|
||||||
name: item.name
|
|
||||||
});
|
|
||||||
})
|
|
||||||
const searching = ref(false)
|
|
||||||
moduleArrays.value.find((module) => {
|
|
||||||
console.log(module.title);
|
|
||||||
if (module.title.includes(search.value.toLowerCase()) && !searching.value) {
|
|
||||||
searching.value = true;
|
searching.value = true;
|
||||||
router.push({ name: module.name });
|
router.push({ name: item.name });
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
})
|
return false;
|
||||||
}
|
});
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -212,14 +196,15 @@ function searchingFunction(evt) {
|
||||||
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
<template v-if="$route?.matched[1]?.name === 'Dashboard'">
|
||||||
<QItem class="q-pb-md">
|
<QItem class="q-pb-md">
|
||||||
<VnInput
|
<VnInput
|
||||||
|
ref="searchInput"
|
||||||
v-model="search"
|
v-model="search"
|
||||||
:label="t('Search modules')"
|
:label="t('Search modules')"
|
||||||
class="full-width"
|
class="full-width"
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
autofocus
|
autofocus
|
||||||
@keyup.enter.stop="searchModule(search)"
|
@keyup.enter.stop="searchingValue ? searchModule(search) : ''"
|
||||||
@update:model-value="searchingFunction($event)"
|
@update:model-value="searchingValue = !!$event"
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
|
|
Loading…
Reference in New Issue