diff --git a/src/api/assets.js b/src/api/assets.js index f39a966..75ab09d 100644 --- a/src/api/assets.js +++ b/src/api/assets.js @@ -144,6 +144,8 @@ export const ASSET_FIELDS = [ }, { id: 'field_59', label: 'Asset Brand', type: 'text' }, { id: 'field_61', label: 'Asset Location', type: 'text' }, + // `label` keeps the builder's spelling; `formLabel` is what the app shows. + { id: 'field_73', label: 'Monthly allowence', formLabel: 'Monthly allowance', type: 'number' }, ] /** INIT's photo field, whose uploads the runtime always accepts. */ @@ -190,8 +192,7 @@ export const fetchAssetActivityFieldDefs = (activityId) => /** * "Asset Owner": a lookup into the employee table, like ASSIGNED's "Employee - * data". The API sample shows only { id }; it is sent as { id, first_name } - * because the runtime checks lookups against their storage columns. + * data". Sent as { id, first_name } — see employeeLookup. */ export const ASSET_OWNER_FIELD = 'field_51' @@ -264,11 +265,9 @@ export const ASSET_ASSIGN_FIELDS = [ ] /** - * "Employee data": a lookup into the employee table. The runtime checks it - * against the lookup's storage columns (a Retired attempt failed with - * "missing required storage column 'first_name'"), so it carries - * { id, first_name }, not the { id, name } the API sample shows. It is picked - * from a list of active employees, so it is sent alongside the form data. + * "Employee data": a lookup into the employee table, sent as { id, first_name } + * like every employee lookup (see employeeLookup). It is picked from a list + * of active employees, so it is sent alongside the form data. */ export const ASSIGN_EMPLOYEE_FIELD = 'field_22' @@ -439,8 +438,17 @@ export const ASSET_LOST_FIELDS = [ /** "Last owner": a lookup into the employee table, like "Employee data". */ export const LOST_EMPLOYEE_FIELD = 'field_35' -/** An employee lookup value, in the shape the runtime validates. */ -const employeeLookup = (employee) => ({ id: employee.id, first_name: employee.first_name }) +/** + * An employee lookup value, in the shape the runtime validates: { id, + * first_name }, the lookup's storage columns. The employee table has no "name" + * column, so { id, name } fails with "… has an incomplete selection" + * (invalid_type), and omitting first_name fails with "missing required + * storage column 'first_name'". + */ +const employeeLookup = (employee) => ({ + id: employee.id, + first_name: employee.first_name || employee.name, +}) /** * Run a later activity (ASSIGNED, RETURNED, …) on an existing asset instance. @@ -584,21 +592,23 @@ const EDITED_FIELDS = [ * with the asset's instance_id. * * POST {APP_API_BASE_URL}/app/{APP_ID}/activity - * { activity_id, workflow_uuid, instance_id, data: { field_73 … field_76 } } + * { activity_id, workflow_uuid, instance_id, data: { field_80 … field_83 } } * { activity_id, workflow_uuid, instance_id, data: { field_77 … field_79 } } * * PLACEHOLDER ids: add an "Under Repair" state and these two activities, with * these fields, in the Zino builder, deploy, and put their ids here. Until - * then, running them fails. + * then, running them fails. (The send fields were field_73 … field_76, but the + * builder has since given field_73 to INIT's "Monthly allowence", so they + * moved to field_80 …; match whatever ids the builder assigns when adding.) */ export const ASSET_REPAIR_ACTIVITY_ID = 'TODO-send-for-repair-activity-id' /** Send for Repair fields. */ export const ASSET_REPAIR_FIELDS = [ - { id: 'field_73', label: 'Repair date', type: 'date' }, - { id: 'field_74', label: 'Issue details', type: 'longtext' }, - { id: 'field_75', label: 'Repair vendor', type: 'text' }, - { id: 'field_76', label: 'Estimated cost', type: 'number' }, + { id: 'field_80', label: 'Repair date', type: 'date' }, + { id: 'field_81', label: 'Issue details', type: 'longtext' }, + { id: 'field_82', label: 'Repair vendor', type: 'text' }, + { id: 'field_83', label: 'Estimated cost', type: 'number' }, ] export const ASSET_REPAIRED_ACTIVITY_ID = 'TODO-repair-completed-activity-id' @@ -1670,13 +1680,13 @@ export function assetEvents(config, row) { ) } - if (present(val('field_73'))) { + if (present(val('field_80'))) { add( HISTORY_ACTION.REPAIR, - val('field_73'), + val('field_80'), '', - joinParts(val('field_75'), present(val('field_76')) && `Estimate ${val('field_76')}`), - val('field_74'), + joinParts(val('field_82'), present(val('field_83')) && `Estimate ${val('field_83')}`), + val('field_81'), ) }