src/app/child-dev-project/notes/deprecated/legacy-note-fields.ts

Index

Properties

Properties

definition
definition: EntitySchemaField
Type : EntitySchemaField
entityType
entityType: string
Type : string

entity type the field links; the field only makes sense in systems that have it

field
field: string
Type : string

name of the Note field

labels
labels: Record<any, string>
Type : Record<any, string>

translations of the $localize label the field had in code

import type { EntitySchemaField } from "../../../core/entity/schema/entity-schema-field";

/** languages the app has translations for (see the labels below) */
export const LABEL_LANGUAGES = ["en", "de", "fr"] as const;
export type LabelLanguage = (typeof LABEL_LANGUAGES)[number];

export interface LegacyNoteField {
  /** name of the Note field */
  field: string;
  /** entity type the field links; the field only makes sense in systems that have it */
  entityType: string;
  definition: EntitySchemaField;
  /** translations of the `$localize` label the field had in code */
  labels: Record<LabelLanguage, string>;
}

/**
 * Snapshot of the `@DatabaseField`s that used to be declared on the `Note` class
 * (in the order of the previous default `bottomForm`).
 *
 * `Note` no longer defines these in code. Systems that still rely on them have the definitions
 * written into their own `entity:Note` config by the `v4-upgrade-note-legacy-child-school-fields`
 * CLI migration, which is the only production code using this snapshot.
 *
 * (This module must stay free of runtime imports, as it is shared with the CLI -
 * see `cli/tsconfig.json`.)
 */
export const LEGACY_NOTE_FIELDS: LegacyNoteField[] = [
  {
    field: "children",
    entityType: "Child",
    definition: {
      dataType: "entity",
      isArray: true,
      additional: "Child",
      entityReferenceRole: "composite",
      editComponent: "EditLegacyAttendance",
      anonymize: "retain",
    },
    labels: { en: "Participants", de: "Teilnehmer:innen", fr: "Participants" },
  },
  {
    field: "schools",
    entityType: "School",
    definition: {
      dataType: "entity",
      isArray: true,
      additional: "School",
      entityReferenceRole: "composite",
      anonymize: "retain",
    },
    labels: { en: "Groups", de: "Gruppen", fr: "Groupes" },
  },
];

/**
 * Snapshot of the deprecated `childrenAttendance` field that used to be declared on the `Note` class.
 *
 * Unlike the link fields above this one was never shown in a view and never had a label:
 * it was edited through the `EditLegacyAttendance` component of the `children` field
 * and read by the roll-call UI of event types based on `Note`.
 *
 * Systems that still rely on it have the definition written into their own `entity:Note` config
 * by the `v4-upgrade-note-legacy-child-school-fields` CLI migration.
 */
export const LEGACY_NOTE_ATTENDANCE_FIELD: {
  field: string;
  definition: EntitySchemaField;
} = {
  field: "childrenAttendance",
  definition: {
    dataType: "event-attendance-map",
    additional: {
      participant: {
        dataType: "entity",
        additional: ["Child"],
      },
    },
    anonymize: "retain",
  },
};

results matching ""

    No results matching ""