fix: refs #6480 fix workerCard
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-04-23 12:00:29 +02:00
parent 54f9cf36c2
commit f9a88ea8c2
4 changed files with 27 additions and 16 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { onBeforeMount } from 'vue'; import { onBeforeMount, computed } from 'vue';
import { useRoute, onBeforeRouteUpdate } from 'vue-router'; import { useRoute, onBeforeRouteUpdate } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
@ -11,8 +11,9 @@ import LeftMenu from 'components/LeftMenu.vue';
const props = defineProps({ const props = defineProps({
dataKey: { type: String, required: true }, dataKey: { type: String, required: true },
baseUrl: { type: String, required: true }, baseUrl: { type: String, default: undefined },
filter: { type: Object, default: undefined }, customUrl: { type: String, default: undefined },
filter: { type: Object, default: () => {} },
descriptor: { type: Object, required: true }, descriptor: { type: Object, required: true },
searchbarDataKey: { type: String, default: undefined }, searchbarDataKey: { type: String, default: undefined },
searchbarUrl: { type: String, default: undefined }, searchbarUrl: { type: String, default: undefined },
@ -23,20 +24,29 @@ const props = defineProps({
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const stateStore = useStateStore();
const route = useRoute(); const route = useRoute();
const url = computed(() => {
if (props.baseUrl) return `${props.baseUrl}/${route.params.id}`;
return props.customUrl;
});
const arrayData = useArrayData(props.dataKey, { const arrayData = useArrayData(props.dataKey, {
url: `${props.baseUrl}/${route.params.id}`, url: url.value,
filter: props.filter, filter: props.filter,
}); });
onBeforeMount(async () => await arrayData.fetch({ append: false })); onBeforeMount(async () => {
await arrayData.fetch({ append: false });
onBeforeRouteUpdate(async (to, from) => { arrayData.store.filter.where = { id: route.params.id };
if (to.params.id !== from.params.id) {
arrayData.store.url = `${props.baseUrl}/${route.params.id}`;
await arrayData.fetch({ append: false });
}
}); });
if (props.baseUrl) {
onBeforeRouteUpdate(async (to, from) => {
if (to.params.id !== from.params.id) {
arrayData.store.url = `${props.baseUrl}/${route.params.id}`;
await arrayData.fetch({ append: false });
}
});
}
</script> </script>
<template> <template>
<Teleport <Teleport

View File

@ -4,7 +4,6 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue'; import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
@ -28,7 +27,6 @@ const filter = {
@on-fetch="(data) => (sectors = data)" @on-fetch="(data) => (sectors = data)"
auto-load auto-load
/> />
<VnSubToolbar />
<FormModel :url="`Parkings/${parkingId}`" model="parking" :filter="filter" auto-load> <FormModel :url="`Parkings/${parkingId}`" model="parking" :filter="filter" auto-load>
<template #form="{ data }"> <template #form="{ data }">
<VnRow> <VnRow>

View File

@ -91,8 +91,8 @@ async function changeState(value) {
> >
<template #header="{ entity }"> <template #header="{ entity }">
<div> <div>
Ticket #{{ entity.id }} - {{ entity.client.name }} ({{ Ticket #{{ entity.id }} - {{ entity.client?.name }} ({{
entity.client.id entity.client?.id
}}) - }}) -
{{ entity.nickname }} {{ entity.nickname }}
</div> </div>

View File

@ -1,12 +1,15 @@
<script setup> <script setup>
import VnCard from 'components/common/VnCard.vue'; import VnCard from 'components/common/VnCard.vue';
import WorkerDescriptor from './WorkerDescriptor.vue'; import WorkerDescriptor from './WorkerDescriptor.vue';
const filter = { where: {} };
</script> </script>
<template> <template>
<VnCard <VnCard
data-key="Worker" data-key="Worker"
base-url="Workers" custom-url="Workers/Summary"
:descriptor="WorkerDescriptor" :descriptor="WorkerDescriptor"
:filter="filter"
searchbar-data-key="WorkerList" searchbar-data-key="WorkerList"
searchbar-url="Workers/filter" searchbar-url="Workers/filter"
searchbar-label="Search worker" searchbar-label="Search worker"