0
0
Fork 0

deploy: test to dev

This commit is contained in:
Alex Moreno 2024-06-06 12:24:08 +02:00
commit 985ce9a643
2 changed files with 9 additions and 9 deletions

View File

@ -117,7 +117,7 @@ onMounted(async () => {
state.set($props.model, $props.formInitialData);
if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch();
else if (arrayData.store.data) updateAndEmit(arrayData.store.data, 'onFetch');
else if (arrayData.store.data) updateAndEmit('onFetch', arrayData.store.data);
if ($props.observeFormChanges) {
watch(
@ -137,7 +137,7 @@ onMounted(async () => {
if (!$props.url)
watch(
() => arrayData.store.data,
(val) => updateAndEmit(val, 'onFetch')
(val) => updateAndEmit('onFetch', val)
);
watch(formUrl, async () => {
@ -172,8 +172,8 @@ async function fetch() {
});
if (Array.isArray(data)) data = data[0] ?? {};
updateAndEmit(data, 'onFetch');
} catch (error) {
updateAndEmit('onFetch', data);
} catch (e) {
state.set($props.model, {});
originalData.value = {};
}
@ -196,7 +196,7 @@ async function save() {
if ($props.urlCreate) notify('globals.dataCreated', 'positive');
updateAndEmit(response?.data, 'onDataSaved');
updateAndEmit('onDataSaved', formData.value, response?.data);
} catch (err) {
console.error(err);
notify('errors.writeRequest', 'negative');
@ -212,7 +212,7 @@ async function saveAndGo() {
}
function reset() {
updateAndEmit(originalData.value, 'onFetch');
updateAndEmit('onFetch', originalData.value);
if ($props.observeFormChanges) {
hasChanges.value = false;
isResetting.value = true;
@ -234,12 +234,12 @@ function filter(value, update, filterOptions) {
);
}
function updateAndEmit(val, evt) {
function updateAndEmit(evt, val, res) {
state.set($props.model, val);
originalData.value = val && JSON.parse(JSON.stringify(val));
if (!$props.url) arrayData.store.data = val;
emit(evt, state.get($props.model));
emit(evt, state.get($props.model), res);
}
defineExpose({ save, isLoading, hasChanges });

View File

@ -29,7 +29,7 @@ const newInvoiceIn = reactive({
const suppliersOptions = ref([]);
const companiesOptions = ref([]);
const redirectToInvoiceInBasicData = ({ id }) => {
const redirectToInvoiceInBasicData = (__, { id }) => {
router.push({ name: 'InvoiceInBasicData', params: { id } });
};
</script>