perf: minor bugs detected
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2024-10-29 02:15:21 +01:00
parent 0de4dfd4f8
commit 0b2c404ab3
6 changed files with 17 additions and 21 deletions

View File

@ -73,6 +73,10 @@ const $props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
appendParams: {
type: Boolean,
default: true,
},
hasSubToolbar: { hasSubToolbar: {
type: Boolean, type: Boolean,
default: null, default: null,

View File

@ -8,7 +8,7 @@ defineProps({
<template> <template>
<div :class="$q.screen.gt.md ? 'q-pb-lg' : 'q-pb-md'"> <div :class="$q.screen.gt.md ? 'q-pb-lg' : 'q-pb-md'">
<div class="header-link" :style="{ cursor: url ? 'pointer' : 'default' }"> <div class="header-link" :style="{ cursor: url ? 'pointer' : 'default' }">
<a :href="url" :class="url ? 'link' : 'color-vn-text'"> <a :href="url" :class="url ? 'link' : 'color-vn-text'" v-bind="$attrs">
{{ text }} {{ text }}
<QIcon v-if="url" :name="icon" /> <QIcon v-if="url" :name="icon" />
</a> </a>

View File

@ -4,6 +4,7 @@ import { useRoute } from 'vue-router';
import SkeletonSummary from 'components/ui/SkeletonSummary.vue'; import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { isDialogOpened } from 'src/filters';
const props = defineProps({ const props = defineProps({
url: { url: {
@ -58,22 +59,6 @@ async function fetch() {
emit('onFetch', Array.isArray(data) ? data[0] : data); emit('onFetch', Array.isArray(data) ? data[0] : data);
isLoading.value = false; isLoading.value = false;
} }
const showRedirectToSummaryIcon = computed(() => {
const exist = existSummary(route.matched);
return !isSummary.value && route.meta.moduleName && exist;
});
function existSummary(routes) {
const hasSummary = routes.some((r) => r.name === `${route.meta.moduleName}Summary`);
if (hasSummary) return hasSummary;
for (const current of routes) {
if (current.path != '/' && current.children) {
const exist = existSummary(current.children);
if (exist) return exist;
}
}
}
</script> </script>
<template> <template>
@ -84,7 +69,7 @@ function existSummary(routes) {
<div class="summaryHeader bg-primary q-pa-sm text-weight-bolder"> <div class="summaryHeader bg-primary q-pa-sm text-weight-bolder">
<slot name="header-left"> <slot name="header-left">
<router-link <router-link
v-if="showRedirectToSummaryIcon" v-if="isDialogOpened()"
class="header link" class="header link"
:to="{ :to="{
name: `${moduleName ?? route.meta.moduleName}Summary`, name: `${moduleName ?? route.meta.moduleName}Summary`,
@ -118,6 +103,7 @@ function existSummary(routes) {
.cardSummary { .cardSummary {
width: 100%; width: 100%;
max-height: 70vh;
.summaryHeader { .summaryHeader {
text-align: center; text-align: center;
font-size: 20px; font-size: 20px;

View File

@ -3,6 +3,7 @@ import { useRouter, useRoute } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import { useArrayDataStore } from 'stores/useArrayDataStore'; import { useArrayDataStore } from 'stores/useArrayDataStore';
import { buildFilter } from 'filters/filterPanel'; import { buildFilter } from 'filters/filterPanel';
import { isDialogOpened } from 'src/filters';
const arrayDataStore = useArrayDataStore(); const arrayDataStore = useArrayDataStore();
@ -114,8 +115,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
for (const row of response.data) store.data.push(row); for (const row of response.data) store.data.push(row);
} else { } else {
store.data = response.data; store.data = response.data;
if (!document.querySelectorAll('[role="dialog"][aria-modal="true"]').length) if (!isDialogOpened()) updateRouter && updateStateParams();
updateRouter && updateStateParams();
} }
store.isLoading = false; store.isLoading = false;
@ -249,7 +249,8 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
function updateStateParams() { function updateStateParams() {
if (!route) return; if (!route) return;
const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; const newUrl = { path: route.path, query: { ...(route.query ?? {}) } };
newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter); if (store.appendParams)
newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter);
if (store.navigate) { if (store.navigate) {
const { customRouteRedirectName, searchText } = store.navigate; const { customRouteRedirectName, searchText } = store.navigate;

View File

@ -12,8 +12,10 @@ import dateRange from './dateRange';
import toHour from './toHour'; import toHour from './toHour';
import dashOrCurrency from './dashOrCurrency'; import dashOrCurrency from './dashOrCurrency';
import getParamWhere from './getParamWhere'; import getParamWhere from './getParamWhere';
import isDialogOpened from './isDialogOpened';
export { export {
isDialogOpened,
toLowerCase, toLowerCase,
toLowerCamel, toLowerCamel,
toDate, toDate,

View File

@ -0,0 +1,3 @@
export default function isDialogOpened(query = '[role="dialog"]') {
return document.querySelectorAll(query).length > 0;
}