0
0
Fork 0

changes in entry searchbar

This commit is contained in:
William Buezas 2024-02-02 14:08:17 -03:00
parent 59c8ada077
commit 6c8e736b17
4 changed files with 40 additions and 21 deletions

View File

@ -61,6 +61,10 @@ const props = defineProps({
type: Function, type: Function,
default: null, default: null,
}, },
customRouteRedirectName: {
type: String,
default: '',
},
}); });
const router = useRouter(); const router = useRouter();
@ -87,8 +91,16 @@ async function search() {
}); });
if (!props.redirect) return; if (!props.redirect) return;
if (props.customRouteRedirectName) {
router.push({
name: props.customRouteRedirectName,
params: { id: searchText.value },
});
return;
}
const { matched: matches } = route; const { matched: matches } = route;
const { path } = matches[matches.length-1]; const { path } = matches[matches.length - 1];
const newRoute = path.replace(':id', searchText.value); const newRoute = path.replace(':id', searchText.value);
await router.push(newRoute); await router.push(newRoute);
} }

View File

@ -8,7 +8,9 @@ import VnRow from 'components/ui/VnRow.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue'; import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { toDate } from 'src/filters'; import { toDate } from 'src/filters';
@ -16,6 +18,7 @@ const state = useState();
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const stateStore = useStateStore();
const user = state.getUser(); const user = state.getUser();
const newEntryForm = reactive({ const newEntryForm = reactive({
@ -55,6 +58,17 @@ const redirectToEntryBasicData = (_, { id }) => {
@on-fetch="(data) => (companiesOptions = data)" @on-fetch="(data) => (companiesOptions = data)"
auto-load auto-load
/> />
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<VnSearchbar
url="Entries/filter"
custom-route-redirect-name="EntrySummary"
data-key="EntrySummary"
:label="t('Search entries')"
:info="t('You can search by entry reference')"
/>
</Teleport>
</template>
<QPage> <QPage>
<VnSubToolbar /> <VnSubToolbar />
<FormModel <FormModel

View File

@ -9,6 +9,7 @@ import VnLv from 'src/components/ui/VnLv.vue';
import CardList from 'src/components/ui/CardList.vue'; import CardList from 'src/components/ui/CardList.vue';
import EntrySummaryDialog from './Card/EntrySummaryDialog.vue'; import EntrySummaryDialog from './Card/EntrySummaryDialog.vue';
import EntryFilter from './EntryFilter.vue'; import EntryFilter from './EntryFilter.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { toDate } from 'src/filters/index'; import { toDate } from 'src/filters/index';
@ -41,6 +42,16 @@ onMounted(async () => {
</script> </script>
<template> <template>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<VnSearchbar
data-key="EntryList"
url="Entries/filter"
:label="t('Search entries')"
:info="t('You can search by entry reference')"
/>
</Teleport>
</template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above> <QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8"> <QScrollArea class="fit text-grey-8">
<EntryFilter data-key="EntryList" /> <EntryFilter data-key="EntryList" />
@ -132,4 +143,6 @@ onMounted(async () => {
es: es:
Inventory entry: Es inventario Inventory entry: Es inventario
Virtual entry: Es una redada Virtual entry: Es una redada
Search entries: Buscar entradas
You can search by entry reference: Puedes buscar por referencia de la entrada
</i18n> </i18n>

View File

@ -1,26 +1,12 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n';
import LeftMenu from 'src/components/LeftMenu.vue'; import LeftMenu from 'src/components/LeftMenu.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
const stateStore = useStateStore(); const stateStore = useStateStore();
const { t } = useI18n();
</script> </script>
<template> <template>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<VnSearchbar
data-key="EntryList"
url="Entries/filter"
:label="t('Search entries')"
:info="t('You can search by entry reference')"
/>
</Teleport>
</template>
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256"> <QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
<QScrollArea class="fit text-grey-8"> <QScrollArea class="fit text-grey-8">
<LeftMenu /> <LeftMenu />
@ -30,9 +16,3 @@ const { t } = useI18n();
<RouterView></RouterView> <RouterView></RouterView>
</QPageContainer> </QPageContainer>
</template> </template>
<i18n>
es:
Search entries: Buscar entradas
You can search by entry reference: Puedes buscar por referencia de la entrada
</i18n>