feat(helpdesk): add domain linking, bulk actions, and revision polish to handovers

Adds domain selection (cascaded from debitor) to handover creation and edit,
bulk delete with confirmation dialog, and various UI improvements to the
handover wizard and list page. Includes migration for domain columns,
domain-select AJAX endpoint, and updated tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-16 13:21:12 +02:00
parent 03e15eaf08
commit e7c60468c9
24 changed files with 913 additions and 146 deletions

View File

@@ -132,30 +132,52 @@ class HandoverRevisionService
$restoredStatus = (string) ($revision['status'] ?? $handover['status']);
// Update the handover with restored values
$fieldValuesJson = json_encode($restoredValues, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$this->handoverRepository->updateFieldValues($tenantId, $handoverId, $fieldValuesJson, $userId);
$this->handoverRepository->beginTransaction();
try {
// Update the handover with restored values.
$fieldValuesJson = json_encode($restoredValues, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$updatedFields = $this->handoverRepository->updateFieldValues($tenantId, $handoverId, $fieldValuesJson, $userId);
if (!$updatedFields) {
throw new \RuntimeException('Failed to restore handover field values');
}
$currentStatus = (string) ($handover['status'] ?? '');
if ($restoredStatus !== $currentStatus) {
$this->handoverRepository->updateStatus($tenantId, $handoverId, $restoredStatus, $userId);
$currentStatus = (string) ($handover['status'] ?? '');
if ($restoredStatus !== $currentStatus) {
$updatedStatus = $this->handoverRepository->updateStatus($tenantId, $handoverId, $restoredStatus, $userId);
if (!$updatedStatus) {
throw new \RuntimeException('Failed to restore handover status');
}
}
// Determine schema version from current handover.
$schema = json_decode((string) ($handover['schema_snapshot'] ?? '{}'), true);
$schemaVersion = is_array($schema) ? (int) ($schema['version'] ?? 1) : 1;
// Create a new revision marking the restore.
$revisionId = $this->createRevision(
$tenantId,
$handoverId,
$restoredValues,
$restoredStatus,
$schemaVersion,
$userId,
self::CHANGE_TYPE_RESTORE
);
if ($revisionId === null) {
throw new \RuntimeException('Failed to create restore revision');
}
$this->handoverRepository->commitTransaction();
} catch (\Throwable) {
try {
$this->handoverRepository->rollbackTransaction();
} catch (\Throwable) {
// no-op
}
return ['ok' => false, 'errors' => ['general' => t('Failed to restore')]];
}
// Determine schema version from current handover
$schema = json_decode((string) ($handover['schema_snapshot'] ?? '{}'), true);
$schemaVersion = is_array($schema) ? (int) ($schema['version'] ?? 1) : 1;
// Create a new revision marking the restore
$this->createRevision(
$tenantId,
$handoverId,
$restoredValues,
$restoredStatus,
$schemaVersion,
$userId,
self::CHANGE_TYPE_RESTORE
);
return ['ok' => true, 'errors' => []];
}