forked from verdnatura/salix-front
feat: refs #6480 check if hasContent or slots
This commit is contained in:
parent
96d3073f67
commit
edf75c8cdd
|
@ -9,7 +9,6 @@ import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
import SkeletonTable from 'components/ui/SkeletonTable.vue';
|
||||||
import { tMobile } from 'src/composables/tMobile';
|
import { tMobile } from 'src/composables/tMobile';
|
||||||
import VnSubToolbar from './ui/VnSubToolbar.vue';
|
|
||||||
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
@ -259,8 +258,24 @@ watch(formUrl, async () => {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnSubToolbar class="q-mb-md">
|
<VnPaginate
|
||||||
<template #st-actions>
|
:url="url"
|
||||||
|
v-bind="$attrs"
|
||||||
|
@on-fetch="fetch"
|
||||||
|
:skeleton="false"
|
||||||
|
ref="vnPaginateRef"
|
||||||
|
>
|
||||||
|
<template #body v-if="formData">
|
||||||
|
<slot
|
||||||
|
name="body"
|
||||||
|
:rows="formData"
|
||||||
|
:validate="validate"
|
||||||
|
:filter="filter"
|
||||||
|
></slot>
|
||||||
|
</template>
|
||||||
|
</VnPaginate>
|
||||||
|
<SkeletonTable v-if="!formData" />
|
||||||
|
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown()">
|
||||||
<QBtnGroup push style="column-gap: 10px">
|
<QBtnGroup push style="column-gap: 10px">
|
||||||
<slot name="moreBeforeActions" />
|
<slot name="moreBeforeActions" />
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -295,25 +310,7 @@ watch(formUrl, async () => {
|
||||||
/>
|
/>
|
||||||
<slot name="moreAfterActions" />
|
<slot name="moreAfterActions" />
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
</template>
|
</Teleport>
|
||||||
</VnSubToolbar>
|
|
||||||
<VnPaginate
|
|
||||||
:url="url"
|
|
||||||
v-bind="$attrs"
|
|
||||||
@on-fetch="fetch"
|
|
||||||
:skeleton="false"
|
|
||||||
ref="vnPaginateRef"
|
|
||||||
>
|
|
||||||
<template #body v-if="formData">
|
|
||||||
<slot
|
|
||||||
name="body"
|
|
||||||
:rows="formData"
|
|
||||||
:validate="validate"
|
|
||||||
:filter="filter"
|
|
||||||
></slot>
|
|
||||||
</template>
|
|
||||||
</VnPaginate>
|
|
||||||
<SkeletonTable v-if="!formData" />
|
|
||||||
<QInnerLoading
|
<QInnerLoading
|
||||||
:showing="isLoading"
|
:showing="isLoading"
|
||||||
:label="t && t('globals.pleaseWait')"
|
:label="t && t('globals.pleaseWait')"
|
||||||
|
|
|
@ -3,9 +3,9 @@ import useCardSize from 'src/composables/useCardSize';
|
||||||
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
import VnSubToolbar from '../ui/VnSubToolbar.vue';
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
<VnSubToolbar />
|
||||||
<QPageContainer>
|
<QPageContainer>
|
||||||
<QPage>
|
<QPage>
|
||||||
<VnSubToolbar />
|
|
||||||
<div :class="useCardSize()">
|
<div :class="useCardSize()">
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,25 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, onUnmounted } from 'vue';
|
import { onMounted, onUnmounted, ref } from 'vue';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
// Falta si los divs tienen contenido o remplazar los teleport y usar siempre slots
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
const actions = ref(null);
|
||||||
|
const data = ref(null);
|
||||||
|
const opts = { subtree: true, childList: true, attributes: true };
|
||||||
|
const hasContent = ref(false);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
stateStore.toggleSubToolbar();
|
stateStore.toggleSubToolbar();
|
||||||
|
actions.value = document.querySelector('#st-actions');
|
||||||
|
data.value = document.querySelector('#st-data');
|
||||||
|
|
||||||
|
// Check if there's content to display
|
||||||
|
const observer = new MutationObserver(
|
||||||
|
() =>
|
||||||
|
(hasContent.value =
|
||||||
|
actions.value.childNodes.length + data.value.childNodes.length)
|
||||||
|
);
|
||||||
|
observer.observe(actions.value, opts);
|
||||||
|
observer.observe(data.value, opts);
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
@ -14,7 +28,10 @@ onUnmounted(() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<QToolbar class="justify-end sticky" v-if="$slots['st-data'] || $slots['st-actions']">
|
<QToolbar
|
||||||
|
class="justify-end sticky"
|
||||||
|
v-show="hasContent || $slots['st-actions'] || $slots['st-data']"
|
||||||
|
>
|
||||||
<slot name="st-data">
|
<slot name="st-data">
|
||||||
<div id="st-data"></div>
|
<div id="st-data"></div>
|
||||||
</slot>
|
</slot>
|
||||||
|
|
|
@ -7,7 +7,6 @@ import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import { useCapitalize } from 'src/composables/useCapitalize';
|
|
||||||
import VnCurrency from 'src/components/common/VnCurrency.vue';
|
import VnCurrency from 'src/components/common/VnCurrency.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -71,11 +70,7 @@ const suppliersRef = ref();
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInputDate
|
<VnInputDate :label="t('From')" v-model="params.from" is-outlined />
|
||||||
:label="t('From')"
|
|
||||||
v-model="params.from"
|
|
||||||
is-outlined
|
|
||||||
/>
|
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem>
|
||||||
|
|
Loading…
Reference in New Issue