0
0
Fork 0

Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 7353-fineTunningMonitor

This commit is contained in:
Jorge Penadés 2024-08-16 15:18:20 +02:00
commit 1cca504c87
1 changed files with 13 additions and 0 deletions

View File

@ -87,6 +87,10 @@ const $props = defineProps({
type: Boolean,
default: false,
},
defaultTrim: {
type: Boolean,
default: true,
},
});
const emit = defineEmits(['onFetch', 'onDataSaved']);
const modelValue = computed(
@ -195,6 +199,7 @@ async function save() {
isLoading.value = true;
try {
formData.value = trimData(formData.value);
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
const method = $props.urlCreate ? 'post' : 'patch';
const url =
@ -253,6 +258,14 @@ function updateAndEmit(evt, val, res) {
emit(evt, state.get(modelValue), res);
}
function trimData(data) {
if (!$props.defaultTrim) return data;
for (const key in data) {
if (typeof data[key] == 'string') data[key] = data[key].trim();
}
return data;
}
defineExpose({
save,
isLoading,