fix: send employee lookups as { id, first_name } and add Monthly allowance field
The runtime validates employee lookups against the lookup's storage
columns, so { id, name } fails with "incomplete selection" — field_51
and the other lookups go back to { id, first_name }. Also adds INIT's
new Monthly allowence field (field_73) and moves the placeholder repair
fields to field_80…field_83.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
086c397f78
commit
25a635cda3
@ -144,6 +144,8 @@ export const ASSET_FIELDS = [
|
|||||||
},
|
},
|
||||||
{ id: 'field_59', label: 'Asset Brand', type: 'text' },
|
{ id: 'field_59', label: 'Asset Brand', type: 'text' },
|
||||||
{ id: 'field_61', label: 'Asset Location', 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. */
|
/** 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
|
* "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 }
|
* data". Sent as { id, first_name } — see employeeLookup.
|
||||||
* because the runtime checks lookups against their storage columns.
|
|
||||||
*/
|
*/
|
||||||
export const ASSET_OWNER_FIELD = 'field_51'
|
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
|
* "Employee data": a lookup into the employee table, sent as { id, first_name }
|
||||||
* against the lookup's storage columns (a Retired attempt failed with
|
* like every employee lookup (see employeeLookup). It is picked from a list
|
||||||
* "missing required storage column 'first_name'"), so it carries
|
* of active employees, so it is sent alongside the form data.
|
||||||
* { 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.
|
|
||||||
*/
|
*/
|
||||||
export const ASSIGN_EMPLOYEE_FIELD = 'field_22'
|
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". */
|
/** "Last owner": a lookup into the employee table, like "Employee data". */
|
||||||
export const LOST_EMPLOYEE_FIELD = 'field_35'
|
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.
|
* Run a later activity (ASSIGNED, RETURNED, …) on an existing asset instance.
|
||||||
@ -584,21 +592,23 @@ const EDITED_FIELDS = [
|
|||||||
* with the asset's instance_id.
|
* with the asset's instance_id.
|
||||||
*
|
*
|
||||||
* POST {APP_API_BASE_URL}/app/{APP_ID}/activity
|
* 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 } }
|
* { activity_id, workflow_uuid, instance_id, data: { field_77 … field_79 } }
|
||||||
*
|
*
|
||||||
* PLACEHOLDER ids: add an "Under Repair" state and these two activities, with
|
* 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
|
* 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'
|
export const ASSET_REPAIR_ACTIVITY_ID = 'TODO-send-for-repair-activity-id'
|
||||||
|
|
||||||
/** Send for Repair fields. */
|
/** Send for Repair fields. */
|
||||||
export const ASSET_REPAIR_FIELDS = [
|
export const ASSET_REPAIR_FIELDS = [
|
||||||
{ id: 'field_73', label: 'Repair date', type: 'date' },
|
{ id: 'field_80', label: 'Repair date', type: 'date' },
|
||||||
{ id: 'field_74', label: 'Issue details', type: 'longtext' },
|
{ id: 'field_81', label: 'Issue details', type: 'longtext' },
|
||||||
{ id: 'field_75', label: 'Repair vendor', type: 'text' },
|
{ id: 'field_82', label: 'Repair vendor', type: 'text' },
|
||||||
{ id: 'field_76', label: 'Estimated cost', type: 'number' },
|
{ id: 'field_83', label: 'Estimated cost', type: 'number' },
|
||||||
]
|
]
|
||||||
|
|
||||||
export const ASSET_REPAIRED_ACTIVITY_ID = 'TODO-repair-completed-activity-id'
|
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(
|
add(
|
||||||
HISTORY_ACTION.REPAIR,
|
HISTORY_ACTION.REPAIR,
|
||||||
val('field_73'),
|
val('field_80'),
|
||||||
'',
|
'',
|
||||||
joinParts(val('field_75'), present(val('field_76')) && `Estimate ${val('field_76')}`),
|
joinParts(val('field_82'), present(val('field_83')) && `Estimate ${val('field_83')}`),
|
||||||
val('field_74'),
|
val('field_81'),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user