From b7f7d7e79344296caf95b68181d3a1ccdbee432f Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 14 Sep 2026 06:42:52 +0000 Subject: [PATCH] Update --- backend/src/index.ts | 32 ++++++++++++++++++++++++--- frontend/src/views/ZammadSyncPage.tsx | 32 ++++++++++++++++++++++++--- scripts/install-local-dependencies.sh | 0 3 files changed, 58 insertions(+), 6 deletions(-) mode change 100644 => 100755 scripts/install-local-dependencies.sh diff --git a/backend/src/index.ts b/backend/src/index.ts index 094b4ae..d653ddd 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1868,12 +1868,38 @@ function syncComparableValue(value: unknown) { return value ?? null; } -function syncValueChanged(left: unknown, right: unknown) { - return JSON.stringify(syncComparableValue(left)) !== JSON.stringify(syncComparableValue(right)); +function syncIdComparableValue(value: unknown) { + const comparable = syncComparableValue(value); + + if (typeof comparable === "number" && Number.isInteger(comparable)) { + return String(comparable); + } + + if (typeof comparable === "bigint") { + return comparable.toString(); + } + + if (typeof comparable === "string" && /^\d+$/.test(comparable.trim())) { + return comparable.trim().replace(/^0+(?=\d)/, ""); + } + + return comparable; +} + +function syncComparableValueForField(field: string, value: unknown) { + if (field === "Organisation") { + return syncIdComparableValue(value); + } + + return syncComparableValue(value); +} + +function syncValueChanged(field: string, left: unknown, right: unknown) { + return JSON.stringify(syncComparableValueForField(field, left)) !== JSON.stringify(syncComparableValueForField(field, right)); } function addSyncChange(changes: ZammadSyncChange[], field: string, from: unknown, to: unknown) { - if (syncValueChanged(from, to)) { + if (syncValueChanged(field, from, to)) { changes.push({ field, from: syncComparableValue(from), to: syncComparableValue(to) }); } } diff --git a/frontend/src/views/ZammadSyncPage.tsx b/frontend/src/views/ZammadSyncPage.tsx index 6c202ec..105e87a 100644 --- a/frontend/src/views/ZammadSyncPage.tsx +++ b/frontend/src/views/ZammadSyncPage.tsx @@ -298,12 +298,38 @@ function comparablePreviewValue(value: unknown) { return value ?? null; } -function cachedValueChanged(left: unknown, right: unknown) { - return JSON.stringify(comparablePreviewValue(left)) !== JSON.stringify(comparablePreviewValue(right)); +function comparablePreviewIdValue(value: unknown) { + const comparable = comparablePreviewValue(value); + + if (typeof comparable === "number" && Number.isInteger(comparable)) { + return String(comparable); + } + + if (typeof comparable === "bigint") { + return comparable.toString(); + } + + if (typeof comparable === "string" && /^\d+$/.test(comparable.trim())) { + return comparable.trim().replace(/^0+(?=\d)/, ""); + } + + return comparable; +} + +function comparablePreviewValueForField(field: string, value: unknown) { + if (field === "Organisation") { + return comparablePreviewIdValue(value); + } + + return comparablePreviewValue(value); +} + +function cachedValueChanged(field: string, left: unknown, right: unknown) { + return JSON.stringify(comparablePreviewValueForField(field, left)) !== JSON.stringify(comparablePreviewValueForField(field, right)); } function addCachedChange(changes: ZammadSyncChange[], field: string, from: unknown, to: unknown) { - if (cachedValueChanged(from, to)) { + if (cachedValueChanged(field, from, to)) { changes.push({ field, from: comparablePreviewValue(from), to: comparablePreviewValue(to) }); } } diff --git a/scripts/install-local-dependencies.sh b/scripts/install-local-dependencies.sh old mode 100644 new mode 100755