fix: call upsert when crudModel haschanges

This commit is contained in:
Javier Segarra 2024-09-10 00:16:01 +02:00
parent 6de4d5f123
commit 7358dab1d0
2 changed files with 7 additions and 3 deletions

View File

@ -296,6 +296,7 @@ defineExpose({
reload, reload,
redirect: redirectFn, redirect: redirectFn,
selected, selected,
CrudModelRef,
}); });
function handleOnDataSaved(_, res) { function handleOnDataSaved(_, res) {

View File

@ -262,10 +262,13 @@ const updateMinPrice = async (value, props) => {
}); });
}; };
const upsertPrice = async ({ row }, resetMinPrice = false) => { const upsertPrice = async (props, resetMinPrice = false) => {
try { try {
if (resetMinPrice) row.hasMinPrice = 0; const { row } = props;
row = await upsertFixedPrice(row); if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) {
if (resetMinPrice) row.hasMinPrice = 0;
await upsertFixedPrice(row);
}
} catch (err) { } catch (err) {
console.error('Error editing price', err); console.error('Error editing price', err);
} }