7525-devToTest #419

Merged
alexm merged 177 commits from 7525-devToTest into test 2024-06-04 08:06:27 +00:00
2 changed files with 16 additions and 20 deletions
Showing only changes of commit 3db3d04bc9 - Show all commits

View File

@ -115,18 +115,16 @@ onMounted(async () => {
// Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla // Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla
state.set($props.model, $props.formInitialData); state.set($props.model, $props.formInitialData);
if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch();
else if (arrayData.store.data) {
state.set($props.model, arrayData.store.data);
emit('onFetch', state.get($props.model)); if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch();
} else if (arrayData.store.data) updateAndEmit(arrayData.store.data, 'onFetch');
if ($props.observeFormChanges) { if ($props.observeFormChanges) {
watch( watch(
() => formData.value, () => formData.value,
(val) => { (newVal, oldVal) => {
hasChanges.value = !isResetting.value && val; if (!oldVal) return;
hasChanges.value = !isResetting.value && newVal;
isResetting.value = false; isResetting.value = false;
}, },
{ deep: true } { deep: true }
@ -143,7 +141,7 @@ if (!$props.url)
watch(formUrl, async () => { watch(formUrl, async () => {
originalData.value = null; originalData.value = null;
reset(); reset();
fetch(); await fetch();
}); });
onBeforeRouteLeave((to, from, next) => { onBeforeRouteLeave((to, from, next) => {
@ -161,10 +159,7 @@ onBeforeRouteLeave((to, from, next) => {
onUnmounted(() => { onUnmounted(() => {
// Restauramos los datos originales en el store si se realizaron cambios en el formulario pero no se guardaron, evitando modificaciones erróneas. // Restauramos los datos originales en el store si se realizaron cambios en el formulario pero no se guardaron, evitando modificaciones erróneas.
if (hasChanges.value) { if (hasChanges.value) return state.set($props.model, originalData.value);
state.set($props.model, originalData.value);
return;
}
if ($props.clearStoreOnUnmount) state.unset($props.model); if ($props.clearStoreOnUnmount) state.unset($props.model);
}); });

View File

@ -15,10 +15,6 @@ const $props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
module: {
type: String,
required: true,
},
title: { title: {
type: String, type: String,
default: '', default: '',
@ -29,7 +25,7 @@ const $props = defineProps({
}, },
dataKey: { dataKey: {
type: String, type: String,
default: '', default: null,
}, },
summary: { summary: {
type: Object, type: Object,
@ -40,7 +36,7 @@ const $props = defineProps({
const state = useState(); const state = useState();
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
const arrayData = useArrayData($props.dataKey || $props.module, { const arrayData = useArrayData($props.dataKey || 'descriptor', {
url: $props.url, url: $props.url,
filter: $props.filter, filter: $props.filter,
skip: 0, skip: 0,
@ -51,7 +47,7 @@ const isLoading = ref(false);
defineExpose({ getData }); defineExpose({ getData });
onBeforeMount(async () => { onBeforeMount(async () => {
await getData(); if (!$props.dataKey) await getData();
watch( watch(
() => [$props.url, $props.filter], () => [$props.url, $props.filter],
async () => await getData() async () => await getData()
@ -93,7 +89,12 @@ const emit = defineEmits(['onFetch']);
{{ t('components.smartCard.openSummary') }} {{ t('components.smartCard.openSummary') }}
</QTooltip> </QTooltip>
</QBtn> </QBtn>
<RouterLink :to="{ name: `${module}Summary`, params: { id: entity.id } }"> <RouterLink
:to="{
name: `${$route.meta.moduleName}Summary`,
params: { id: entity.id },
}"
>
<QBtn <QBtn
class="link" class="link"
color="white" color="white"