Add support for selfserve_enabled lanes and synchronize behavior across tasks, sessions, and projections

- Introduced `selfserve_enabled` property for `department_lanes` with schema update, object properties, and associated methods/tests.
- Enhanced `selfserve_wash_flow` and session logic to respect lane self-serve settings, including block handling and task filtering.
- Updated API routes and Studio Graph projections to include `selfserve_enabled` in payloads and progress callbacks.
- Added unit tests for session statuses, lane configuration, and blocking behavior due to disabled self-serve settings.
This commit is contained in:
Jeppe Bundgaard
2026-04-29 17:28:42 +02:00
parent 5875371d13
commit 8bf957b273
18 changed files with 924 additions and 101 deletions
@@ -60,6 +60,7 @@ class departmentLanesRoute
'relay_machine_cleaner_id',
'dynamic_image_id',
'machine_type_id',
'selfserve_enabled',
])
->listObjectsWithPaginationIfSet(
function ($department_lane) use ($user) {
@@ -317,6 +318,9 @@ class departmentLanesRoute
$dynamic_image_id = $response->getRequestParameter('dynamic_image_id') ?? null;
$machine_type_id = $response->getRequestParameter('machine_type_id') ?? null;
$selfserve_enabled = self::isParametersSet(['selfserve_enabled'])
? department_lanes_o::normalizeSelfServeEnabledValue($response->getRequestParameter('selfserve_enabled'))
: true;
if ($dynamic_image_id !== null) {
$did = (int)$dynamic_image_id;
$this->requireType($did, $this->type_int());
@@ -333,9 +337,12 @@ class departmentLanesRoute
// Check if the required fields are set
if ($name && $department) {
// Add the department lane
(new department_lanes_o())->add((int)$department, (string)$name, $relay_in_id, $relay_out_id, $relay_machine_id, $relay_machine_program_picker_id, $relay_machine_cleaner_id, $dynamic_image_id, $machine_type_id);
$created_lane = (new department_lanes_o())->add((int)$department, (string)$name, $relay_in_id, $relay_out_id, $relay_machine_id, $relay_machine_program_picker_id, $relay_machine_cleaner_id, $dynamic_image_id, $machine_type_id, $selfserve_enabled);
// Return a success message
$response->success('Department lane added');
$response->success([
'message' => 'Department lane added',
'lane' => $created_lane->asArray(),
]);
} else {
// Return an error
$response->error('Missing required fields', 400);
@@ -385,6 +392,7 @@ class departmentLanesRoute
// Return an error
$response->error('Department lane not found', 404);
}
$was_selfserve_enabled = $department_lane->isSelfServeEnabled();
// Update the department lane fields that are set
if (self::isParametersSet(['name'])) {
$department_lane->name->set($name);
@@ -429,8 +437,18 @@ class departmentLanesRoute
$department_lane->machine_type_id->set($machineTypeId);
}
}
if (self::isParametersSet(['selfserve_enabled'])) {
$next_selfserve_enabled = department_lanes_o::normalizeSelfServeEnabledValue($response->getRequestParameter('selfserve_enabled'));
$department_lane->selfserve_enabled->set($next_selfserve_enabled);
if ($was_selfserve_enabled && !$next_selfserve_enabled) {
department_lanes_o::disableSelfServeRelaysBestEffort((int)$department_lane->id);
}
}
// Return a success message
$response->success('Department lane updated');
$response->success([
'message' => 'Department lane updated',
'lane' => $department_lane->asArray(),
]);
} else {
// Log the incident
(new logs_o())->add('department_lanes', 'global', 1, 0, 'EDIT_DEPARTMENT_LANE', 'User tried to edit a department lane without being logged in');