0
0
Fork 0

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,
redirect: redirectFn,
selected,
CrudModelRef,
});
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 {
if (resetMinPrice) row.hasMinPrice = 0;
row = await upsertFixedPrice(row);
const { row } = props;
if (tableRef.value.CrudModelRef.getChanges().updates.length > 0) {
if (resetMinPrice) row.hasMinPrice = 0;
await upsertFixedPrice(row);
}
} catch (err) {
console.error('Error editing price', err);
}