refactor: refs #6891 use Teleport | slot
This commit is contained in:
parent
15b080f7bd
commit
b1147f00d3
|
@ -1,9 +1,25 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
|
||||||
defineProps({
|
const hasContent = ref(false);
|
||||||
dataKey: { type: String, required: true },
|
const rightPanel = ref(null);
|
||||||
|
onMounted(() => {
|
||||||
|
rightPanel.value = document.querySelector('#right-panel');
|
||||||
|
if (rightPanel.value.childNodes.length) return (hasContent.value = true);
|
||||||
|
|
||||||
|
// Check if there's content to display
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
hasContent.value = rightPanel.value.childNodes.length;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (rightPanel.value)
|
||||||
|
observer.observe(rightPanel.value, {
|
||||||
|
subtree: true,
|
||||||
|
childList: true,
|
||||||
|
attributes: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -21,7 +37,8 @@ const stateStore = useStateStore();
|
||||||
</Teleport>
|
</Teleport>
|
||||||
<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">
|
||||||
<slot name="right-panel" />
|
<div id="right-panel"></div>
|
||||||
|
<slot v-if="!hasContent" name="right-panel" />
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -201,30 +201,7 @@ async function post(query, params) {
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (destinationTypes = data)"
|
@on-fetch="(data) => (destinationTypes = data)"
|
||||||
/>
|
/>
|
||||||
<template v-if="stateStore.isHeaderMounted()">
|
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted() && claim">
|
||||||
<Teleport to="#actions-append">
|
|
||||||
<div class="row q-gutter-x-sm">
|
|
||||||
<QBtn
|
|
||||||
flat
|
|
||||||
@click="stateStore.toggleRightDrawer()"
|
|
||||||
round
|
|
||||||
dense
|
|
||||||
icon="menu"
|
|
||||||
>
|
|
||||||
<QTooltip bottom anchor="bottom right">
|
|
||||||
{{ t('globals.collapseMenu') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</div>
|
|
||||||
</Teleport>
|
|
||||||
</template>
|
|
||||||
<QDrawer
|
|
||||||
v-model="stateStore.rightDrawer"
|
|
||||||
side="right"
|
|
||||||
:width="300"
|
|
||||||
show-if-above
|
|
||||||
v-if="claim"
|
|
||||||
>
|
|
||||||
<QCard class="totalClaim q-my-md q-pa-sm no-box-shadow">
|
<QCard class="totalClaim q-my-md q-pa-sm no-box-shadow">
|
||||||
{{ `${t('Total claimed')}: ${toCurrency(totalClaimed)}` }}
|
{{ `${t('Total claimed')}: ${toCurrency(totalClaimed)}` }}
|
||||||
</QCard>
|
</QCard>
|
||||||
|
@ -274,7 +251,7 @@ async function post(query, params) {
|
||||||
v-model="multiplicatorValue"
|
v-model="multiplicatorValue"
|
||||||
/>
|
/>
|
||||||
</QCard>
|
</QCard>
|
||||||
</QDrawer>
|
</Teleport>
|
||||||
<Teleport to="#st-data" v-if="stateStore.isSubToolbarShown()"> </Teleport>
|
<Teleport to="#st-data" v-if="stateStore.isSubToolbarShown()"> </Teleport>
|
||||||
<CrudModel
|
<CrudModel
|
||||||
v-if="claim"
|
v-if="claim"
|
||||||
|
|
Loading…
Reference in New Issue