diff --git a/src/i18n/locales/de/common.json b/src/i18n/locales/de/common.json index b70ef46a..8cd74d91 100644 --- a/src/i18n/locales/de/common.json +++ b/src/i18n/locales/de/common.json @@ -260,6 +260,7 @@ "SHARED": { "ACTUAL": "Aktuell", "ACTUAL-TIME": "Tatsächliche Zeit", + "TBD": "Wird geklärt", "AIRPORT_CHANGE": "Wechsel des Flughafens", "ALL_DAY": "Ganztägig", "ALL_DIRECTIONS": "All directions", diff --git a/src/i18n/locales/en/common.json b/src/i18n/locales/en/common.json index 7acc2af1..439d7bfa 100644 --- a/src/i18n/locales/en/common.json +++ b/src/i18n/locales/en/common.json @@ -299,6 +299,7 @@ "SHARED": { "ACTUAL": "Actual", "ACTUAL-TIME": "Actual Time", + "TBD": "Pending", "AIRPORT_CHANGE": "Different airports", "ALL_DAY": "All day", "ALL_DIRECTIONS": "All directions", diff --git a/src/i18n/locales/es/common.json b/src/i18n/locales/es/common.json index 84396df7..026eae43 100644 --- a/src/i18n/locales/es/common.json +++ b/src/i18n/locales/es/common.json @@ -260,6 +260,7 @@ "SHARED": { "ACTUAL": "Real", "ACTUAL-TIME": "Hora real", + "TBD": "Por especificar", "AIRPORT_CHANGE": "Aeropuertos diferentes", "ALL_DAY": "Todo el día", "ALL_DIRECTIONS": "All directions", diff --git a/src/i18n/locales/fr/common.json b/src/i18n/locales/fr/common.json index db04583f..06b76000 100644 --- a/src/i18n/locales/fr/common.json +++ b/src/i18n/locales/fr/common.json @@ -260,6 +260,7 @@ "SHARED": { "ACTUAL": "Réelle", "ACTUAL-TIME": "Heure réelle", + "TBD": "À clarifier", "AIRPORT_CHANGE": "Aéroports différents", "ALL_DAY": "Toute la journée", "ALL_DIRECTIONS": "All directions", diff --git a/src/i18n/locales/it/common.json b/src/i18n/locales/it/common.json index 6a67bef8..f862db6a 100644 --- a/src/i18n/locales/it/common.json +++ b/src/i18n/locales/it/common.json @@ -260,6 +260,7 @@ "SHARED": { "ACTUAL": "Effettivo", "ACTUAL-TIME": "Ora effettiva", + "TBD": "Da chiarire", "AIRPORT_CHANGE": "Aeroporti diversi", "ALL_DAY": "Tutto il giorno", "ALL_DIRECTIONS": "All directions", diff --git a/src/i18n/locales/ja/common.json b/src/i18n/locales/ja/common.json index 5f789bdd..10f95ee4 100644 --- a/src/i18n/locales/ja/common.json +++ b/src/i18n/locales/ja/common.json @@ -260,6 +260,7 @@ "SHARED": { "ACTUAL": "実際", "ACTUAL-TIME": "実際の時間", + "TBD": "確認中", "AIRPORT_CHANGE": "別の空港", "ALL_DAY": "終日", "ALL_DIRECTIONS": "All directions", diff --git a/src/i18n/locales/ko/common.json b/src/i18n/locales/ko/common.json index 357c2c2a..6393c060 100644 --- a/src/i18n/locales/ko/common.json +++ b/src/i18n/locales/ko/common.json @@ -260,6 +260,7 @@ "SHARED": { "ACTUAL": "실제", "ACTUAL-TIME": "실제 시간", + "TBD": "확인 중", "AIRPORT_CHANGE": "다른 공항", "ALL_DAY": "전체", "ALL_DIRECTIONS": "All directions", diff --git a/src/i18n/locales/ru/common.json b/src/i18n/locales/ru/common.json index 0f5ba6ef..36b02a7a 100644 --- a/src/i18n/locales/ru/common.json +++ b/src/i18n/locales/ru/common.json @@ -299,6 +299,7 @@ "SHARED": { "ACTUAL": "Фактическое", "ACTUAL-TIME": "Фактическое время", + "TBD": "Уточняется", "AIRPORT_CHANGE": "Смена аэропорта", "ALL_DAY": "Весь день", "ALL_DIRECTIONS": "Все направления", diff --git a/src/i18n/locales/zh/common.json b/src/i18n/locales/zh/common.json index 126d25d2..939a5d6e 100644 --- a/src/i18n/locales/zh/common.json +++ b/src/i18n/locales/zh/common.json @@ -260,6 +260,7 @@ "SHARED": { "ACTUAL": "实际", "ACTUAL-TIME": "实际时间", + "TBD": "待确定", "AIRPORT_CHANGE": "不同机场", "ALL_DAY": "全天", "ALL_DIRECTIONS": "All directions", diff --git a/src/shared/tbd.test.ts b/src/shared/tbd.test.ts new file mode 100644 index 00000000..b83ad492 --- /dev/null +++ b/src/shared/tbd.test.ts @@ -0,0 +1,39 @@ +import { describe, expect, it } from "vitest"; +import { tbdOr } from "./tbd.js"; + +describe("4.1.23-R: tbdOr fallback", () => { + const t = (k: string) => (k === "SHARED.TBD" ? "Уточняется" : k); + + it("returns TBD string for null", () => { + expect(tbdOr(null, t)).toBe("Уточняется"); + }); + + it("returns TBD string for undefined", () => { + expect(tbdOr(undefined, t)).toBe("Уточняется"); + }); + + it("returns TBD string for empty string", () => { + expect(tbdOr("", t)).toBe("Уточняется"); + }); + + it("returns TBD string for whitespace-only string", () => { + expect(tbdOr(" ", t)).toBe("Уточняется"); + }); + + it("returns the value when non-empty string", () => { + expect(tbdOr("A320", t)).toBe("A320"); + }); + + it("returns numeric value as-is", () => { + expect(tbdOr(42, t)).toBe(42); + }); + + it("returns non-string non-number values as-is", () => { + const obj = { code: "MOW" }; + expect(tbdOr(obj, t)).toBe(obj); + }); + + it("returns 0 as-is (not treated as missing)", () => { + expect(tbdOr(0, t)).toBe(0); + }); +}); diff --git a/src/shared/tbd.ts b/src/shared/tbd.ts new file mode 100644 index 00000000..5998b417 --- /dev/null +++ b/src/shared/tbd.ts @@ -0,0 +1,26 @@ +/** + * "Уточняется" fallback per TZ §4.1.23. + * + * When a field is null / undefined / empty string / whitespace, returns + * the localized "Уточняется" label. Otherwise returns the value as-is. + * + * NOTE: Only apply to fields TZ explicitly enumerates for this fallback + * (gate, terminal, aircraft type, bag belt, dispatch type, etc.). Don't + * use as a blanket fallback for all nullable fields — Angular reference + * uses dashes/absent rendering for fields not listed in §4.1.23. + * + * Styling: callers are responsible for applying the orange color class + * (`.tbd-text` or equivalent) when rendering the fallback string. + */ + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type TFunction = (key: string, opts?: any) => string; + +export function tbdOr( + value: T | null | undefined, + t: TFunction, +): T | string { + if (value === null || value === undefined) return t("SHARED.TBD"); + if (typeof value === "string" && value.trim() === "") return t("SHARED.TBD"); + return value; +} diff --git a/src/styles/_common.scss b/src/styles/_common.scss index c783e707..f898addd 100644 --- a/src/styles/_common.scss +++ b/src/styles/_common.scss @@ -45,3 +45,8 @@ .wrapper-header { z-index: 1002; } + +// TZ §4.1.23: "Уточняется" fallback label styling (orange color) +.tbd-text { + color: $orange; +}