forked from verdnatura/salix-front
feat: refs #6891 hide if no content
This commit is contained in:
parent
b1147f00d3
commit
7b6841afc6
|
@ -1,13 +1,15 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted, useSlots } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
|
||||||
|
const slots = useSlots();
|
||||||
const hasContent = ref(false);
|
const hasContent = ref(false);
|
||||||
const rightPanel = ref(null);
|
const rightPanel = ref(null);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
rightPanel.value = document.querySelector('#right-panel');
|
rightPanel.value = document.querySelector('#right-panel');
|
||||||
if (rightPanel.value.childNodes.length) return (hasContent.value = true);
|
if (rightPanel.value.childNodes.length) hasContent.value = true;
|
||||||
|
|
||||||
// Check if there's content to display
|
// Check if there's content to display
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
|
@ -20,6 +22,8 @@ onMounted(() => {
|
||||||
childList: true,
|
childList: true,
|
||||||
attributes: true,
|
attributes: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!slots['right-panel'] && !hasContent.value) stateStore.rightDrawer = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -28,7 +32,14 @@ const stateStore = useStateStore();
|
||||||
<template>
|
<template>
|
||||||
<Teleport to="#actions-append">
|
<Teleport to="#actions-append">
|
||||||
<div class="row q-gutter-x-sm">
|
<div class="row q-gutter-x-sm">
|
||||||
<QBtn flat @click="stateStore.toggleRightDrawer()" round dense icon="menu">
|
<QBtn
|
||||||
|
v-if="hasContent || $slots['right-panel']"
|
||||||
|
flat
|
||||||
|
@click="stateStore.toggleRightDrawer()"
|
||||||
|
round
|
||||||
|
dense
|
||||||
|
icon="menu"
|
||||||
|
>
|
||||||
<QTooltip bottom anchor="bottom right">
|
<QTooltip bottom anchor="bottom right">
|
||||||
{{ t('globals.collapseMenu') }}
|
{{ t('globals.collapseMenu') }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
|
|
|
@ -68,12 +68,8 @@ if (props.baseUrl) {
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
<RightMenu>
|
<RightMenu>
|
||||||
<template #right-panel>
|
<template #right-panel v-if="props.filterPanel">
|
||||||
<component
|
<component :is="props.filterPanel" :data-key="props.searchbarDataKey" />
|
||||||
v-if="props.filterPanel"
|
|
||||||
:is="props.filterPanel"
|
|
||||||
:data-key="props.searchbarDataKey"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue