#7897 - masterTest_24_36 #669

Merged
jsegarra merged 115 commits from 7897_masterTest_24_36 into master 2024-09-03 06:37:49 +00:00
1 changed files with 13 additions and 0 deletions
Showing only changes of commit fa0ca732fc - Show all commits

View File

@ -87,6 +87,10 @@ const $props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
defaultTrim: {
type: Boolean,
default: true,
},
}); });
const emit = defineEmits(['onFetch', 'onDataSaved']); const emit = defineEmits(['onFetch', 'onDataSaved']);
const modelValue = computed( const modelValue = computed(
@ -195,6 +199,7 @@ async function save() {
isLoading.value = true; isLoading.value = true;
try { try {
formData.value = trimData(formData.value);
const body = $props.mapper ? $props.mapper(formData.value) : formData.value; const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
const method = $props.urlCreate ? 'post' : 'patch'; const method = $props.urlCreate ? 'post' : 'patch';
const url = const url =
@ -253,6 +258,14 @@ function updateAndEmit(evt, val, res) {
emit(evt, state.get(modelValue), 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({ defineExpose({
save, save,
isLoading, isLoading,