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 { onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import { useRoute, onBeforeRouteUpdate } from 'vue-router';
|
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
@ -120,13 +118,7 @@ watch(
|
||||||
() => props.url,
|
() => props.url,
|
||||||
(url) => fetch({ 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) => {
|
const addFilter = async (filter, params) => {
|
||||||
await arrayData.addFilter({ filter, params });
|
await arrayData.addFilter({ filter, params });
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,22 +33,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
|
|
||||||
if (key && userOptions) setOptions();
|
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() {
|
function setOptions() {
|
||||||
const allowedOptions = [
|
const allowedOptions = [
|
||||||
'url',
|
'url',
|
||||||
|
@ -265,6 +249,5 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
isLoading,
|
isLoading,
|
||||||
deleteOption,
|
deleteOption,
|
||||||
reset,
|
reset,
|
||||||
reloadRoute,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
@ -11,8 +11,8 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const shelvingId = ref(route.params?.id || null);
|
const entityId = computed(() => route.params.id ?? null);
|
||||||
const isNew = Boolean(!shelvingId.value);
|
const isNew = Boolean(!entityId.value);
|
||||||
const defaultInitialData = {
|
const defaultInitialData = {
|
||||||
parkingFk: null,
|
parkingFk: null,
|
||||||
priority: null,
|
priority: null,
|
||||||
|
@ -67,7 +67,7 @@ const onSave = (shelving, newShelving) => {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnSubToolbar />
|
<VnSubToolbar v-if="isNew" />
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Parkings"
|
url="Parkings"
|
||||||
:filter="parkingFilter"
|
:filter="parkingFilter"
|
||||||
|
@ -75,13 +75,13 @@ const onSave = (shelving, newShelving) => {
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FormModel
|
<FormModel
|
||||||
:url="isNew ? null : `Shelvings/${route.params?.id}`"
|
:url="isNew ? null : `Shelvings/${entityId}`"
|
||||||
:url-create="isNew ? 'Shelvings' : null"
|
:url-create="isNew ? 'Shelvings' : null"
|
||||||
:observe-form-changes="!isNew"
|
:observe-form-changes="!isNew"
|
||||||
:filter="shelvingFilter"
|
:filter="shelvingFilter"
|
||||||
model="shelving"
|
model="shelving"
|
||||||
:auto-load="!isNew"
|
:auto-load="!isNew"
|
||||||
:form-initial-data="defaultInitialData"
|
:form-initial-data="isNew ? defaultInitialData : null"
|
||||||
@on-data-saved="onSave"
|
@on-data-saved="onSave"
|
||||||
>
|
>
|
||||||
<template #form="{ data, validate, filter }">
|
<template #form="{ data, validate, filter }">
|
||||||
|
|
Loading…
Reference in New Issue