feat: unnecessary changes
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
4df52d2692
commit
2dc75db122
|
@ -2,8 +2,6 @@
|
|||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { useRoute, onBeforeRouteUpdate } from 'vue-router';
|
||||
const route = useRoute();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
|
@ -120,13 +118,7 @@ watch(
|
|||
() => props.url,
|
||||
(url) => fetch({ url })
|
||||
);
|
||||
onBeforeRouteUpdate((to, from, next) => {
|
||||
if (to.params.id !== from.params.id) {
|
||||
arrayData.reloadRoute(to.params.id);
|
||||
fetch();
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
const addFilter = async (filter, params) => {
|
||||
await arrayData.addFilter({ filter, params });
|
||||
};
|
||||
|
|
|
@ -33,22 +33,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
|||
|
||||
if (key && userOptions) setOptions();
|
||||
|
||||
function reloadRoute(newId = route.params.id) {
|
||||
if (route.path === store.url) return;
|
||||
//Así fuerzo al reinicio
|
||||
store.data = null;
|
||||
if (!store?.filter?.where) {
|
||||
//Cuando el cambio viene por VnSearchbar
|
||||
if (newId) store.url = store.url.replace(/(\d+)/, newId);
|
||||
return;
|
||||
}
|
||||
// Cuando el usuario cambia en la URL
|
||||
const keyFk = Object.keys(store.filter.where).find((key) => key.endsWith('Fk'));
|
||||
if (keyFk) {
|
||||
store.filter.where[keyFk] = newId;
|
||||
}
|
||||
}
|
||||
|
||||
function setOptions() {
|
||||
const allowedOptions = [
|
||||
'url',
|
||||
|
@ -265,6 +249,5 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
|||
isLoading,
|
||||
deleteOption,
|
||||
reset,
|
||||
reloadRoute,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
|
@ -11,8 +11,8 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
|||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const shelvingId = ref(route.params?.id || null);
|
||||
const isNew = Boolean(!shelvingId.value);
|
||||
const entityId = computed(() => route.params.id ?? null);
|
||||
const isNew = Boolean(!entityId.value);
|
||||
const defaultInitialData = {
|
||||
parkingFk: null,
|
||||
priority: null,
|
||||
|
@ -67,7 +67,7 @@ const onSave = (shelving, newShelving) => {
|
|||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnSubToolbar />
|
||||
<VnSubToolbar v-if="isNew" />
|
||||
<FetchData
|
||||
url="Parkings"
|
||||
:filter="parkingFilter"
|
||||
|
@ -75,13 +75,13 @@ const onSave = (shelving, newShelving) => {
|
|||
auto-load
|
||||
/>
|
||||
<FormModel
|
||||
:url="isNew ? null : `Shelvings/${route.params?.id}`"
|
||||
:url="isNew ? null : `Shelvings/${entityId}`"
|
||||
:url-create="isNew ? 'Shelvings' : null"
|
||||
:observe-form-changes="!isNew"
|
||||
:filter="shelvingFilter"
|
||||
model="shelving"
|
||||
:auto-load="!isNew"
|
||||
:form-initial-data="defaultInitialData"
|
||||
:form-initial-data="isNew ? defaultInitialData : null"
|
||||
@on-data-saved="onSave"
|
||||
>
|
||||
<template #form="{ data, validate, filter }">
|
||||
|
|
Loading…
Reference in New Issue