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:
@@ -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' => []];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user