refactor: refs #6891 searchbar teleport

This commit is contained in:
Jorge Penadés 2024-06-03 12:58:26 +02:00
parent c78828d6a6
commit 36ff4e9312
2 changed files with 55 additions and 51 deletions

View File

@ -56,9 +56,19 @@ watchEffect(() => {
}); });
</script> </script>
<template> <template>
<template v-if="stateStore.isHeaderMounted()"> <QDrawer
<Teleport to="#searchbar" v-if="props.searchDataKey"> v-model="stateStore.leftDrawer"
<slot name="searchbar"> show-if-above
:width="256"
v-if="stateStore.isHeaderMounted()"
>
<QScrollArea class="fit">
<component :is="descriptor" />
<QSeparator />
<LeftMenu source="card" />
</QScrollArea>
</QDrawer>
<slot name="searchbar" v-if="props.searchDataKey">
<VnSearchbar <VnSearchbar
:data-key="props.searchDataKey" :data-key="props.searchDataKey"
:url="props.searchUrl" :url="props.searchUrl"
@ -68,16 +78,7 @@ watchEffect(() => {
:redirect="searchRedirect" :redirect="searchRedirect"
/> />
</slot> </slot>
</Teleport>
<slot v-else name="searchbar" /> <slot v-else name="searchbar" />
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
<QScrollArea class="fit">
<component :is="descriptor" />
<QSeparator />
<LeftMenu source="card" />
</QScrollArea>
</QDrawer>
</template>
<RightMenu> <RightMenu>
<template #right-panel v-if="props.filterPanel"> <template #right-panel v-if="props.filterPanel">
<component :is="props.filterPanel" :data-key="props.searchDataKey" /> <component :is="props.filterPanel" :data-key="props.searchDataKey" />

View File

@ -5,9 +5,11 @@ import { useArrayData } from 'composables/useArrayData';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import useRedirect from 'src/composables/useRedirect'; import useRedirect from 'src/composables/useRedirect';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useStateStore } from 'src/stores/useStateStore';
const quasar = useQuasar(); const quasar = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
const state = useStateStore();
const props = defineProps({ const props = defineProps({
dataKey: { dataKey: {
@ -107,8 +109,8 @@ async function search() {
}); });
} }
</script> </script>
<template> <template>
<Teleport to="#searchbar" v-if="state.isHeaderMounted()">
<QForm @submit="search" id="searchbarForm"> <QForm @submit="search" id="searchbarForm">
<VnInput <VnInput
id="searchbar" id="searchbar"
@ -137,6 +139,7 @@ async function search() {
</template> </template>
</VnInput> </VnInput>
</QForm> </QForm>
</Teleport>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>