8713-testToMaster #1539

Merged
alexm merged 118 commits from 8713-testToMaster into master 2025-03-04 06:57:15 +00:00
3 changed files with 5 additions and 64 deletions
Showing only changes of commit aff783eb2e - Show all commits

View File

@ -2,7 +2,7 @@
import RightAdvancedMenu from './RightAdvancedMenu.vue'; import RightAdvancedMenu from './RightAdvancedMenu.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnSearchbar from 'components/ui/VnSearchbar.vue';
import VnTableFilter from '../VnTable/VnTableFilter.vue'; import VnTableFilter from '../VnTable/VnTableFilter.vue';
import { onBeforeMount, onMounted, onUnmounted, computed, ref, inject, watch } from 'vue'; import { onBeforeMount, onMounted, onUnmounted, computed, ref } from 'vue';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useHasContent } from 'src/composables/useHasContent'; import { useHasContent } from 'src/composables/useHasContent';
@ -36,10 +36,6 @@ const $props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
filterPanelRef: {
type: Object,
default: null,
},
redirect: { redirect: {
type: Boolean, type: Boolean,
default: true, default: true,
@ -60,9 +56,6 @@ const isMainSection = ref(false);
const searchbarId = 'section-searchbar'; const searchbarId = 'section-searchbar';
const advancedMenuSlot = 'advanced-menu'; const advancedMenuSlot = 'advanced-menu';
const hasContent = useHasContent(`#${searchbarId}`); const hasContent = useHasContent(`#${searchbarId}`);
// const filterPanel = ref(inject('filterPanel', null));
// filterPanel.value = inject('filterPanel', null);
onBeforeMount(() => { onBeforeMount(() => {
if ($props.dataKey) if ($props.dataKey)
@ -74,26 +67,14 @@ onBeforeMount(() => {
}); });
checkIsMain(); checkIsMain();
}); });
// const filterPanel = ref(inject('filterPanel', null));
onMounted(() => { onMounted(() => {
const unsubscribe = router.afterEach(() => { const unsubscribe = router.afterEach(() => {
checkIsMain(); checkIsMain();
}); });
// filterPanel.value = inject('filterPanel', null);
onUnmounted(unsubscribe); onUnmounted(unsubscribe);
}); });
watch(
() => inject('filterPanel'),
(newValue) => {
if (newValue) {
debugger;
// hacer algo cuando el valor esté disponible
}
},
{ immediate: true },
);
onUnmounted(() => { onUnmounted(() => {
if (arrayData) arrayData.destroy(); if (arrayData) arrayData.destroy();
}); });
@ -107,10 +88,8 @@ function checkIsMain() {
} }
</script> </script>
<template> <template>
<pre>{{ filterPanelRef }}</pre>
<slot name="searchbar"> <slot name="searchbar">
<VnSearchbar <VnSearchbar
:filterPanel="filterPanelRef"
v-if="searchBar && !hasContent" v-if="searchBar && !hasContent"
v-bind="arrayDataProps" v-bind="arrayDataProps"
:data-key="dataKey" :data-key="dataKey"

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed, inject, onMounted, provide } from 'vue'; import { ref, computed, provide } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import toDate from 'filters/toDate'; import toDate from 'filters/toDate';
@ -92,25 +92,16 @@ const arrayData =
const store = arrayData.store; const store = arrayData.store;
const userParams = ref(useFilterParams($props.dataKey).params); const userParams = ref(useFilterParams($props.dataKey).params);
const userOrders = ref(useFilterParams($props.dataKey).orders); const userOrders = ref(useFilterParams($props.dataKey).orders);
const searchbar = ref(null);
const isLoading = ref(false); const isLoading = ref(false);
const excludeParams = ref($props.excludeParams); const excludeParams = ref($props.excludeParams);
onMounted(() => {
searchbar.value = inject('searchbar');
});
defineExpose({ search, params: userParams, remove }); defineExpose({ search, params: userParams, remove });
async function search(evt) { async function search(evt) {
try { try {
// if ($props.searchbarOptions.use) {
// // if (!searchbar.value) {
// // return;
// // }
const validations = $props.validations.every((validation) => { const validations = $props.validations.every((validation) => {
return validation(userParams.value); return validation(userParams.value);
}); });
// $props.searchbarOptions.validateFn(userParams.value);
if (!validations) { if (!validations) {
return; return;
@ -120,7 +111,6 @@ async function search(evt) {
excludeParams.value = null; excludeParams.value = null;
} }
// }
if (evt && $props.disableSubmitEvent) return; if (evt && $props.disableSubmitEvent) return;
store.filter.where = {}; store.filter.where = {};
@ -143,7 +133,6 @@ async function search(evt) {
isLoading.value = false; isLoading.value = false;
} }
} }
provide('filterPanel', search);
async function clearFilters() { async function clearFilters() {
try { try {

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { onMounted, ref, computed, watch, inject, onUpdated } from 'vue'; import { onMounted, ref, computed, watch } from 'vue';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
@ -69,10 +69,6 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: true, default: true,
}, },
filterPanelOptions: {
type: Boolean,
default: true,
},
filterPanel: { filterPanel: {
type: Object, type: Object,
default: true, default: true,
@ -93,6 +89,7 @@ if (props.redirect)
}; };
let arrayData = useArrayData(props.dataKey, arrayDataProps); let arrayData = useArrayData(props.dataKey, arrayDataProps);
let store = arrayData.store; let store = arrayData.store;
const filterPanel = ref(props.filterPanel);
const to = computed(() => { const to = computed(() => {
const url = { path: route.path, query: { ...(route.query ?? {}) } }; const url = { path: route.path, query: { ...(route.query ?? {}) } };
const searchUrl = arrayData.store.searchUrl; const searchUrl = arrayData.store.searchUrl;
@ -104,30 +101,6 @@ const to = computed(() => {
if (searchUrl) url.query[searchUrl] = JSON.stringify(currentFilter); if (searchUrl) url.query[searchUrl] = JSON.stringify(currentFilter);
return url; return url;
}); });
// watch(
// () => filterPanel.value,
// (newValue) => {
// if (newValue) {
// // hacer algo cuando el valor esté disponible
// filterPanel.value = newValue;
// }
// },
// { immediate: true },
// );
const filterPanelRef = ref(null);
const filterPanel = ref(null);
watch(
() => filterPanelRef.value,
(newValue) => {
if (newValue) {
// hacer algo cuando el valor esté disponible
filterPanelRef.value = newValue;
}
},
{ immediate: true },
);
watch( watch(
() => props.dataKey, () => props.dataKey,
(val) => { (val) => {
@ -153,7 +126,7 @@ async function search() {
arrayData.resetPagination(); arrayData.resetPagination();
let filter = { params: { search: searchText.value } }; let filter = { params: { search: searchText.value } };
if (props.filterPanelOptions && filterPanel.value) { if (filterPanel.value) {
filterPanel.value.filterPanelRef.search(filter); filterPanel.value.filterPanelRef.search(filter);
return; return;
} }