fix: show Update values on the employee details page
The Update activity maps its fields into the employees table, but the detail view and workflow record view return only the INIT values, so the details page showed old data after an Update. Read the employee's table row and use its values for the Update fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5b55bd267b
commit
c0749f50e4
@ -223,6 +223,22 @@ export async function fetchEmployeeInstance(instanceId) {
|
||||
return rows.find((r) => String(r.instance_id) === String(instanceId)) || null
|
||||
}
|
||||
|
||||
/**
|
||||
* An employee-table row's values under the Update field ids. Update maps every
|
||||
* field into the table, so the row holds what was last saved even though the
|
||||
* workflow views return only the INIT fields.
|
||||
*/
|
||||
function updateValuesFromTable(row) {
|
||||
if (!row) return {}
|
||||
const byLabel = new Map(Object.entries(row).map(([k, v]) => [normLabel(k), v]))
|
||||
const out = {}
|
||||
for (const f of EMPLOYEE_UPDATE_FIELDS) {
|
||||
const v = byLabel.get(normLabel(f.label))
|
||||
if (v !== undefined && v !== null && v !== '') out[f.id] = v
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the latest saved values on the details page.
|
||||
*
|
||||
@ -242,7 +258,13 @@ export async function withLatestInstanceValues(view, instanceId) {
|
||||
}
|
||||
if (!instance) return view
|
||||
|
||||
const record = { ...view.record, ...instance }
|
||||
let tableRow = null
|
||||
try {
|
||||
tableRow = await fetchEmployeeTableRow(instance)
|
||||
} catch {
|
||||
// Keep the instance values.
|
||||
}
|
||||
const record = { ...view.record, ...instance, ...updateValuesFromTable(tableRow) }
|
||||
const latest = new Map(
|
||||
[...latestByLabel(ALL_EMPLOYEE_FIELDS, record)].map(([label, v]) => [normLabel(label), v]),
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user