fix: version 4.2.2 -- Equipos ya no da falso conflicto al guardar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,10 @@ function SimpleTable({ columns, rows, empty }) {
|
||||
);
|
||||
}
|
||||
|
||||
// Valores editables del equipo; el mismo formato para `initial` y para `fetchCurrent` (incluida
|
||||
// editVersion: si falta en uno de los dos, las huellas nunca coinciden y todo guardado da conflicto).
|
||||
const toForm = (d) => ({ status: d.status, assignedUserId: d.assigned_user_id || '', departmentId: d.department_id || '', notes: d.notes || '', editVersion: d.edit_version });
|
||||
|
||||
function DeviceDetail({ id, onClose, onChanged, canEdit, tab = 'general', onTabChange }) {
|
||||
const { t, pushToast } = useUi();
|
||||
const runAction = useAction();
|
||||
@@ -69,7 +73,7 @@ function DeviceDetail({ id, onClose, onChanged, canEdit, tab = 'general', onTabC
|
||||
// Borrador de los datos editables del equipo (estado, asignado, departamento, notas).
|
||||
const draft = useDraftForm({
|
||||
formId: 'device-edit', entityId: id,
|
||||
initial: device ? { status: device.status, assignedUserId: device.assigned_user_id || '', departmentId: device.department_id || '', notes: device.notes || '', editVersion: device.edit_version } : {},
|
||||
initial: device ? toForm(device) : {},
|
||||
label: `${t('eq_detail')}: ${device?.hostname || id}`, enabled: !!device && canEdit && tab === 'general', onDiscard: () => setEditing(false),
|
||||
});
|
||||
const form = draft.values;
|
||||
@@ -99,7 +103,7 @@ function DeviceDetail({ id, onClose, onChanged, canEdit, tab = 'general', onTabC
|
||||
await reload();
|
||||
onChanged();
|
||||
pushToast({ tone: 'success', message: t('common_saved') });
|
||||
}), { fetchCurrent: async () => { const d = await getDevice(id); return { status: d.status, assignedUserId: d.assigned_user_id || '', departmentId: d.department_id || '', notes: d.notes || '' }; } });
|
||||
}), { fetchCurrent: async () => toForm(await getDevice(id)) });
|
||||
}
|
||||
|
||||
if (!device) return <div className="text-muted">{t('common_loading')}</div>;
|
||||
|
||||
Reference in New Issue
Block a user