Screens

Feature flags

New features are switched per flag; with all flags off a tool behaves like the version it replaces. In the viewer the panel «Funktionen» switches them (remembered per browser); ?flags=a,b in a link turns them on for the person opening it. In the product the platform evaluates them per club (ARCHITECTURE.md §5). Defined in flags.json; screens ask { "$flag": "id" }.

FlagToolWhat it addsDefaultTry it
Warnung bei wartenden Anfragen
anfragen.overdue-warning
anfragenÜber dem Posteingang ein Hinweis, wenn eine Anfrage länger als 4 Tage wartet, mit Link zur Antwort.off · proposalonly this one
Wischen: übernehmen oder erledigen
anfragen.swipe
anfragenIn der Liste nach rechts wischen = «Ich übernehme das», nach links = «Ohne Antwort erledigen» (mit Rückgängig). Beides auch im Menü ⋯ der Zeile.off · proposalonly this one
Gruppe und Probetraining wählen
anfragen.trial-date
anfragenÜber dem Entwurf die Gruppe (aus dem Alter vorgeschlagen) und einen konkreten Termin aus dem Trainingskalender wählen; Ferien sind nicht wählbar. Die Antwort schlägt diesen Termin vor; optional eine Erinnerung am Vortag.off · proposalonly this one
Senden: E-Mail und Folgen zeigen
anfragen.review-effects
anfragenDie Bestätigung vor dem Senden zeigt die E-Mail genau so, wie sie rausgeht, und was danach passiert.off · proposalonly this one
Nach dem Senden die nächste Anfrage
anfragen.next-inquiry
anfragenNach dem Senden öffnet sich die nächste offene Anfrage statt des Posteingangs. Anfragen, die gerade jemand anderes bearbeitet, werden übersprungen.off · proposalonly this one
Verlauf je Anfrage
anfragen.history
anfragenUnter «Gesendet» zu jeder Anfrage eine Seite mit Verlauf (eingegangen, gesendet, Erinnerung, Probetraining besucht) und dem nächsten Schritt «Anmeldeformular schicken».off · proposalonly this one
Ruhigere Feiern
athlete.calm-celebrations
athleteStatt der grossen Konfetti-Show: ein kleiner Ausbruch dort, wo du getippt hast, kein Aufblitzen des ganzen Bildschirms, die Punkte kurz oben statt gross über dem Inhalt, keine Vibration bei jeder Übung. Training, Challenge und Belohnung bleiben ein Fest, nur leiser — für Athletinnen, denen viel Bewegung und Licht zu viel ist.off · proposalonly this one
Feiern einstellen
athlete.celebration-setting
athleteIn den Einstellungen «Feiern: Voll · Ruhig · Aus» für dieses Gerät, mit Vorschau. «Aus» zeigt die Punkte als kurze Meldung. Die Wahl gilt vor dem Standard.off · proposalonly this one

Anfragen with all flags on Anfragen with all flags off (legacy parity)

Example screens

athlete.challenges-archive

athletescreen

Route /challenges/archiv · 4 components: page-header, chip-group, badge, empty-state · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.challenges-archive",
  "version": 1,
  "app": "athlete",
  "route": "/challenges/archiv",
  "title": "Frühere Challenges",
  "data": {
    "archive": {
      "source": "athlete.challenges.past"
    }
  },
  "chrome": {
    "title": "Frühere Challenges",
    "back": {
      "label": "Challenges",
      "href": "?screen=athlete.challenges"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Frühere Challenges"
      }
    },
    {
      "component": "chip-group",
      "data": {
        "label": "Status",
        "name": "status",
        "chips": [
          {
            "value": "all",
            "label": "Alle",
            "href": {
              "$text": "?screen=athlete.challenges-archive&status=all&month={params.month}"
            },
            "pressed": {
              "$eq": [
                {
                  "$bind": "params.status"
                },
                "all"
              ]
            }
          },
          {
            "value": "done",
            "label": "Erledigt",
            "href": {
              "$text": "?screen=athlete.challenges-archive&status=done&month={params.month}"
            },
            "pressed": {
              "$eq": [
                {
                  "$bind": "params.status"
                },
                "done"
              ]
            }
          },
          {
            "value": "expired",
            "label": "Abgelaufen",
            "href": {
              "$text": "?screen=athlete.challenges-archive&status=expired&month={params.month}"
            },
            "pressed": {
              "$eq": [
                {
                  "$bind": "params.status"
                },
                "expired"
              ]
            }
          }
        ]
      }
    },
    {
      "component": "chip-group",
      "data": {
        "label": "Monat",
        "name": "month",
        "chips": [
          {
            "value": "all",
            "label": "Alle Monate",
            "href": {
              "$text": "?screen=athlete.challenges-archive&month=all&status={params.status}"
            },
            "pressed": {
              "$eq": [
                {
                  "$bind": "params.month"
                },
                "all"
              ]
            }
          },
          {
            "value": "2026-09",
            "label": "Sep 2026",
            "href": {
              "$text": "?screen=athlete.challenges-archive&month=2026-09&status={params.status}"
            },
            "pressed": {
              "$eq": [
                {
                  "$bind": "params.month"
                },
                "2026-09"
              ]
            }
          },
          {
            "value": "2026-08",
            "label": "Aug 2026",
            "href": {
              "$text": "?screen=athlete.challenges-archive&month=2026-08&status={params.status}"
            },
            "pressed": {
              "$eq": [
                {
                  "$bind": "params.month"
                },
                "2026-08"
              ]
            }
          }
        ]
      }
    },
    {
      "each": "archive.items",
      "as": "c",
      "where": {
        "$and": [
          {
            "$or": [
              {
                "$eq": [
                  {
                    "$bind": "params.status"
                  },
                  "all"
                ]
              },
              {
                "$eq": [
                  {
                    "$bind": "c.status"
                  },
                  {
                    "$bind": "params.status"
                  }
                ]
              }
            ]
          },
          {
            "$or": [
              {
                "$eq": [
                  {
                    "$bind": "params.month"
                  },
                  "all"
                ]
              },
              {
                "$eq": [
                  {
                    "$bind": "c.month"
                  },
                  {
                    "$bind": "params.month"
                  }
                ]
              }
            ]
          }
        ]
      },
      "node": {
        "layout": "card",
        "itemId": {
          "$bind": "c.id"
        },
        "title": {
          "$bind": "c.title"
        },
        "tags": [
          {
            "label": {
              "$text": "+{c.points} P."
            },
            "kind": "points"
          }
        ],
        "children": [
          {
            "layout": "cluster",
            "children": [
              {
                "component": "badge",
                "data": {
                  "label": {
                    "$bind": "c.statusLabel"
                  },
                  "tone": {
                    "$bind": "c.tone"
                  }
                }
              },
              {
                "component": "badge",
                "data": {
                  "label": {
                    "$bind": "c.category"
                  }
                }
              }
            ]
          }
        ]
      }
    },
    {
      "component": "empty-state",
      "if": {
        "$eq": [
          {
            "$count": "archive.items",
            "as": "c",
            "where": {
              "$and": [
                {
                  "$or": [
                    {
                      "$eq": [
                        {
                          "$bind": "params.status"
                        },
                        "all"
                      ]
                    },
                    {
                      "$eq": [
                        {
                          "$bind": "c.status"
                        },
                        {
                          "$bind": "params.status"
                        }
                      ]
                    }
                  ]
                },
                {
                  "$or": [
                    {
                      "$eq": [
                        {
                          "$bind": "params.month"
                        },
                        "all"
                      ]
                    },
                    {
                      "$eq": [
                        {
                          "$bind": "c.month"
                        },
                        {
                          "$bind": "params.month"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          },
          0
        ]
      },
      "data": {
        "icon": "filter",
        "title": "Nichts in dieser Auswahl",
        "text": "Wähle einen anderen Status oder Monat."
      }
    }
  ]
}

athlete.challenges

athletescreen

Route /challenges · 4 components: page-header, badge, button, empty-state · actions: complete (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.challenges",
  "version": 1,
  "app": "athlete",
  "route": "/challenges",
  "title": "Challenges",
  "nav": {
    "label": "Challenges",
    "icon": "target",
    "order": 3,
    "tab": true
  },
  "data": {
    "challenges": {
      "source": "athlete.challenges.open"
    }
  },
  "actions": {
    "complete": {
      "handler": "athlete.challenges.complete",
      "risk": "safe",
      "celebrate": {
        "kind": "big",
        "style": {
          "$if": {
            "$flag": "athlete.calm-celebrations"
          },
          "then": "calm",
          "else": "full"
        },
        "pref": {
          "$flag": "athlete.celebration-setting"
        },
        "points": {
          "$find": "challenges.items",
          "as": "x",
          "where": {
            "$eq": [
              {
                "$bind": "x.id"
              },
              {
                "$bind": "target.id"
              }
            ]
          },
          "get": "points"
        },
        "message": "Challenge erledigt!"
      },
      "next": {
        "$text": "?screen=athlete.challenges&done={target.id},{params.done}"
      }
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Challenges"
      }
    },
    {
      "each": "challenges.items",
      "as": "c",
      "where": {
        "$not": {
          "$bind": "c.completed"
        }
      },
      "node": {
        "layout": "card",
        "itemId": {
          "$bind": "c.id"
        },
        "title": {
          "$bind": "c.title"
        },
        "tags": [
          {
            "label": {
              "$text": "+{c.points} P."
            },
            "kind": "points"
          }
        ],
        "meta": {
          "$bind": "c.description"
        },
        "children": [
          {
            "layout": "cluster",
            "children": [
              {
                "component": "badge",
                "data": {
                  "label": {
                    "$bind": "c.category"
                  }
                }
              },
              {
                "component": "badge",
                "data": {
                  "label": {
                    "$bind": "c.until"
                  }
                }
              }
            ]
          },
          {
            "component": "button",
            "data": {
              "label": "Erledigt melden",
              "variant": "primary",
              "block": "always",
              "action": "complete"
            }
          }
        ]
      }
    },
    {
      "component": "empty-state",
      "if": {
        "$eq": [
          {
            "$count": "challenges.items",
            "as": "c",
            "where": {
              "$not": {
                "$bind": "c.completed"
              }
            }
          },
          0
        ]
      },
      "data": {
        "icon": "target",
        "title": "Alle Challenges erledigt",
        "text": "Starke Leistung! Neue Challenges erscheinen hier."
      }
    },
    {
      "component": "button",
      "data": {
        "label": "Frühere Challenges",
        "icon": "chevron-right",
        "variant": "ghost",
        "href": "?screen=athlete.challenges-archive"
      }
    }
  ]
}

athlete.competitions

athletescreen

Route /wettkaempfe · 2 components: page-header, list · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.competitions",
  "version": 1,
  "app": "athlete",
  "route": "/wettkaempfe",
  "title": "Wettkämpfe",
  "nav": {
    "label": "Wettkämpfe",
    "icon": "trophy",
    "order": 5,
    "tab": true
  },
  "data": {
    "competitions": {
      "source": "athlete.competitions.mine"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Wettkämpfe"
      }
    },
    {
      "layout": "section",
      "variant": "label",
      "id": "bevorstehend",
      "title": "Bevorstehend",
      "gap": "sm",
      "children": [
        {
          "component": "list",
          "data": {
            "label": "Bevorstehende Wettkämpfe",
            "variant": "cards",
            "items": {
              "$each": "competitions.upcoming",
              "as": "k",
              "map": {
                "id": {
                  "$bind": "k.id"
                },
                "title": {
                  "$bind": "k.name"
                },
                "tags": {
                  "$bind": "k.tags"
                }
              }
            }
          }
        }
      ]
    },
    {
      "layout": "section",
      "variant": "label",
      "id": "vergangen",
      "title": "Vergangen",
      "gap": "sm",
      "children": [
        {
          "component": "list",
          "data": {
            "label": "Vergangene Wettkämpfe",
            "variant": "cards",
            "items": {
              "$each": "competitions.past",
              "as": "k",
              "map": {
                "id": {
                  "$bind": "k.id"
                },
                "title": {
                  "$bind": "k.name"
                },
                "tags": {
                  "$bind": "k.tags"
                },
                "badge": {
                  "$bind": "k.result"
                }
              }
            }
          }
        }
      ]
    }
  ]
}

athlete.plans-plan

athletescreen

Route /plaene/:id · 6 components: page-header, ring, badge, button, list, sheet · actions: done (safe), complete (safe), pdf (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.plans-plan",
  "version": 1,
  "app": "athlete",
  "route": "/plaene/:id",
  "title": {
    "$bind": "plan.title"
  },
  "data": {
    "plan": {
      "source": "athlete.plans.get",
      "params": {
        "id": {
          "$bind": "params.id"
        }
      }
    }
  },
  "chrome": {
    "title": {
      "$bind": "plan.title"
    },
    "back": {
      "label": "Pläne",
      "href": "?screen=athlete.plans"
    }
  },
  "actions": {
    "done": {
      "handler": "athlete.plans.tickSet",
      "risk": "safe",
      "celebrate": {
        "kind": "small",
        "style": {
          "$if": {
            "$flag": "athlete.calm-celebrations"
          },
          "then": "calm",
          "else": "full"
        },
        "pref": {
          "$flag": "athlete.celebration-setting"
        },
        "points": 10
      },
      "next": {
        "$text": "?screen=athlete.plans-plan&id={params.id}&completed={params.completed}&{target.id}=done"
      }
    },
    "complete": {
      "handler": "athlete.plans.complete",
      "risk": "safe",
      "success": "Plan als fertig markiert.",
      "celebrate": {
        "kind": "huge",
        "style": {
          "$if": {
            "$flag": "athlete.calm-celebrations"
          },
          "then": "calm",
          "else": "full"
        },
        "pref": {
          "$flag": "athlete.celebration-setting"
        }
      },
      "next": {
        "$text": "?screen=athlete.plans-plan&id={params.id}&e8={params.e8}&completed=1"
      }
    },
    "pdf": {
      "handler": "athlete.plans.pdf",
      "risk": "safe",
      "success": "PDF gespeichert."
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": {
          "$bind": "plan.title"
        }
      }
    },
    {
      "layout": "card",
      "children": [
        {
          "layout": "cluster",
          "grow": "last",
          "children": [
            {
              "component": "ring",
              "data": {
                "value": {
                  "$bind": "plan.pct"
                },
                "label": {
                  "$text": "Plan zu {plan.pct} Prozent erledigt"
                }
              }
            },
            {
              "layout": "cluster",
              "children": [
                {
                  "component": "badge",
                  "data": {
                    "label": {
                      "$join": [
                        {
                          "$count": "plan.exercises",
                          "as": "x",
                          "where": {
                            "$bind": "x.done"
                          }
                        },
                        "/",
                        {
                          "$count": "plan.exercises"
                        }
                      ]
                    }
                  }
                },
                {
                  "component": "badge",
                  "data": {
                    "label": {
                      "$text": "{plan.points} P."
                    },
                    "kind": "points"
                  }
                },
                {
                  "component": "badge",
                  "if": {
                    "$bind": "params.completed"
                  },
                  "data": {
                    "label": "fertig",
                    "tone": "success"
                  }
                },
                {
                  "component": "button",
                  "data": {
                    "label": "PDF",
                    "icon": "download",
                    "size": "sm",
                    "variant": "ghost",
                    "action": "pdf"
                  }
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "layout": "details",
      "title": {
        "$bind": "plan.setTitle"
      },
      "aside": {
        "$join": [
          {
            "$count": "plan.exercises"
          }
        ]
      },
      "open": true,
      "children": [
        {
          "component": "list",
          "data": {
            "label": {
              "$bind": "plan.setTitle"
            },
            "flush": true,
            "items": {
              "$each": "plan.exercises",
              "as": "ex",
              "map": {
                "id": {
                  "$bind": "ex.id"
                },
                "title": {
                  "$bind": "ex.title"
                },
                "meta": {
                  "$bind": "ex.scheme"
                },
                "href": {
                  "$text": "#sheet-{ex.id}"
                },
                "done": {
                  "$bind": "ex.done"
                },
                "quickAction": {
                  "action": "done",
                  "label": "Fertig",
                  "icon": "check"
                }
              }
            }
          }
        }
      ]
    },
    {
      "each": "plan.exercises",
      "as": "ex",
      "node": {
        "component": "sheet",
        "data": {
          "id": {
            "$text": "sheet-{ex.id}"
          },
          "title": {
            "$bind": "ex.title"
          },
          "meta": {
            "$bind": "ex.sheetMeta"
          },
          "paragraphs": [
            {
              "$bind": "ex.description"
            }
          ]
        }
      }
    },
    {
      "component": "button",
      "if": {
        "$not": {
          "$bind": "params.completed"
        }
      },
      "data": {
        "label": "Plan abschliessen",
        "variant": "primary",
        "block": "always",
        "action": "complete"
      }
    }
  ]
}

athlete.plans-programme

athletescreen

Route /plaene/:id · 11 components: page-header, ring, badge, button, progress, alert, list, sheet, note, field, kv · actions: done (reversible), set (reversible), reset (reversible), reply (safe), pdf (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.plans-programme",
  "version": 1,
  "app": "athlete",
  "route": "/plaene/:id",
  "title": {
    "$bind": "plan.title"
  },
  "data": {
    "plan": {
      "source": "athlete.programmes.today",
      "params": {
        "id": {
          "$bind": "params.id"
        }
      }
    }
  },
  "chrome": {
    "title": {
      "$bind": "plan.title"
    },
    "back": {
      "label": "Pläne",
      "href": "?screen=athlete.plans"
    }
  },
  "actions": {
    "done": {
      "handler": "athlete.training.tickExercise",
      "risk": "reversible",
      "success": {
        "$if": {
          "$eq": [
            {
              "$count": "plan.exercises",
              "as": "x",
              "where": {
                "$bind": "x.done"
              }
            },
            0
          ]
        },
        "then": "Noch 4 Übungen",
        "else": {
          "$if": {
            "$eq": [
              {
                "$count": "plan.exercises",
                "as": "x",
                "where": {
                  "$bind": "x.done"
                }
              },
              1
            ]
          },
          "then": "Noch 3 Übungen",
          "else": {
            "$if": {
              "$eq": [
                {
                  "$count": "plan.exercises",
                  "as": "x",
                  "where": {
                    "$bind": "x.done"
                  }
                },
                2
              ]
            },
            "then": "Noch 2 Übungen",
            "else": {
              "$if": {
                "$eq": [
                  {
                    "$count": "plan.exercises",
                    "as": "x",
                    "where": {
                      "$bind": "x.done"
                    }
                  },
                  3
                ]
              },
              "then": "Noch eine Übung!"
            }
          }
        }
      },
      "celebrate": {
        "kind": {
          "$if": {
            "$eq": [
              {
                "$count": "plan.exercises",
                "as": "x",
                "where": {
                  "$bind": "x.done"
                }
              },
              4
            ]
          },
          "then": "huge",
          "else": "exercise"
        },
        "style": {
          "$if": {
            "$flag": "athlete.calm-celebrations"
          },
          "then": "calm",
          "else": "full"
        },
        "pref": {
          "$flag": "athlete.celebration-setting"
        },
        "points": {
          "$if": {
            "$eq": [
              {
                "$count": "plan.exercises",
                "as": "x",
                "where": {
                  "$bind": "x.done"
                }
              },
              4
            ]
          },
          "then": {
            "$bind": "plan.points"
          }
        },
        "message": {
          "$if": {
            "$eq": [
              {
                "$count": "plan.exercises",
                "as": "x",
                "where": {
                  "$bind": "x.done"
                }
              },
              4
            ]
          },
          "then": "🏋️ Training geschafft!",
          "else": [
            "Übung geschafft! 💪",
            "Stark! 🔥",
            "Boom! 👊",
            "Weiter so! ⭐",
            "Läuft! 🥋",
            "Yes! ✨",
            "Nächste! 🚀"
          ]
        }
      },
      "next": {
        "$join": [
          {
            "$text": "?screen=athlete.plans-programme&id={params.id}&e1={params.e1}&e2={params.e2}&e3={params.e3}&e4={params.e4}&e5={params.e5}&set={params.set}&{target.id}=done"
          },
          "&reply=",
          {
            "$fmt": "url",
            "value": {
              "$bind": "params.reply"
            }
          }
        ]
      }
    },
    "set": {
      "handler": "athlete.training.tickSet",
      "risk": "reversible",
      "next": {
        "$join": [
          {
            "$text": "?screen=athlete.plans-programme&id={params.id}&e1={params.e1}&e2={params.e2}&e3={params.e3}&e4={params.e4}&e5={params.e5}&set={params.set}&set={target.id},{params.set}"
          },
          "&reply=",
          {
            "$fmt": "url",
            "value": {
              "$bind": "params.reply"
            }
          }
        ]
      },
      "success": {
        "$find": "plan.exercises",
        "as": "x",
        "where": {
          "$eq": [
            {
              "$bind": "x.id"
            },
            {
              "$bind": "target.id"
            }
          ]
        },
        "get": "nextSet"
      }
    },
    "reset": {
      "handler": "athlete.training.resetExercise",
      "risk": "reversible",
      "next": {
        "$join": [
          {
            "$text": "?screen=athlete.plans-programme&id={params.id}&e1={params.e1}&e2={params.e2}&e3={params.e3}&e4={params.e4}&e5={params.e5}&set={params.set}&{target.id}=reset"
          },
          "&reply=",
          {
            "$fmt": "url",
            "value": {
              "$bind": "params.reply"
            }
          }
        ]
      }
    },
    "reply": {
      "handler": "athlete.coach.reply",
      "risk": "safe",
      "success": "Antwort gesendet",
      "next": {
        "$join": [
          {
            "$text": "?screen=athlete.plans-programme&id={params.id}&e1={params.e1}&e2={params.e2}&e3={params.e3}&e4={params.e4}&e5={params.e5}&set={params.set}"
          },
          "&reply=",
          {
            "$fmt": "url",
            "value": {
              "$bind": "values.reply"
            }
          }
        ]
      }
    },
    "pdf": {
      "handler": "athlete.plans.pdf",
      "risk": "safe",
      "success": "PDF gespeichert."
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": {
          "$bind": "plan.title"
        }
      }
    },
    {
      "layout": "card",
      "children": [
        {
          "layout": "cluster",
          "grow": "last",
          "children": [
            {
              "component": "ring",
              "data": {
                "value": {
                  "$bind": "plan.pct"
                },
                "label": {
                  "$text": "Programm zu {plan.pct} Prozent erledigt"
                }
              }
            },
            {
              "layout": "cluster",
              "children": [
                {
                  "component": "badge",
                  "data": {
                    "label": {
                      "$text": "Woche {plan.week} von {plan.weeks}"
                    }
                  }
                },
                {
                  "component": "badge",
                  "data": {
                    "label": {
                      "$bind": "plan.phase"
                    }
                  }
                },
                {
                  "component": "badge",
                  "data": {
                    "label": {
                      "$if": {
                        "$eq": [
                          {
                            "$count": "plan.exercises",
                            "as": "x",
                            "where": {
                              "$bind": "x.done"
                            }
                          },
                          {
                            "$bind": "plan.total"
                          }
                        ]
                      },
                      "then": "2/3 diese Woche",
                      "else": {
                        "$text": "{plan.weekDone}/{plan.weekTarget} diese Woche"
                      }
                    }
                  }
                },
                {
                  "component": "badge",
                  "data": {
                    "label": {
                      "$text": "{plan.weekStreak} Wo."
                    },
                    "icon": "flame"
                  }
                },
                {
                  "component": "button",
                  "data": {
                    "label": "PDF",
                    "icon": "download",
                    "size": "sm",
                    "variant": "ghost",
                    "action": "pdf"
                  }
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "component": "progress",
      "data": {
        "id": "today",
        "label": "Heute",
        "hideLabel": true,
        "value": {
          "$count": "plan.exercises",
          "as": "x",
          "where": {
            "$bind": "x.done"
          }
        },
        "max": {
          "$bind": "plan.total"
        },
        "text": {
          "$if": {
            "$eq": [
              {
                "$count": "plan.exercises",
                "as": "x",
                "where": {
                  "$bind": "x.done"
                }
              },
              {
                "$bind": "plan.total"
              }
            ]
          },
          "then": "Heutiges Training geschafft",
          "else": {
            "$join": [
              {
                "$count": "plan.exercises",
                "as": "x",
                "where": {
                  "$bind": "x.done"
                }
              },
              "/",
              {
                "$bind": "plan.total"
              },
              " Übungen heute · ",
              {
                "$bind": "plan.phaseLeft"
              }
            ]
          }
        }
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "neutral",
        "title": {
          "$bind": "plan.hint"
        }
      }
    },
    {
      "layout": "section",
      "id": "uebungen",
      "title": "Deine Übungen",
      "gap": "sm",
      "children": [
        {
          "component": "list",
          "data": {
            "label": "Deine Übungen",
            "gestures": "primary",
            "swipeHint": {
              "id": "athlete-swipe",
              "title": "So geht's",
              "items": [
                "Nach rechts wischen: Übung fertig",
                "Nach links wischen: ein Satz geschafft",
                "Name antippen: Bilder, Video und Beschreibung",
                "Erledigt aus Versehen: ↺ setzt zurück"
              ]
            },
            "items": {
              "$each": "plan.exercises",
              "as": "ex",
              "sortBy": "ex.done",
              "map": {
                "id": {
                  "$bind": "ex.id"
                },
                "title": {
                  "$bind": "ex.title"
                },
                "meta": {
                  "$bind": "ex.scheme"
                },
                "href": {
                  "$text": "#sheet-{ex.id}"
                },
                "done": {
                  "$bind": "ex.done"
                },
                "progress": {
                  "$if": {
                    "$gte": [
                      {
                        "$bind": "ex.sets"
                      },
                      2
                    ]
                  },
                  "then": {
                    "done": {
                      "$bind": "ex.setsDone"
                    },
                    "total": {
                      "$bind": "ex.sets"
                    }
                  }
                },
                "quickAction": {
                  "action": "done",
                  "label": "Fertig",
                  "icon": "check"
                },
                "doneAction": {
                  "action": "reset",
                  "label": "Zurücksetzen",
                  "icon": "undo"
                },
                "swipe": {
                  "$if": {
                    "$bind": "ex.done"
                  },
                  "else": {
                    "mode": "commit",
                    "start": {
                      "action": "done",
                      "label": "Übung fertig",
                      "icon": "check",
                      "tone": "success"
                    },
                    "end": {
                      "$if": {
                        "$gte": [
                          {
                            "$bind": "ex.sets"
                          },
                          2
                        ]
                      },
                      "then": {
                        "action": "set",
                        "label": "Satz geschafft",
                        "icon": "plus",
                        "tone": "accent"
                      }
                    }
                  }
                },
                "actions": {
                  "$if": {
                    "$and": [
                      {
                        "$not": {
                          "$bind": "ex.done"
                        }
                      },
                      {
                        "$gte": [
                          {
                            "$bind": "ex.sets"
                          },
                          2
                        ]
                      }
                    ]
                  },
                  "then": [
                    {
                      "action": "set",
                      "label": "Ein Satz geschafft",
                      "icon": "plus"
                    }
                  ],
                  "else": []
                }
              }
            }
          }
        }
      ]
    },
    {
      "each": "plan.exercises",
      "as": "ex",
      "node": {
        "component": "sheet",
        "data": {
          "id": {
            "$text": "sheet-{ex.id}"
          },
          "title": {
            "$bind": "ex.title"
          },
          "meta": {
            "$bind": "ex.sheetMeta"
          },
          "paragraphs": [
            {
              "$bind": "ex.description"
            }
          ]
        }
      }
    },
    {
      "layout": "section",
      "variant": "label",
      "id": "coach",
      "title": "Vom Coach",
      "gap": "sm",
      "children": [
        {
          "each": "plan.coach",
          "as": "m",
          "node": {
            "component": "note",
            "data": {
              "author": {
                "$bind": "m.author"
              },
              "date": {
                "$bind": "m.date"
              },
              "dateLabel": {
                "$bind": "m.dateLabel"
              },
              "text": [
                {
                  "$bind": "m.text"
                }
              ],
              "mine": {
                "$bind": "m.mine"
              }
            }
          }
        },
        {
          "component": "note",
          "if": {
            "$bind": "params.reply"
          },
          "data": {
            "author": "Du",
            "dateLabel": "gerade eben",
            "text": [
              {
                "$bind": "params.reply"
              }
            ],
            "mine": true
          }
        },
        {
          "layout": "cluster",
          "grow": "first",
          "children": [
            {
              "component": "field",
              "data": {
                "id": "reply",
                "name": "reply",
                "label": "Antwort an Sandra",
                "hideLabel": true,
                "placeholder": "Antworten …",
                "maxlength": 600,
                "autocomplete": "off"
              }
            },
            {
              "component": "button",
              "data": {
                "label": "Senden",
                "icon": "send",
                "iconOnly": true,
                "ariaLabel": "Antwort senden",
                "variant": "primary",
                "action": "reply"
              }
            }
          ]
        }
      ]
    },
    {
      "layout": "section",
      "variant": "label",
      "id": "abzeichen",
      "title": "Meine Abzeichen",
      "gap": "sm",
      "children": [
        {
          "layout": "cluster",
          "children": [
            {
              "each": "plan.badges",
              "as": "b",
              "node": {
                "component": "badge",
                "data": {
                  "label": {
                    "$bind": "b.label"
                  },
                  "icon": {
                    "$bind": "b.icon"
                  }
                }
              }
            }
          ]
        },
        {
          "component": "kv",
          "data": {
            "items": [
              {
                "term": "Nächstes Abzeichen",
                "value": {
                  "$bind": "plan.nextBadge"
                }
              }
            ]
          }
        }
      ]
    },
    {
      "layout": "section",
      "variant": "label",
      "id": "gruppe",
      "title": "Ranking der Gruppe",
      "gap": "sm",
      "children": [
        {
          "component": "list",
          "data": {
            "label": "Ranking der Gruppe",
            "variant": "cards",
            "items": {
              "$each": "plan.group",
              "as": "g",
              "map": {
                "id": {
                  "$bind": "g.id"
                },
                "title": {
                  "$bind": "g.name"
                },
                "rank": {
                  "$bind": "g.rank"
                },
                "value": {
                  "$bind": "g.trainings"
                },
                "current": {
                  "$bind": "g.me"
                },
                "meta": {
                  "$if": {
                    "$bind": "g.streak"
                  },
                  "then": {
                    "$text": "{g.streak} Wochen am Stück"
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}

athlete.plans

athletescreen

Route /plaene · 2 components: page-header, list · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.plans",
  "version": 1,
  "app": "athlete",
  "route": "/plaene",
  "title": "Trainingspläne",
  "nav": {
    "label": "Pläne",
    "icon": "list",
    "order": 2,
    "tab": true
  },
  "data": {
    "plans": {
      "source": "athlete.plans.active"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Trainingspläne"
      }
    },
    {
      "component": "list",
      "data": {
        "label": "Trainingspläne",
        "variant": "cards",
        "items": {
          "$each": "plans.items",
          "as": "p",
          "map": {
            "id": {
              "$bind": "p.id"
            },
            "title": {
              "$bind": "p.title"
            },
            "ring": {
              "$bind": "p.pct"
            },
            "href": {
              "$bind": "p.href"
            },
            "tags": {
              "$bind": "p.tags"
            }
          }
        }
      }
    }
  ]
}

athlete.ranking

athletescreen

Route /ranking · 5 components: page-header, stat, badge, dialog, list · actions: save-name (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.ranking",
  "version": 1,
  "app": "athlete",
  "route": "/ranking",
  "title": "Ranking",
  "nav": {
    "label": "Ranking",
    "icon": "award",
    "order": 4,
    "tab": true
  },
  "data": {
    "points": {
      "source": "athlete.points.month"
    },
    "board": {
      "source": "athlete.leaderboard.month"
    },
    "me": {
      "source": "athlete.me"
    }
  },
  "actions": {
    "save-name": {
      "handler": "athlete.me.setPublicName",
      "risk": "safe",
      "success": {
        "$join": [
          "Name gespeichert: ",
          {
            "$bind": "values.publicName"
          }
        ]
      },
      "next": {
        "$join": [
          "?screen=athlete.ranking&name=",
          {
            "$fmt": "url",
            "value": {
              "$bind": "values.publicName"
            }
          }
        ]
      }
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Ranking"
      }
    },
    {
      "component": "stat",
      "data": {
        "label": "Deine Punkte diesen Monat",
        "icon": "star",
        "kind": "points",
        "value": {
          "$bind": "points.total"
        },
        "meta": {
          "$text": "Platz {points.rank} im Ranking"
        }
      }
    },
    {
      "layout": "cluster",
      "children": [
        {
          "each": "points.breakdown",
          "as": "b",
          "node": {
            "component": "badge",
            "data": {
              "label": {
                "$bind": "b.label"
              }
            }
          }
        },
        {
          "component": "dialog",
          "data": {
            "id": "name-dialog",
            "title": "Öffentlicher Name",
            "trigger": {
              "label": "Einstellungen …",
              "variant": "ghost",
              "icon": "settings"
            },
            "fields": [
              {
                "id": "publicName",
                "name": "publicName",
                "label": "Öffentlicher Name",
                "hint": "Wird im Ranking angezeigt: 3–24 Zeichen, z. B. „TKD Nicci“. Leer lassen, um nicht in der Liste zu erscheinen.",
                "value": {
                  "$if": {
                    "$bind": "params.name"
                  },
                  "then": {
                    "$bind": "params.name"
                  },
                  "else": {
                    "$bind": "me.publicName"
                  }
                },
                "maxlength": 24,
                "autocomplete": "off",
                "placeholder": "z. B. TKD Nicci"
              }
            ],
            "actions": [
              {
                "label": "Abbrechen",
                "value": "cancel"
              },
              {
                "label": "Speichern",
                "value": "save",
                "variant": "primary",
                "action": "save-name"
              }
            ]
          }
        }
      ]
    },
    {
      "layout": "section",
      "variant": "label",
      "id": "monat",
      "title": {
        "$text": "Monat {points.month}"
      },
      "gap": "sm",
      "children": [
        {
          "component": "list",
          "data": {
            "label": {
              "$text": "Ranking {points.month}"
            },
            "variant": "cards",
            "items": {
              "$each": "board.rows",
              "as": "r",
              "map": {
                "id": {
                  "$bind": "r.id"
                },
                "rank": {
                  "$bind": "r.rank"
                },
                "title": {
                  "$if": {
                    "$bind": "r.me"
                  },
                  "then": {
                    "$if": {
                      "$bind": "params.name"
                    },
                    "then": {
                      "$bind": "params.name"
                    },
                    "else": {
                      "$bind": "me.publicName"
                    }
                  },
                  "else": {
                    "$bind": "r.name"
                  }
                },
                "value": {
                  "$bind": "r.points"
                },
                "current": {
                  "$bind": "r.me"
                }
              }
            }
          }
        }
      ]
    }
  ]
}

athlete.settings

athletescreen

Route /einstellungen · 7 components: page-header, kv, dialog, switch, segmented, button, field · actions: save-name (safe), celebrate-preview (safe), logout (irreversible)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.settings",
  "version": 1,
  "app": "athlete",
  "route": "/einstellungen",
  "title": "Einstellungen",
  "data": {
    "me": {
      "source": "athlete.me"
    }
  },
  "chrome": {
    "title": "Einstellungen",
    "current": false
  },
  "actions": {
    "save-name": {
      "handler": "athlete.me.setPublicName",
      "risk": "safe",
      "success": {
        "$join": [
          "Name gespeichert: ",
          {
            "$bind": "values.publicName"
          }
        ]
      },
      "next": {
        "$join": [
          "?screen=athlete.settings&name=",
          {
            "$fmt": "url",
            "value": {
              "$bind": "values.publicName"
            }
          }
        ]
      }
    },
    "celebrate-preview": {
      "handler": "athlete.celebrations.preview",
      "risk": "safe",
      "celebrate": {
        "kind": "huge",
        "style": {
          "$if": {
            "$flag": "athlete.calm-celebrations"
          },
          "then": "calm",
          "else": "full"
        },
        "pref": {
          "$flag": "athlete.celebration-setting"
        },
        "points": 20,
        "message": "So sieht es aus"
      }
    },
    "logout": {
      "handler": "auth.logout",
      "risk": "irreversible",
      "confirm": {
        "title": "Wirklich abmelden?",
        "body": "Du meldest dich auf diesem Gerät ab und brauchst einen neuen Code aus der E-Mail.",
        "confirmLabel": "Abmelden",
        "tone": "danger"
      },
      "success": "Abgemeldet"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Einstellungen"
      }
    },
    {
      "layout": "card",
      "title": "Profil",
      "meta": "Erscheint im Ranking. 3–24 Zeichen, z. B. „TKD Nicci“.",
      "children": [
        {
          "layout": "cluster",
          "justify": "between",
          "children": [
            {
              "component": "kv",
              "data": {
                "items": [
                  {
                    "term": "Öffentlicher Name",
                    "value": {
                      "$if": {
                        "$bind": "params.name"
                      },
                      "then": {
                        "$bind": "params.name"
                      },
                      "else": {
                        "$bind": "me.publicName"
                      }
                    }
                  }
                ]
              }
            },
            {
              "component": "dialog",
              "data": {
                "id": "name-dialog",
                "title": "Öffentlicher Name",
                "trigger": {
                  "label": "Ändern …"
                },
                "fields": [
                  {
                    "id": "publicName",
                    "name": "publicName",
                    "label": "Öffentlicher Name",
                    "hint": "Wird im Ranking angezeigt: 3–24 Zeichen, z. B. „TKD Nicci“. Leer lassen, um nicht in der Liste zu erscheinen.",
                    "value": {
                      "$if": {
                        "$bind": "params.name"
                      },
                      "then": {
                        "$bind": "params.name"
                      },
                      "else": {
                        "$bind": "me.publicName"
                      }
                    },
                    "maxlength": 24,
                    "autocomplete": "off",
                    "placeholder": "z. B. TKD Nicci"
                  }
                ],
                "actions": [
                  {
                    "label": "Abbrechen",
                    "value": "cancel"
                  },
                  {
                    "label": "Speichern",
                    "value": "save",
                    "variant": "primary",
                    "action": "save-name"
                  }
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "layout": "card",
      "title": "Push-Benachrichtigungen",
      "children": [
        {
          "component": "switch",
          "data": {
            "id": "push",
            "label": "Neue Challenges, Pläne, Belohnungen",
            "hint": "Aktivieren, um Benachrichtigungen auf diesem Gerät zu bekommen."
          }
        }
      ]
    },
    {
      "layout": "card",
      "title": "Training",
      "children": [
        {
          "component": "switch",
          "data": {
            "id": "restTimer",
            "label": "Pausen-Timer nach jedem Set",
            "hint": "Nach einem Set läuft die Pause aus dem Plan rückwärts, mit Vibration am Ende. Tippen überspringt sie."
          }
        }
      ]
    },
    {
      "layout": "card",
      "title": "Feiern",
      "if": {
        "$flag": "athlete.celebration-setting"
      },
      "meta": "Konfetti und Punkte, wenn du etwas geschafft hast. Gilt für dieses Gerät.",
      "children": [
        {
          "layout": "cluster",
          "justify": "between",
          "children": [
            {
              "component": "segmented",
              "data": {
                "id": "celebrations",
                "legend": "Feiern",
                "hideLegend": true,
                "pref": "celebrations",
                "value": {
                  "$if": {
                    "$flag": "athlete.calm-celebrations"
                  },
                  "then": "calm",
                  "else": "full"
                },
                "options": [
                  {
                    "value": "full",
                    "label": "Voll"
                  },
                  {
                    "value": "calm",
                    "label": "Ruhig"
                  },
                  {
                    "value": "off",
                    "label": "Aus"
                  }
                ]
              }
            },
            {
              "component": "button",
              "data": {
                "label": "Vorschau",
                "icon": "play",
                "variant": "ghost",
                "action": "celebrate-preview"
              }
            }
          ]
        }
      ]
    },
    {
      "layout": "card",
      "title": "App",
      "children": [
        {
          "component": "field",
          "data": {
            "id": "lang",
            "name": "lang",
            "label": "Sprache",
            "control": "select",
            "value": "de",
            "hint": "Trainingspläne, Programme und die App werden in dieser Sprache angezeigt.",
            "options": [
              {
                "value": "de",
                "label": "Deutsch"
              },
              {
                "value": "en",
                "label": "English"
              },
              {
                "value": "fr",
                "label": "Français"
              },
              {
                "value": "fa",
                "label": "فارسی"
              }
            ]
          }
        },
        {
          "component": "segmented",
          "data": {
            "id": "theme",
            "legend": "Design",
            "pref": "theme",
            "value": "dark",
            "options": [
              {
                "value": "dark",
                "label": "Dunkel"
              },
              {
                "value": "light",
                "label": "Hell"
              }
            ]
          }
        },
        {
          "layout": "cluster",
          "justify": "between",
          "children": [
            {
              "component": "kv",
              "data": {
                "items": [
                  {
                    "term": "Konto",
                    "value": {
                      "$bind": "user.email"
                    }
                  }
                ]
              }
            },
            {
              "component": "button",
              "data": {
                "label": "Abmelden",
                "icon": "log-out",
                "action": "logout"
              }
            }
          ]
        }
      ]
    }
  ]
}

athlete.today

athletescreen

Route /heute · 9 components: page-header, streak, action-tile, stat, alert, scale, button, badge, list · actions: push-on (safe), push-dismiss (safe), wellness-save (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "athlete.today",
  "version": 1,
  "app": "athlete",
  "route": "/heute",
  "title": {
    "$text": "Hallo {user.firstName}"
  },
  "nav": {
    "label": "Heute",
    "icon": "home",
    "order": 1,
    "tab": true
  },
  "data": {
    "programme": {
      "source": "athlete.programmes.current"
    },
    "streak": {
      "source": "athlete.streak.week"
    },
    "points": {
      "source": "athlete.points.month"
    },
    "wellness": {
      "source": "athlete.wellness.today"
    },
    "reward": {
      "source": "athlete.rewards.self"
    }
  },
  "chrome": {
    "title": {
      "$text": "Hallo {user.firstName}"
    }
  },
  "actions": {
    "push-on": {
      "handler": "athlete.push.subscribe",
      "risk": "safe",
      "success": "Benachrichtigungen eingeschaltet",
      "next": {
        "$text": "?screen=athlete.today&push=on&wellness={params.wellness}"
      }
    },
    "push-dismiss": {
      "handler": "athlete.push.hideNudge",
      "risk": "safe",
      "next": {
        "$text": "?screen=athlete.today&push=off&wellness={params.wellness}"
      }
    },
    "wellness-save": {
      "handler": "athlete.wellness.save",
      "risk": "safe",
      "celebrate": {
        "kind": "small",
        "style": {
          "$if": {
            "$flag": "athlete.calm-celebrations"
          },
          "then": "calm",
          "else": "full"
        },
        "pref": {
          "$flag": "athlete.celebration-setting"
        },
        "points": 5,
        "message": "Check-in gespeichert!"
      },
      "next": {
        "$text": "?screen=athlete.today&wellness=done&push={params.push}&reward={params.reward}"
      }
    }
  },
  "celebrate": {
    "if": {
      "$bind": "reward.eligible"
    },
    "once": "athlete-reward",
    "kind": "huge",
    "style": {
      "$if": {
        "$flag": "athlete.calm-celebrations"
      },
      "then": "calm",
      "else": "full"
    },
    "pref": {
      "$flag": "athlete.celebration-setting"
    },
    "message": {
      "$text": "🎁 Belohnung freigeschaltet!\n{reward.reward}"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": {
          "$text": "Hallo {user.firstName}"
        }
      }
    },
    {
      "layout": "card",
      "children": [
        {
          "component": "streak",
          "data": {
            "weeks": {
              "$bind": "streak.weeks"
            },
            "goal": {
              "$bind": "streak.goal"
            },
            "label": {
              "$bind": "streak.label"
            },
            "days": {
              "$bind": "streak.days"
            }
          }
        }
      ]
    },
    {
      "layout": "tiles",
      "children": [
        {
          "component": "action-tile",
          "data": {
            "href": "?screen=athlete.plans-programme&id=p1",
            "eyebrow": "Training",
            "title": "Start",
            "icon": "play",
            "meta": {
              "$bind": "programme.title"
            },
            "progress": {
              "value": {
                "$bind": "programme.weekDone"
              },
              "max": {
                "$bind": "programme.weekTarget"
              },
              "text": {
                "$text": "{programme.weekDone}/{programme.weekTarget} diese Woche · +{programme.points} Punkte"
              }
            }
          }
        },
        {
          "component": "stat",
          "data": {
            "label": "Punkte",
            "icon": "star",
            "kind": "points",
            "level": {
              "$bind": "points.level"
            },
            "value": {
              "$bind": "points.total"
            },
            "meta": {
              "$text": "{points.tier} · Platz {points.rank}"
            },
            "href": "?screen=athlete.ranking"
          }
        },
        {
          "component": "stat",
          "data": {
            "label": "Wellness",
            "icon": "heart",
            "kind": "wellness",
            "value": {
              "$if": {
                "$bind": "wellness.done"
              },
              "then": "Erledigt",
              "else": "–"
            },
            "meta": {
              "$if": {
                "$bind": "wellness.done"
              },
              "then": "+5 P. heute",
              "else": "Wie geht's dir?"
            },
            "href": {
              "$if": {
                "$bind": "wellness.done"
              },
              "then": "?screen=athlete.today&wellness=done&push={params.push}",
              "else": "#wellness"
            }
          }
        }
      ]
    },
    {
      "component": "alert",
      "if": {
        "$not": {
          "$bind": "params.push"
        }
      },
      "data": {
        "tone": "info",
        "title": "Benachrichtigungen einschalten",
        "body": "High five nach dem Training, eine Erinnerung an Tagen ohne Training, Nachrichten vom Coach.",
        "action": {
          "action": "push-on",
          "label": "Einschalten"
        },
        "dismiss": {
          "action": "push-dismiss",
          "label": "Nicht mehr anzeigen"
        }
      }
    },
    {
      "layout": "card",
      "id": "wellness",
      "if": {
        "$not": {
          "$bind": "wellness.done"
        }
      },
      "title": "Wie geht's dir heute?",
      "tags": [
        {
          "label": "+5 P.",
          "kind": "points"
        }
      ],
      "children": [
        {
          "component": "scale",
          "data": {
            "id": "sleep",
            "name": "sleep",
            "legend": "Schlaf",
            "inline": true,
            "minLabel": "😴",
            "maxLabel": "⭐"
          }
        },
        {
          "component": "scale",
          "data": {
            "id": "mood",
            "name": "mood",
            "legend": "Laune",
            "inline": true,
            "minLabel": "😞",
            "maxLabel": "😄"
          }
        },
        {
          "component": "scale",
          "data": {
            "id": "motivation",
            "name": "motivation",
            "legend": "Motivation",
            "inline": true,
            "minLabel": "💤",
            "maxLabel": "🔥"
          }
        },
        {
          "component": "scale",
          "data": {
            "id": "energy",
            "name": "energy",
            "legend": "Energie",
            "inline": true,
            "minLabel": "🪫",
            "maxLabel": "⚡"
          }
        },
        {
          "component": "button",
          "data": {
            "label": "Speichern",
            "variant": "primary",
            "block": "always",
            "action": "wellness-save"
          }
        }
      ]
    },
    {
      "layout": "card",
      "title": {
        "$bind": "reward.title"
      },
      "tags": {
        "$if": {
          "$bind": "reward.eligible"
        },
        "then": [
          {
            "label": "Freigeschaltet",
            "tone": "success"
          }
        ],
        "else": [
          {
            "label": {
              "$bind": "reward.progress"
            }
          }
        ]
      },
      "meta": {
        "$bind": "reward.text"
      },
      "children": [
        {
          "layout": "cluster",
          "children": [
            {
              "each": "reward.stamps",
              "as": "s",
              "node": {
                "component": "badge",
                "data": {
                  "label": {
                    "$bind": "s.label"
                  },
                  "tone": {
                    "$bind": "s.tone"
                  }
                }
              }
            }
          ]
        },
        {
          "component": "badge",
          "data": {
            "label": {
              "$text": "Belohnung: {reward.reward}"
            },
            "icon": "gift"
          }
        }
      ]
    },
    {
      "layout": "section",
      "variant": "label",
      "id": "weitere",
      "title": "Weitere Pläne",
      "gap": "sm",
      "children": [
        {
          "component": "list",
          "data": {
            "label": "Weitere Pläne",
            "variant": "cards",
            "items": [
              {
                "id": "p2",
                "title": "Beweglichkeit Poomsae",
                "meta": "1/2 Übungen · 10 Punkte",
                "ring": 50,
                "href": "?screen=athlete.plans-plan&id=p2"
              }
            ]
          }
        }
      ]
    }
  ]
}

comms.admin

anfragenscreen

Route /benutzer · 6 components: page-header, field, button, kv, alert, table · actions: saveSettings (safe), readCalendar (safe), saveCalendar (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.admin",
  "version": 1,
  "app": "anfragen",
  "route": "/benutzer",
  "title": "Benutzer",
  "data": {
    "settings": {
      "source": "settings.get"
    },
    "calendar": {
      "source": "training.calendar.status"
    },
    "users": {
      "source": "users.list"
    }
  },
  "actions": {
    "saveSettings": {
      "handler": "settings.save",
      "risk": "safe",
      "success": "Einstellungen gespeichert"
    },
    "readCalendar": {
      "handler": "training.readCalendar",
      "risk": "safe",
      "success": "Kalender gelesen: 18 Trainings pro Woche"
    },
    "saveCalendar": {
      "handler": "training.saveCalendarUrl",
      "risk": "safe",
      "success": "Gespeichert"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Einstellungen",
        "meta": "Email Workflow-Konfiguration"
      }
    },
    {
      "layout": "card",
      "title": "Gmail Labels",
      "children": [
        {
          "layout": "grid",
          "min": "14rem",
          "children": [
            {
              "component": "field",
              "data": {
                "id": "source-label",
                "name": "sourceLabel",
                "label": "Posteingang (Quelle)",
                "control": "select",
                "hint": "Gmail-Label, aus dem neue Anfragen geladen werden",
                "value": {
                  "$bind": "settings.sourceLabel"
                },
                "options": {
                  "$each": "settings.labels",
                  "as": "l",
                  "map": {
                    "value": {
                      "$bind": "l"
                    },
                    "label": {
                      "$bind": "l"
                    }
                  }
                }
              }
            },
            {
              "component": "field",
              "data": {
                "id": "done-label",
                "name": "doneLabel",
                "label": "Erledigt (Ziel)",
                "control": "select",
                "hint": "Gmail-Label, wohin beantwortete E-Mails verschoben werden",
                "value": {
                  "$bind": "settings.doneLabel"
                },
                "options": {
                  "$each": "settings.labels",
                  "as": "l",
                  "map": {
                    "value": {
                      "$bind": "l"
                    },
                    "label": {
                      "$bind": "l"
                    }
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "layout": "card",
      "title": "Antwort-Betreff",
      "children": [
        {
          "layout": "grid",
          "min": "14rem",
          "children": [
            {
              "component": "field",
              "data": {
                "id": "subject-de",
                "name": "replySubjectDe",
                "label": "Deutsch",
                "value": {
                  "$bind": "settings.replySubjectDe"
                }
              }
            },
            {
              "component": "field",
              "data": {
                "id": "subject-en",
                "name": "replySubjectEn",
                "label": "English",
                "value": {
                  "$bind": "settings.replySubjectEn"
                }
              }
            }
          ]
        },
        {
          "layout": "cluster",
          "children": [
            {
              "component": "button",
              "data": {
                "label": "Einstellungen speichern",
                "variant": "primary",
                "action": "saveSettings"
              }
            }
          ]
        }
      ]
    },
    {
      "layout": "card",
      "title": "Trainingskalender",
      "children": [
        {
          "component": "field",
          "data": {
            "id": "ical-url",
            "name": "icalUrl",
            "label": "Kalender-Adresse (iCal)",
            "type": "url",
            "inputmode": "url",
            "value": {
              "$bind": "calendar.url"
            },
            "hint": "Aus diesem Kalender kommt der Wochenplan; die Antworten nennen die Trainings der erkannten Gruppe."
          }
        },
        {
          "component": "kv",
          "data": {
            "items": [
              {
                "term": "Zuletzt gelesen",
                "value": {
                  "$bind": "calendar.readLabel"
                }
              },
              {
                "term": "Trainings pro Woche",
                "value": {
                  "$bind": "calendar.sessionCount"
                }
              }
            ]
          }
        },
        {
          "layout": "cluster",
          "children": [
            {
              "component": "button",
              "data": {
                "label": "Speichern",
                "variant": "primary",
                "action": "saveCalendar"
              }
            },
            {
              "component": "button",
              "data": {
                "label": "Jetzt lesen",
                "icon": "refresh",
                "action": "readCalendar"
              }
            }
          ]
        }
      ]
    },
    {
      "layout": "section",
      "id": "team",
      "title": {
        "$join": [
          "Team · ",
          {
            "$count": "users.items"
          },
          " berechtigte Email Responder"
        ]
      },
      "children": [
        {
          "component": "alert",
          "data": {
            "tone": "info",
            "title": "Benutzerverwaltung über Webling",
            "body": "Die Benutzer werden automatisch aus der Webling-Gruppe «Email Responders» geladen. Um jemanden hinzuzufügen oder zu entfernen, ändere die Gruppenmitgliedschaft direkt in Webling.",
            "link": {
              "label": "Webling öffnen",
              "href": "#"
            }
          }
        },
        {
          "component": "table",
          "data": {
            "caption": "Email Responder",
            "captionHidden": true,
            "columns": [
              {
                "key": "name",
                "label": "Name"
              },
              {
                "key": "email",
                "label": "E-Mail"
              },
              {
                "key": "status",
                "label": "Status"
              }
            ],
            "rowHeaderKey": "name",
            "rows": {
              "$each": "users.items",
              "as": "u",
              "map": {
                "id": {
                  "$bind": "u.id"
                },
                "selected": {
                  "$bind": "u.me"
                },
                "cells": {
                  "name": {
                    "$bind": "u.name"
                  },
                  "email": {
                    "$bind": "u.email"
                  },
                  "status": {
                    "badge": {
                      "label": "Aktiv",
                      "tone": "success"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}

comms.closures

anfragenscreen

Route /ferien · 6 components: page-header, alert, choice-group, field, button, card · actions: save (safe), edit (safe), delete (irreversible)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.closures",
  "version": 1,
  "app": "anfragen",
  "route": "/ferien",
  "title": "Ferien & Events",
  "data": {
    "closures": {
      "source": "closures.list"
    }
  },
  "actions": {
    "save": {
      "handler": "closures.save",
      "risk": "safe",
      "success": "Gespeichert",
      "next": "?screen=comms.closures"
    },
    "edit": {
      "handler": "closures.edit",
      "risk": "safe",
      "next": {
        "$text": "?screen=comms.closures&edit={target.id}"
      }
    },
    "delete": {
      "handler": "closures.delete",
      "risk": "irreversible",
      "confirm": {
        "title": "Eintrag löschen?",
        "body": "Die Antworten erwähnen ihn danach nicht mehr.",
        "confirmLabel": "Löschen",
        "tone": "danger"
      },
      "success": "Gelöscht",
      "next": {
        "$text": "?screen=comms.closures&deleted={target.id}"
      }
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Ferien & Events",
        "meta": "Zeiten ohne Training oder ohne reguläres Training. Vergangene Einträge verschwinden automatisch."
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "neutral",
        "title": "Die Antworten erwähnen einen Eintrag, wenn er in den nächsten 8 Wochen liegt oder gerade läuft und die empfohlenen Trainings betrifft, und schlagen das erste Training danach vor."
      }
    },
    {
      "layout": "card",
      "title": {
        "$if": {
          "$bind": "closures.form.id"
        },
        "then": "Eintrag bearbeiten",
        "else": "Neuer Eintrag"
      },
      "children": [
        {
          "component": "choice-group",
          "data": {
            "id": "cl-type",
            "name": "type",
            "legend": "Art",
            "type": "radio",
            "options": [
              {
                "value": "vacation",
                "label": "Ferien",
                "hint": "kein Training",
                "checked": {
                  "$not": {
                    "$eq": [
                      {
                        "$bind": "closures.form.type"
                      },
                      "event"
                    ]
                  }
                }
              },
              {
                "value": "event",
                "label": "Event",
                "hint": "reguläres Training fällt aus, z.B. Gurtprüfung",
                "checked": {
                  "$eq": [
                    {
                      "$bind": "closures.form.type"
                    },
                    "event"
                  ]
                }
              }
            ]
          }
        },
        {
          "layout": "grid",
          "min": "12rem",
          "children": [
            {
              "component": "field",
              "data": {
                "id": "cl-title",
                "name": "title",
                "label": "Titel",
                "placeholder": "z.B. Herbstferien, Gurtprüfung",
                "maxlength": 80,
                "value": {
                  "$bind": "closures.form.title"
                }
              }
            },
            {
              "component": "field",
              "data": {
                "id": "cl-from",
                "name": "from",
                "label": "Von",
                "type": "date",
                "required": true,
                "value": {
                  "$bind": "closures.form.from"
                }
              }
            },
            {
              "component": "field",
              "data": {
                "id": "cl-to",
                "name": "to",
                "label": "Bis",
                "type": "date",
                "required": true,
                "value": {
                  "$bind": "closures.form.to"
                }
              }
            }
          ]
        },
        {
          "component": "choice-group",
          "data": {
            "id": "cl-groups",
            "name": "groups",
            "legend": "Betroffene Trainings",
            "type": "checkbox",
            "hint": "Keins gewählt = alle Trainings",
            "options": {
              "$each": "closures.groups",
              "as": "g",
              "map": {
                "value": {
                  "$bind": "g.key"
                },
                "label": {
                  "$bind": "g.label"
                },
                "checked": {
                  "$bind": "g.checked"
                }
              }
            }
          }
        },
        {
          "component": "field",
          "data": {
            "id": "cl-note",
            "name": "note",
            "label": "Notiz",
            "optional": true,
            "hint": "Wird in den Antworten erwähnt",
            "placeholder": "z.B. Ab 19.10. wieder normales Training",
            "maxlength": 300,
            "value": {
              "$bind": "closures.form.note"
            }
          }
        },
        {
          "layout": "cluster",
          "children": [
            {
              "component": "button",
              "data": {
                "label": {
                  "$if": {
                    "$bind": "closures.form.id"
                  },
                  "then": "Änderungen speichern",
                  "else": "Hinzufügen"
                },
                "variant": "primary",
                "action": "save"
              }
            },
            {
              "component": "button",
              "if": {
                "$bind": "closures.form.id"
              },
              "data": {
                "label": "Abbrechen",
                "variant": "ghost",
                "href": "?screen=comms.closures"
              }
            }
          ]
        }
      ]
    },
    {
      "each": "closures.items",
      "as": "c",
      "node": {
        "component": "card",
        "if": {
          "$not": {
            "$eq": [
              {
                "$bind": "c.id"
              },
              {
                "$bind": "params.deleted"
              }
            ]
          }
        },
        "data": {
          "title": {
            "$bind": "c.title"
          },
          "headingLevel": 2,
          "badge": {
            "$if": {
              "$bind": "c.running"
            },
            "then": {
              "label": "läuft",
              "tone": "success"
            }
          },
          "meta": {
            "$text": "{c.range} · {c.kind}"
          },
          "body": {
            "$bind": "c.lines"
          },
          "actions": [
            {
              "label": "Bearbeiten",
              "action": "edit",
              "actionId": {
                "$bind": "c.id"
              }
            },
            {
              "label": "Löschen",
              "variant": "danger-ghost",
              "action": "delete",
              "actionId": {
                "$bind": "c.id"
              }
            }
          ]
        }
      }
    }
  ]
}

comms.help

anfragenscreen

Route /hilfe · 2 components: page-header, card · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.help",
  "version": 1,
  "app": "anfragen",
  "route": "/hilfe",
  "title": "Hilfe",
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Hilfe",
        "meta": "So funktioniert der Email Hub"
      }
    },
    {
      "layout": "grid",
      "min": "18rem",
      "children": [
        {
          "component": "card",
          "data": {
            "title": "1. Anfrage öffnen",
            "body": [
              "Neue Schnuppertraining-Anfragen aus dem Gmail-Label «ClaudeSchnupperer» erscheinen im Posteingang. Solange du eine Anfrage offen hast, sehen die anderen, dass du sie bearbeitest."
            ]
          }
        },
        {
          "component": "card",
          "data": {
            "title": "2. Antwort prüfen",
            "body": [
              "Die AI hat eine Antwort mit den passenden Trainingszeiten vorbereitet. Mit Du / ihr / Sie wird sie in der gewählten Anrede neu geschrieben, «Neu schreiben» erstellt eine neue Version."
            ]
          }
        },
        {
          "component": "card",
          "data": {
            "title": "3. Senden",
            "body": [
              "«Senden» schickt die Antwort und verschiebt die Anfrage nach «ClaudeDone». «Speichern» behält den Entwurf für alle im Team."
            ]
          }
        },
        {
          "component": "card",
          "data": {
            "title": "Ferien und Wochenplan",
            "body": [
              "Trainingszeiten kommen aus dem Trainingskalender (iCal), Ausfälle aus «Ferien & Events». Die Antworten erwähnen sie automatisch."
            ]
          }
        }
      ]
    }
  ]
}

comms.inquiries

anfragenscreen

Route /anfragen · 4 components: page-header, alert, list, empty-state · actions: sendAll (irreversible), assign (safe), close (reversible)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.inquiries",
  "version": 3,
  "app": "anfragen",
  "route": "/anfragen",
  "title": "Posteingang",
  "requires": [
    "comms.inquiries"
  ],
  "data": {
    "inquiries": {
      "source": "comms.inquiries.list"
    }
  },
  "actions": {
    "sendAll": {
      "handler": "comms.sendAll",
      "risk": "irreversible",
      "confirm": {
        "title": {
          "$join": [
            "Alle ",
            {
              "$count": "inquiries.items",
              "as": "r",
              "where": {
                "$and": [
                  {
                    "$eq": [
                      {
                        "$bind": "r.status"
                      },
                      "pending"
                    ]
                  },
                  {
                    "$not": {
                      "$bind": "r.done"
                    }
                  }
                ]
              }
            },
            " vorbereiteten Antworten jetzt absenden?"
          ]
        },
        "body": "Bitte stelle sicher, dass du alle Antworten geprüft hast.",
        "consequences": {
          "$each": "inquiries.items",
          "as": "r",
          "where": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "r.status"
                  },
                  "pending"
                ]
              },
              {
                "$not": {
                  "$bind": "r.done"
                }
              }
            ]
          },
          "map": {
            "$text": "An {r.name} <{r.fromEmail}>"
          }
        },
        "confirmLabel": "Alle senden",
        "tone": "primary"
      },
      "success": "Alle Antworten gesendet",
      "next": {
        "$join": [
          "?screen=comms.inquiries&sent=",
          {
            "$each": "inquiries.items",
            "as": "r",
            "where": {
              "$and": [
                {
                  "$eq": [
                    {
                      "$bind": "r.status"
                    },
                    "pending"
                  ]
                },
                {
                  "$not": {
                    "$bind": "r.done"
                  }
                }
              ]
            },
            "map": {
              "$bind": "r.id"
            }
          },
          ",",
          {
            "$bind": "params.sent"
          },
          "&moved=",
          {
            "$bind": "params.moved"
          }
        ]
      }
    },
    "assign": {
      "handler": "comms.assignInquiry",
      "risk": "safe",
      "success": "Du bearbeitest diese Anfrage – das Team sieht es."
    },
    "close": {
      "handler": "comms.closeInquiry",
      "risk": "reversible",
      "success": "Ohne Antwort erledigt"
    }
  },
  "body": [
    {
      "component": "page-header",
      "media": "phone",
      "data": {
        "title": "Posteingang",
        "meta": {
          "$if": {
            "$count": "inquiries.items",
            "as": "r",
            "where": {
              "$and": [
                {
                  "$eq": [
                    {
                      "$bind": "r.status"
                    },
                    "pending"
                  ]
                },
                {
                  "$not": {
                    "$bind": "r.done"
                  }
                }
              ]
            }
          },
          "then": {
            "$join": [
              {
                "$count": "inquiries.items",
                "as": "r",
                "where": {
                  "$and": [
                    {
                      "$eq": [
                        {
                          "$bind": "r.status"
                        },
                        "pending"
                      ]
                    },
                    {
                      "$not": {
                        "$bind": "r.done"
                      }
                    }
                  ]
                }
              },
              " offen"
            ]
          },
          "else": "Alles beantwortet"
        }
      }
    },
    {
      "component": "alert",
      "if": {
        "$and": [
          {
            "$flag": "anfragen.overdue-warning"
          },
          {
            "$bind": "inquiries.overdue"
          }
        ]
      },
      "data": {
        "tone": "warning",
        "title": {
          "$bind": "inquiries.overdue.title"
        },
        "body": "Familien entscheiden sich oft für den Verein, der zuerst antwortet.",
        "link": {
          "label": "Jetzt beantworten",
          "href": {
            "$text": "?screen=comms.inquiry-reply&id={inquiries.overdue.id}&sent={params.sent}&moved={params.moved}"
          }
        }
      }
    },
    {
      "component": "page-header",
      "media": "wide",
      "data": {
        "title": "Posteingang",
        "meta": {
          "$join": [
            {
              "$count": "inquiries.items",
              "as": "r",
              "where": {
                "$and": [
                  {
                    "$eq": [
                      {
                        "$bind": "r.status"
                      },
                      "pending"
                    ]
                  },
                  {
                    "$not": {
                      "$bind": "r.done"
                    }
                  }
                ]
              }
            },
            " ausstehend · ",
            {
              "$count": "inquiries.items",
              "as": "r",
              "where": {
                "$or": [
                  {
                    "$eq": [
                      {
                        "$bind": "r.status"
                      },
                      "sent"
                    ]
                  },
                  {
                    "$bind": "r.sent"
                  }
                ]
              }
            },
            " beantwortet"
          ]
        },
        "actions": {
          "$if": {
            "$gte": [
              {
                "$count": "inquiries.items",
                "as": "r",
                "where": {
                  "$and": [
                    {
                      "$eq": [
                        {
                          "$bind": "r.status"
                        },
                        "pending"
                      ]
                    },
                    {
                      "$not": {
                        "$bind": "r.done"
                      }
                    }
                  ]
                }
              },
              2
            ]
          },
          "then": [
            {
              "label": {
                "$join": [
                  "Alle senden (",
                  {
                    "$count": "inquiries.items",
                    "as": "r",
                    "where": {
                      "$and": [
                        {
                          "$eq": [
                            {
                              "$bind": "r.status"
                            },
                            "pending"
                          ]
                        },
                        {
                          "$not": {
                            "$bind": "r.done"
                          }
                        }
                      ]
                    }
                  },
                  ")"
                ]
              },
              "icon": "mail",
              "action": "sendAll"
            }
          ],
          "else": []
        }
      }
    },
    {
      "component": "alert",
      "media": "wide",
      "if": {
        "$gte": [
          {
            "$count": "inquiries.items",
            "as": "r",
            "where": {
              "$and": [
                {
                  "$eq": [
                    {
                      "$bind": "r.status"
                    },
                    "pending"
                  ]
                },
                {
                  "$not": {
                    "$bind": "r.done"
                  }
                }
              ]
            }
          },
          1
        ]
      },
      "data": {
        "tone": "neutral",
        "title": "Klicke auf eine Anfrage, um die Antwort zu prüfen und zu bearbeiten."
      }
    },
    {
      "component": "list",
      "if": {
        "$count": "inquiries.items",
        "as": "r",
        "where": {
          "$and": [
            {
              "$eq": [
                {
                  "$bind": "r.status"
                },
                "pending"
              ]
            },
            {
              "$not": {
                "$bind": "r.done"
              }
            }
          ]
        }
      },
      "data": {
        "label": "Ausstehende Anfragen",
        "items": {
          "$each": "inquiries.items",
          "as": "r",
          "where": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "r.status"
                  },
                  "pending"
                ]
              },
              {
                "$not": {
                  "$bind": "r.done"
                }
              }
            ]
          },
          "map": {
            "id": {
              "$bind": "r.id"
            },
            "title": {
              "$bind": "r.name"
            },
            "time": {
              "$bind": "r.time"
            },
            "meta": {
              "$bind": "r.subject"
            },
            "excerpt": {
              "$bind": "r.preview"
            },
            "avatar": {
              "$bind": "r.initials"
            },
            "tags": {
              "$bind": "r.tags"
            },
            "href": {
              "$text": "?screen=comms.inquiry-reply&id={r.id}&sent={params.sent}&moved={params.moved}"
            },
            "actions": {
              "$if": {
                "$flag": "anfragen.swipe"
              },
              "then": [
                {
                  "action": "assign",
                  "label": "Ich übernehme das",
                  "icon": "user"
                },
                {
                  "action": "close",
                  "label": "Ohne Antwort erledigen",
                  "icon": "check"
                }
              ]
            },
            "swipe": {
              "$if": {
                "$flag": "anfragen.swipe"
              },
              "then": {
                "start": {
                  "action": "assign",
                  "label": "Übernehmen",
                  "icon": "user",
                  "tone": "accent"
                },
                "end": {
                  "action": "close",
                  "label": "Erledigt",
                  "icon": "check",
                  "tone": "neutral"
                }
              }
            }
          }
        }
      }
    },
    {
      "component": "empty-state",
      "if": {
        "$not": {
          "$count": "inquiries.items",
          "as": "r",
          "where": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "r.status"
                  },
                  "pending"
                ]
              },
              {
                "$not": {
                  "$bind": "r.done"
                }
              }
            ]
          }
        }
      },
      "data": {
        "icon": "check-circle",
        "title": "Alles erledigt!",
        "text": "Keine neuen Schnuppertraining-Anfragen vorhanden. Sobald neue Anfragen eintreffen, erscheinen sie hier automatisch.",
        "action": {
          "label": "Gesendet",
          "href": "?screen=comms.sent"
        }
      }
    }
  ]
}

comms.inquiry-reply

anfragenflow · 2 steps

Route /anfragen/:id · 8 components: alert, badge, message, field, segmented, kv, switch, button · actions: send (irreversible), save (safe), template (safe), moveToInbox (irreversible), assign (safe), close (reversible)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.inquiry-reply",
  "kind": "flow",
  "version": 3,
  "app": "anfragen",
  "route": "/anfragen/:id",
  "title": {
    "$text": "{inquiry.from} · {inquiry.subject}"
  },
  "requires": [
    "comms.inquiries"
  ],
  "modes": {
    "guided": false,
    "compact": true
  },
  "density": "dense",
  "data": {
    "inquiry": {
      "source": "comms.inquiries.get",
      "params": {
        "id": {
          "$bind": "params.id"
        }
      }
    },
    "inquiries": {
      "source": "comms.inquiries.list"
    }
  },
  "back": {
    "label": "Posteingang",
    "href": {
      "$text": "?screen=comms.inquiries&sent={params.sent}&moved={params.moved}"
    }
  },
  "aside": [
    {
      "component": "list",
      "data": {
        "label": "Ausstehende Anfragen",
        "items": {
          "$each": "inquiries.items",
          "as": "r",
          "where": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "r.status"
                  },
                  "pending"
                ]
              },
              {
                "$not": {
                  "$bind": "r.done"
                }
              }
            ]
          },
          "map": {
            "id": {
              "$bind": "r.id"
            },
            "title": {
              "$bind": "r.name"
            },
            "time": {
              "$bind": "r.time"
            },
            "meta": {
              "$bind": "r.subject"
            },
            "excerpt": {
              "$bind": "r.preview"
            },
            "avatar": {
              "$bind": "r.initials"
            },
            "tags": {
              "$bind": "r.tags"
            },
            "href": {
              "$text": "?screen=comms.inquiry-reply&id={r.id}&sent={params.sent}&moved={params.moved}"
            },
            "current": {
              "$eq": [
                {
                  "$bind": "r.id"
                },
                {
                  "$bind": "params.id"
                }
              ]
            },
            "actions": {
              "$if": {
                "$flag": "anfragen.swipe"
              },
              "then": [
                {
                  "action": "assign",
                  "label": "Ich übernehme das",
                  "icon": "user"
                },
                {
                  "action": "close",
                  "label": "Ohne Antwort erledigen",
                  "icon": "check"
                }
              ]
            },
            "swipe": {
              "$if": {
                "$flag": "anfragen.swipe"
              },
              "then": {
                "start": {
                  "action": "assign",
                  "label": "Übernehmen",
                  "icon": "user",
                  "tone": "accent"
                },
                "end": {
                  "action": "close",
                  "label": "Erledigt",
                  "icon": "check",
                  "tone": "neutral"
                }
              }
            }
          }
        }
      }
    }
  ],
  "asideLabel": "Ausstehende Anfragen",
  "readonly": {
    "$bind": "inquiry.lock"
  },
  "draftScope": {
    "$bind": "params.id"
  },
  "derive": {
    "reply": {
      "from": [
        "register",
        "group",
        "slot"
      ],
      "source": "comms.inquiries.draft",
      "rewritten": "Antwort neu geschrieben – deine Änderungen wurden ersetzt."
    }
  },
  "actions": {
    "send": {
      "handler": "comms.sendReply",
      "risk": "irreversible",
      "success": {
        "$if": {
          "$and": [
            {
              "$flag": "anfragen.next-inquiry"
            },
            {
              "$bind": "inquiry.nextId"
            }
          ]
        },
        "then": {
          "$text": "Antwort an {inquiry.from} gesendet · nächste Anfrage"
        },
        "else": {
          "$text": "Antwort gesendet! An: {inquiry.fromEmail}"
        }
      }
    },
    "save": {
      "handler": "comms.saveReply",
      "risk": "safe",
      "success": "Entwurf gespeichert – für alle im Team sichtbar"
    },
    "template": {
      "handler": "comms.saveTemplate",
      "risk": "safe",
      "success": "Als Vorlage gespeichert"
    },
    "moveToInbox": {
      "handler": "comms.moveToInbox",
      "risk": "irreversible",
      "confirm": {
        "title": "Keine Schnuppertraining-Anfrage?",
        "body": "Die E-Mail wird zurück in den normalen Gmail-Posteingang verschoben und hier entfernt.",
        "confirmLabel": "Zurück in Posteingang",
        "tone": "danger"
      },
      "success": "E-Mail zurück in den Posteingang verschoben",
      "next": {
        "$text": "?screen=comms.inquiries&sent={params.sent}&moved={params.id},{params.moved}"
      }
    },
    "assign": {
      "handler": "comms.assignInquiry",
      "risk": "safe",
      "success": "Du bearbeitest diese Anfrage – das Team sieht es."
    },
    "close": {
      "handler": "comms.closeInquiry",
      "risk": "reversible",
      "success": "Ohne Antwort erledigt"
    }
  },
  "submit": {
    "action": "send",
    "label": "Senden"
  },
  "done": {
    "href": {
      "$if": {
        "$and": [
          {
            "$flag": "anfragen.next-inquiry"
          },
          {
            "$bind": "inquiry.nextId"
          }
        ]
      },
      "then": {
        "$text": "?screen=comms.inquiry-reply&id={inquiry.nextId}&sent={params.id},{params.sent}&moved={params.moved}"
      },
      "else": {
        "$text": "?screen=comms.inquiries&sent={params.id},{params.sent}&moved={params.moved}"
      }
    }
  },
  "steps": [
    {
      "id": "inquiry",
      "title": "Originalanfrage",
      "help": "Die Anfrage, wie sie eingegangen ist. Die Stichworte darüber hat Club Hub aus der Nachricht erkannt (Gruppe, Personen, Sprache, Anrede).",
      "body": [
        {
          "component": "alert",
          "if": {
            "$bind": "inquiry.lock"
          },
          "data": {
            "tone": "warning",
            "title": {
              "$text": "Wird gerade von {inquiry.lock} bearbeitet"
            },
            "body": "Du kannst die Antwort lesen, aber nicht ändern."
          }
        },
        {
          "layout": "cluster",
          "children": [
            {
              "each": "inquiry.tags",
              "as": "t",
              "node": {
                "component": "badge",
                "data": {
                  "label": {
                    "$bind": "t.label"
                  },
                  "tone": {
                    "$bind": "t.tone"
                  }
                }
              }
            }
          ]
        },
        {
          "component": "message",
          "data": {
            "label": "Nachricht",
            "from": {
              "$text": "{inquiry.from} <{inquiry.fromEmail}>"
            },
            "dateLabel": {
              "$bind": "inquiry.dateLabel"
            },
            "subject": {
              "$bind": "inquiry.subject"
            },
            "body": {
              "$bind": "inquiry.body"
            },
            "clamp": 7
          }
        }
      ]
    },
    {
      "id": "reply",
      "title": "Vorbereitete Antwort",
      "help": "Die AI hat die Antwort mit den Trainingszeiten der erkannten Gruppe vorbereitet. Du / ihr / Sie schreibt sie in dieser Anrede neu, «Neu schreiben» erstellt eine neue Version. «Speichern» macht den Entwurf für alle im Team sichtbar.",
      "body": [
        {
          "layout": "grid",
          "min": "14rem",
          "if": {
            "$and": [
              {
                "$flag": "anfragen.trial-date"
              },
              {
                "$not": {
                  "$bind": "inquiry.lock"
                }
              }
            ]
          },
          "children": [
            {
              "component": "field",
              "data": {
                "id": "group",
                "name": "group",
                "label": "Gruppe",
                "control": "select",
                "required": true,
                "hint": {
                  "$bind": "inquiry.groupHint"
                },
                "value": {
                  "$bind": "inquiry.suggestedGroup"
                },
                "options": {
                  "$each": "trial.groupOptions",
                  "as": "o",
                  "map": {
                    "value": {
                      "$bind": "o.value"
                    },
                    "label": {
                      "$bind": "o.label"
                    }
                  }
                }
              }
            },
            {
              "each": "trial.groups",
              "as": "g",
              "node": {
                "component": "field",
                "if": {
                  "$eq": [
                    {
                      "$bind": "values.group"
                    },
                    {
                      "$bind": "g.label"
                    }
                  ]
                },
                "data": {
                  "id": {
                    "$text": "slot-{g.key}"
                  },
                  "name": "slot",
                  "label": "Probetraining",
                  "control": "select",
                  "required": true,
                  "hint": "Aus dem Trainingskalender",
                  "value": {
                    "$bind": "g.suggested"
                  },
                  "options": {
                    "$each": "g.slots",
                    "as": "s",
                    "map": {
                      "value": {
                        "$bind": "s.label"
                      },
                      "label": {
                        "$if": {
                          "$bind": "s.closed"
                        },
                        "then": {
                          "$text": "{s.label} – Ferien"
                        },
                        "else": {
                          "$bind": "s.label"
                        }
                      },
                      "disabled": {
                        "$bind": "s.closed"
                      }
                    }
                  }
                }
              }
            }
          ]
        },
        {
          "component": "segmented",
          "if": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "inquiry.language"
                  },
                  "de"
                ]
              },
              {
                "$not": {
                  "$bind": "inquiry.lock"
                }
              }
            ]
          },
          "data": {
            "id": "register",
            "name": "register",
            "legend": "Anrede",
            "kind": "address",
            "value": {
              "$bind": "inquiry.register"
            },
            "options": [
              {
                "value": "du",
                "label": "Du"
              },
              {
                "value": "ihr",
                "label": "ihr"
              },
              {
                "value": "sie",
                "label": "Sie"
              }
            ]
          }
        },
        {
          "component": "field",
          "data": {
            "id": "reply",
            "name": "reply",
            "label": "Antwort",
            "control": "textarea",
            "rows": 14,
            "required": true,
            "hint": {
              "$bind": "inquiry.draftMeta"
            },
            "disabled": {
              "$not": {
                "$not": {
                  "$bind": "inquiry.lock"
                }
              }
            }
          }
        },
        {
          "component": "kv",
          "data": {
            "items": [
              {
                "term": "An",
                "value": {
                  "$text": "{inquiry.from} <{inquiry.fromEmail}>"
                }
              }
            ]
          }
        },
        {
          "component": "switch",
          "if": {
            "$and": [
              {
                "$flag": "anfragen.trial-date"
              },
              {
                "$not": {
                  "$bind": "inquiry.lock"
                }
              }
            ]
          },
          "data": {
            "id": "remind",
            "name": "remind",
            "label": "Am Vortag erinnern",
            "hint": "Kurze E-Mail mit Adresse und was mitbringen.",
            "checked": true
          }
        },
        {
          "layout": "cluster",
          "if": {
            "$not": {
              "$bind": "inquiry.lock"
            }
          },
          "children": [
            {
              "component": "button",
              "data": {
                "label": "Speichern",
                "action": "save",
                "actionId": {
                  "$bind": "inquiry.id"
                }
              }
            },
            {
              "component": "button",
              "data": {
                "label": "Neu schreiben",
                "icon": "sparkles",
                "kind": "ai",
                "action": "flow-derive",
                "actionId": "reply"
              }
            },
            {
              "component": "button",
              "data": {
                "label": "Vorlage",
                "icon": "list",
                "action": "template",
                "actionId": {
                  "$bind": "inquiry.id"
                }
              }
            },
            {
              "component": "button",
              "data": {
                "label": "Zurück in Posteingang",
                "variant": "danger-ghost",
                "icon": "arrow-left",
                "action": "moveToInbox",
                "actionId": {
                  "$bind": "inquiry.id"
                }
              }
            }
          ]
        },
        {
          "component": "alert",
          "if": {
            "$not": {
              "$bind": "inquiry.lock"
            }
          },
          "data": {
            "tone": "neutral",
            "title": "Tipp: Prüfe die Antwort, bevor du sie absendest. Mit «Speichern» wird der Entwurf für alle Teamkollegen sichtbar."
          }
        }
      ]
    }
  ],
  "review": {
    "confirm": true,
    "title": {
      "$text": "Antwort jetzt an {inquiry.from} senden?"
    },
    "intro": {
      "$text": "An: {inquiry.from} <{inquiry.fromEmail}>"
    },
    "backLabel": "Abbrechen",
    "summary": [
      {
        "component": "message",
        "if": {
          "$flag": "anfragen.review-effects"
        },
        "data": {
          "direction": "out",
          "label": "So geht die Antwort raus",
          "from": "Taekwondo Bern <[email protected]>",
          "to": {
            "$text": "{inquiry.from} <{inquiry.fromEmail}>"
          },
          "subject": {
            "$text": "Re: {inquiry.subject}"
          },
          "body": {
            "$if": {
              "$bind": "values.reply"
            },
            "then": {
              "$bind": "values.reply"
            },
            "else": "(leer)"
          }
        }
      }
    ],
    "effectsTitle": "Was passiert, wenn du sendest:",
    "effects": {
      "$if": {
        "$flag": "anfragen.review-effects"
      },
      "then": {
        "$if": {
          "$flag": "anfragen.trial-date"
        },
        "then": [
          {
            "$text": "Die Antwort geht an {inquiry.fromEmail}."
          },
          {
            "$text": "{inquiry.trialLabel} ist für {values.slot} als Probetraining notiert – das Trainingsteam sieht es."
          },
          {
            "$if": {
              "$bind": "values.remind"
            },
            "then": "Am Vortag geht eine Erinnerung raus.",
            "else": "Es geht keine Erinnerung raus."
          },
          "Die Anfrage erscheint unter «Gesendet» und im Sende-Log."
        ],
        "else": [
          {
            "$text": "Die Antwort geht an {inquiry.fromEmail}."
          },
          "Die Anfrage wird in Gmail nach «ClaudeDone» verschoben und erscheint unter «Gesendet» und im Sende-Log."
        ]
      },
      "else": []
    }
  }
}

comms.inquiry

anfragenscreen

Route /anfragen/gesendet/:id · 5 components: alert, page-header, message, kv, list · actions: sendRegistrationLink (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.inquiry",
  "version": 2,
  "app": "anfragen",
  "route": "/anfragen/gesendet/:id",
  "title": {
    "$text": "Anfrage von {inquiry.from}"
  },
  "requires": [
    "comms.inquiries"
  ],
  "data": {
    "inquiry": {
      "source": "comms.inquiries.get",
      "params": {
        "id": {
          "$bind": "params.id"
        }
      }
    }
  },
  "actions": {
    "sendRegistrationLink": {
      "handler": "comms.sendRegistrationLink",
      "risk": "safe",
      "success": {
        "$text": "Link zum Anmeldeformular an {inquiry.fromEmail} geschickt"
      }
    }
  },
  "body": [
    {
      "component": "alert",
      "if": {
        "$not": {
          "$flag": "anfragen.history"
        }
      },
      "data": {
        "tone": "neutral",
        "title": "Diese Seite gehört zur Funktion «Verlauf je Anfrage»",
        "body": "Sie ist ausgeschaltet; schalte sie unter «Funktionen» ein."
      }
    },
    {
      "component": "page-header",
      "data": {
        "title": {
          "$bind": "inquiry.from"
        },
        "meta": {
          "$text": "Gesendet von {inquiry.sentBy} · {inquiry.sentLabel}"
        },
        "back": {
          "label": "Gesendet",
          "href": "?screen=comms.sent"
        },
        "actions": [
          {
            "label": "Anmeldeformular schicken",
            "icon": "mail",
            "action": "sendRegistrationLink",
            "actionId": {
              "$bind": "inquiry.id"
            }
          }
        ]
      }
    },
    {
      "layout": "split",
      "children": [
        {
          "layout": "stack",
          "children": [
            {
              "component": "message",
              "data": {
                "label": "Anfrage",
                "from": {
                  "$text": "{inquiry.from} <{inquiry.fromEmail}>"
                },
                "dateLabel": {
                  "$bind": "inquiry.dateLabel"
                },
                "subject": {
                  "$bind": "inquiry.subject"
                },
                "body": {
                  "$bind": "inquiry.body"
                }
              }
            },
            {
              "component": "message",
              "data": {
                "direction": "out",
                "label": {
                  "$text": "Antwort von {inquiry.sentBy}"
                },
                "from": "Taekwondo Bern <[email protected]>",
                "to": {
                  "$text": "{inquiry.from} <{inquiry.fromEmail}>"
                },
                "dateLabel": {
                  "$bind": "inquiry.sentLabel"
                },
                "body": {
                  "$bind": "inquiry.replyDraft"
                }
              }
            }
          ]
        },
        {
          "layout": "stack",
          "children": [
            {
              "component": "kv",
              "data": {
                "items": [
                  {
                    "term": "Stand",
                    "value": {
                      "$bind": "inquiry.outcome.label"
                    }
                  }
                ]
              }
            },
            {
              "layout": "section",
              "id": "verlauf",
              "title": "Verlauf",
              "children": [
                {
                  "component": "list",
                  "data": {
                    "label": "Verlauf der Anfrage",
                    "items": {
                      "$each": "inquiry.history",
                      "as": "h",
                      "map": {
                        "id": {
                          "$bind": "h.id"
                        },
                        "title": {
                          "$bind": "h.title"
                        },
                        "meta": {
                          "$bind": "h.meta"
                        }
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

comms.more

anfragenscreen

Route /mehr · 2 components: page-header, list · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.more",
  "version": 1,
  "app": "anfragen",
  "route": "/mehr",
  "title": "Mehr",
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Mehr"
      }
    },
    {
      "component": "list",
      "data": {
        "label": "Weitere Seiten",
        "items": [
          {
            "id": "schedule",
            "title": "Wochenplan",
            "meta": "Trainingszeiten aller Gruppen",
            "href": "?screen=comms.schedule"
          },
          {
            "id": "admin",
            "title": "Benutzer",
            "meta": "Gmail Labels, Betreff, Wochenplan, Team",
            "href": "?screen=comms.admin"
          },
          {
            "id": "sendlog",
            "title": "Sende-Log",
            "meta": "Wer hat wann an wen geantwortet",
            "href": "?screen=comms.sendlog"
          },
          {
            "id": "help",
            "title": "Hilfe",
            "meta": "So funktioniert der Email Hub",
            "href": "?screen=comms.help"
          },
          {
            "id": "logout",
            "title": "Abmelden",
            "meta": "Sandra Meier · Email Responder",
            "href": "#"
          }
        ]
      }
    }
  ]
}

comms.schedule

anfragenscreen

Route /wochenplan · 4 components: page-header, alert, chip-group, table · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.schedule",
  "version": 1,
  "app": "anfragen",
  "route": "/wochenplan",
  "title": "Wochenplan",
  "data": {
    "schedule": {
      "source": "schedule.get"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Wochenplan",
        "meta": "Trainingszeiten für alle Gruppen — Quelle: Trainingskalender des Vereins (iCal)"
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "neutral",
        "title": "Diese Zeiten werden automatisch in die generierten Antworten eingefügt, passend zur erkannten Altersgruppe."
      }
    },
    {
      "component": "chip-group",
      "data": {
        "label": "Sortierung",
        "name": "sort",
        "chips": [
          {
            "value": "class",
            "label": "Nach Klasse",
            "pressed": {
              "$not": {
                "$eq": [
                  {
                    "$bind": "params.sort"
                  },
                  "day"
                ]
              }
            },
            "href": "?screen=comms.schedule&sort=class"
          },
          {
            "value": "day",
            "label": "Nach Tag",
            "pressed": {
              "$eq": [
                {
                  "$bind": "params.sort"
                },
                "day"
              ]
            },
            "href": "?screen=comms.schedule&sort=day"
          }
        ]
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "warning",
        "title": "Ausfälle & Änderungen",
        "body": {
          "$bind": "schedule.cancellationsText"
        }
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "info",
        "title": "Ferien & Events",
        "body": {
          "$bind": "schedule.closuresText"
        },
        "link": {
          "label": "bearbeiten",
          "href": "?screen=comms.closures"
        }
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "neutral",
        "title": "Besondere Termine",
        "body": {
          "$bind": "schedule.specialText"
        }
      }
    },
    {
      "layout": "grid",
      "min": "20rem",
      "if": {
        "$not": {
          "$eq": [
            {
              "$bind": "params.sort"
            },
            "day"
          ]
        }
      },
      "children": [
        {
          "each": "schedule.groups",
          "as": "g",
          "node": {
            "component": "table",
            "data": {
              "caption": {
                "$bind": "g.label"
              },
              "density": "dense",
              "stack": false,
              "columns": [
                {
                  "key": "day",
                  "label": "Tag"
                },
                {
                  "key": "time",
                  "label": "Zeit"
                },
                {
                  "key": "name",
                  "label": "Training"
                }
              ],
              "rows": {
                "$each": "g.sessions",
                "as": "s",
                "map": {
                  "cells": {
                    "day": {
                      "$bind": "s.day"
                    },
                    "time": {
                      "$bind": "s.time"
                    },
                    "name": {
                      "$bind": "s.name"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "layout": "grid",
      "min": "20rem",
      "if": {
        "$eq": [
          {
            "$bind": "params.sort"
          },
          "day"
        ]
      },
      "children": [
        {
          "each": "schedule.days",
          "as": "d",
          "node": {
            "component": "table",
            "data": {
              "caption": {
                "$bind": "d.day"
              },
              "density": "dense",
              "stack": false,
              "columns": [
                {
                  "key": "time",
                  "label": "Zeit"
                },
                {
                  "key": "name",
                  "label": "Training"
                },
                {
                  "key": "group",
                  "label": "Gruppe"
                }
              ],
              "rows": {
                "$each": "d.sessions",
                "as": "s",
                "map": {
                  "cells": {
                    "time": {
                      "$bind": "s.time"
                    },
                    "name": {
                      "$bind": "s.name"
                    },
                    "group": {
                      "$bind": "s.group"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}

comms.sendlog

anfragenscreen

Route /sende-log · 2 components: page-header, table · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.sendlog",
  "version": 1,
  "app": "anfragen",
  "route": "/sende-log",
  "title": "Sende-Log",
  "data": {
    "log": {
      "source": "emails.sendLog"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Sende-Log",
        "meta": "Protokoll aller gesendeten Antworten — wer hat wann an wen geantwortet"
      }
    },
    {
      "component": "table",
      "data": {
        "caption": "Gesendete Antworten",
        "captionHidden": true,
        "columns": [
          {
            "key": "to",
            "label": "Empfänger"
          },
          {
            "key": "subject",
            "label": "Betreff"
          },
          {
            "key": "category",
            "label": "Kategorie"
          },
          {
            "key": "by",
            "label": "Gesendet von"
          },
          {
            "key": "at",
            "label": "Zeitpunkt"
          }
        ],
        "rowHeaderKey": "to",
        "rows": {
          "$each": "log.entries",
          "as": "l",
          "map": {
            "id": {
              "$bind": "l.id"
            },
            "cells": {
              "to": {
                "$text": "{l.from} · {l.fromEmail}"
              },
              "subject": {
                "$bind": "l.subject"
              },
              "category": {
                "badge": {
                  "label": {
                    "$bind": "l.category"
                  }
                }
              },
              "by": {
                "$bind": "l.sentBy"
              },
              "at": {
                "$bind": "l.sentLabel"
              }
            }
          }
        }
      }
    }
  ]
}

comms.sent

anfragenscreen

Route /gesendet · 3 components: page-header, message, button · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "comms.sent",
  "version": 1,
  "app": "anfragen",
  "route": "/gesendet",
  "title": "Gesendet",
  "data": {
    "categories": {
      "source": "emails.categories"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Gesendete Antworten",
        "meta": {
          "$join": [
            {
              "$bind": "categories.total"
            },
            " beantwortete Anfragen, sortiert nach Trainingsgruppe"
          ]
        }
      }
    },
    {
      "each": "categories.groups",
      "as": "g",
      "node": {
        "layout": "section",
        "title": {
          "$text": "{g.name} · {g.age} · {g.count}"
        },
        "children": [
          {
            "each": "g.items",
            "as": "e",
            "node": {
              "layout": "details",
              "group": "sent",
              "title": {
                "$bind": "e.from"
              },
              "meta": {
                "$bind": "e.subject"
              },
              "aside": {
                "$text": "{e.sentBy} · {e.dateLabel}"
              },
              "children": [
                {
                  "layout": "grid",
                  "min": "20rem",
                  "children": [
                    {
                      "component": "message",
                      "data": {
                        "label": "Originalanfrage",
                        "from": {
                          "$text": "{e.from} <{e.fromEmail}>"
                        },
                        "dateLabel": {
                          "$bind": "e.dateLabel"
                        },
                        "body": {
                          "$bind": "e.body"
                        }
                      }
                    },
                    {
                      "component": "message",
                      "data": {
                        "direction": "out",
                        "label": "Gesendete Antwort",
                        "from": "Taekwondo Bern <[email protected]>",
                        "to": {
                          "$text": "{e.from} <{e.fromEmail}>"
                        },
                        "dateLabel": {
                          "$bind": "e.sentLabel"
                        },
                        "body": {
                          "$bind": "e.replyDraft"
                        }
                      }
                    }
                  ]
                },
                {
                  "layout": "cluster",
                  "if": {
                    "$flag": "anfragen.history"
                  },
                  "children": [
                    {
                      "component": "button",
                      "data": {
                        "label": "Verlauf und nächste Schritte",
                        "icon": "list",
                        "href": {
                          "$text": "?screen=comms.inquiry&id={e.id}"
                        }
                      }
                    }
                  ]
                }
              ]
            }
          }
        ]
      }
    }
  ]
}

emailhub.admin

email-hubscreen

Route /benutzer · 5 components: page-header, field, button, table, alert · actions: saveSettings (safe), saveSchedule (safe), addClass (safe), addSession (safe), removeSession (reversible), removeClass (irreversible)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.admin",
  "version": 1,
  "app": "email-hub",
  "route": "/benutzer",
  "title": "Benutzer",
  "data": {
    "settings": {
      "source": "settings.get"
    },
    "schedule": {
      "source": "schedule.get"
    },
    "users": {
      "source": "users.list"
    }
  },
  "actions": {
    "saveSettings": {
      "handler": "settings.save",
      "risk": "safe",
      "success": "Einstellungen gespeichert"
    },
    "saveSchedule": {
      "handler": "schedule.save",
      "risk": "safe",
      "success": "Wochenplan gespeichert"
    },
    "addClass": {
      "handler": "schedule.addClass",
      "risk": "safe",
      "success": "Neue Klasse hinzugefügt – Bezeichnung und Trainings ausfüllen"
    },
    "addSession": {
      "handler": "schedule.addSession",
      "risk": "safe",
      "success": "Training hinzugefügt"
    },
    "removeSession": {
      "handler": "schedule.removeSession",
      "risk": "reversible",
      "success": "Training entfernt"
    },
    "removeClass": {
      "handler": "schedule.removeClass",
      "risk": "irreversible",
      "confirm": {
        "title": "Klasse löschen?",
        "body": "Die Klasse und ihre Trainings verschwinden aus dem Wochenplan und aus den Antworten.",
        "confirmLabel": "Löschen",
        "tone": "danger"
      },
      "success": "Klasse gelöscht"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Einstellungen",
        "meta": "Email Workflow-Konfiguration"
      }
    },
    {
      "layout": "card",
      "title": "Gmail Labels",
      "children": [
        {
          "layout": "grid",
          "min": "14rem",
          "children": [
            {
              "component": "field",
              "data": {
                "id": "source-label",
                "name": "sourceLabel",
                "label": "Posteingang (Quelle)",
                "control": "select",
                "hint": "Gmail-Label, aus dem neue Anfragen geladen werden",
                "value": {
                  "$bind": "settings.sourceLabel"
                },
                "options": {
                  "$each": "settings.labels",
                  "as": "l",
                  "map": {
                    "value": {
                      "$bind": "l"
                    },
                    "label": {
                      "$bind": "l"
                    }
                  }
                }
              }
            },
            {
              "component": "field",
              "data": {
                "id": "done-label",
                "name": "doneLabel",
                "label": "Erledigt (Ziel)",
                "control": "select",
                "hint": "Gmail-Label, wohin beantwortete E-Mails verschoben werden",
                "value": {
                  "$bind": "settings.doneLabel"
                },
                "options": {
                  "$each": "settings.labels",
                  "as": "l",
                  "map": {
                    "value": {
                      "$bind": "l"
                    },
                    "label": {
                      "$bind": "l"
                    }
                  }
                }
              }
            }
          ]
        }
      ]
    },
    {
      "layout": "card",
      "title": "Antwort-Betreff",
      "children": [
        {
          "layout": "grid",
          "min": "14rem",
          "children": [
            {
              "component": "field",
              "data": {
                "id": "subject-de",
                "name": "replySubjectDe",
                "label": "Deutsch",
                "value": {
                  "$bind": "settings.replySubjectDe"
                }
              }
            },
            {
              "component": "field",
              "data": {
                "id": "subject-en",
                "name": "replySubjectEn",
                "label": "English",
                "value": {
                  "$bind": "settings.replySubjectEn"
                }
              }
            }
          ]
        },
        {
          "layout": "cluster",
          "children": [
            {
              "component": "button",
              "data": {
                "label": "Einstellungen speichern",
                "variant": "primary",
                "action": "saveSettings"
              }
            }
          ]
        }
      ]
    },
    {
      "layout": "section",
      "id": "wochenplan",
      "title": "Wochenplan",
      "children": [
        {
          "layout": "cluster",
          "children": [
            {
              "component": "button",
              "data": {
                "label": "Klasse hinzufügen",
                "icon": "plus",
                "action": "addClass"
              }
            },
            {
              "component": "button",
              "data": {
                "label": "Speichern",
                "variant": "primary",
                "action": "saveSchedule"
              }
            }
          ]
        },
        {
          "each": "schedule.groups",
          "as": "c",
          "node": {
            "layout": "details",
            "group": "classes",
            "title": {
              "$bind": "c.label"
            },
            "meta": {
              "$text": "{c.shortSchedule} · Alter {c.ageRange}"
            },
            "aside": {
              "$join": [
                {
                  "$count": "c.sessions"
                },
                " Trainings"
              ]
            },
            "children": [
              {
                "layout": "grid",
                "min": "12rem",
                "children": [
                  {
                    "component": "field",
                    "data": {
                      "id": {
                        "$text": "label-{c.key}"
                      },
                      "name": {
                        "$text": "label-{c.key}"
                      },
                      "label": "Bezeichnung",
                      "value": {
                        "$bind": "c.label"
                      }
                    }
                  },
                  {
                    "component": "field",
                    "data": {
                      "id": {
                        "$text": "age-{c.key}"
                      },
                      "name": {
                        "$text": "age-{c.key}"
                      },
                      "label": "Altersgruppe",
                      "value": {
                        "$bind": "c.ageRange"
                      }
                    }
                  },
                  {
                    "component": "field",
                    "data": {
                      "id": {
                        "$text": "short-{c.key}"
                      },
                      "name": {
                        "$text": "short-{c.key}"
                      },
                      "label": "Kurzplan (für Antworten)",
                      "value": {
                        "$bind": "c.shortSchedule"
                      }
                    }
                  }
                ]
              },
              {
                "component": "table",
                "data": {
                  "caption": {
                    "$text": "Trainings {c.label}"
                  },
                  "captionHidden": true,
                  "density": "dense",
                  "columns": [
                    {
                      "key": "day",
                      "label": "Tag"
                    },
                    {
                      "key": "time",
                      "label": "Zeit"
                    },
                    {
                      "key": "name",
                      "label": "Trainingsname"
                    }
                  ],
                  "rows": {
                    "$each": "c.sessions",
                    "as": "s",
                    "map": {
                      "cells": {
                        "day": {
                          "$bind": "s.day"
                        },
                        "time": {
                          "$bind": "s.time"
                        },
                        "name": {
                          "$bind": "s.name"
                        }
                      }
                    }
                  }
                }
              },
              {
                "layout": "cluster",
                "children": [
                  {
                    "component": "button",
                    "data": {
                      "label": "Training hinzufügen",
                      "icon": "plus",
                      "size": "sm",
                      "action": "addSession",
                      "actionId": {
                        "$bind": "c.key"
                      }
                    }
                  },
                  {
                    "component": "button",
                    "data": {
                      "label": "Klasse löschen",
                      "icon": "trash",
                      "size": "sm",
                      "variant": "danger-ghost",
                      "action": "removeClass",
                      "actionId": {
                        "$bind": "c.key"
                      }
                    }
                  }
                ]
              }
            ]
          }
        }
      ]
    },
    {
      "layout": "section",
      "id": "team",
      "title": {
        "$join": [
          "Team · ",
          {
            "$count": "users.items"
          },
          " berechtigte Email Responder"
        ]
      },
      "children": [
        {
          "component": "alert",
          "data": {
            "tone": "info",
            "title": "Benutzerverwaltung über Webling",
            "body": "Die Benutzer werden automatisch aus der Webling-Gruppe «Email Responders» geladen. Um jemanden hinzuzufügen oder zu entfernen, ändere die Gruppenmitgliedschaft direkt in Webling.",
            "link": {
              "label": "Webling öffnen",
              "href": "#"
            }
          }
        },
        {
          "component": "table",
          "data": {
            "caption": "Email Responder",
            "captionHidden": true,
            "columns": [
              {
                "key": "name",
                "label": "Name"
              },
              {
                "key": "email",
                "label": "E-Mail"
              },
              {
                "key": "status",
                "label": "Status"
              }
            ],
            "rowHeaderKey": "name",
            "rows": {
              "$each": "users.items",
              "as": "u",
              "map": {
                "id": {
                  "$bind": "u.id"
                },
                "selected": {
                  "$bind": "u.me"
                },
                "cells": {
                  "name": {
                    "$bind": "u.name"
                  },
                  "email": {
                    "$bind": "u.email"
                  },
                  "status": {
                    "badge": {
                      "label": "Aktiv",
                      "tone": "success"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}

emailhub.closures

email-hubscreen

Route /ferien · 6 components: page-header, alert, choice-group, field, button, card · actions: save (safe), edit (safe), delete (irreversible)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.closures",
  "version": 1,
  "app": "email-hub",
  "route": "/ferien",
  "title": "Ferien & Events",
  "data": {
    "closures": {
      "source": "closures.list"
    }
  },
  "actions": {
    "save": {
      "handler": "closures.save",
      "risk": "safe",
      "success": "Gespeichert",
      "next": "?screen=emailhub.closures"
    },
    "edit": {
      "handler": "closures.edit",
      "risk": "safe",
      "next": {
        "$text": "?screen=emailhub.closures&edit={target.id}"
      }
    },
    "delete": {
      "handler": "closures.delete",
      "risk": "irreversible",
      "confirm": {
        "title": "Eintrag löschen?",
        "body": "Die Antworten erwähnen ihn danach nicht mehr.",
        "confirmLabel": "Löschen",
        "tone": "danger"
      },
      "success": "Gelöscht",
      "next": {
        "$text": "?screen=emailhub.closures&deleted={target.id}"
      }
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Ferien & Events",
        "meta": "Zeiten ohne Training oder ohne reguläres Training. Vergangene Einträge verschwinden automatisch."
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "neutral",
        "title": "Die Antworten erwähnen einen Eintrag, wenn er in den nächsten 8 Wochen liegt oder gerade läuft und die empfohlenen Trainings betrifft, und schlagen das erste Training danach vor."
      }
    },
    {
      "layout": "card",
      "title": {
        "$if": {
          "$bind": "closures.form.id"
        },
        "then": "Eintrag bearbeiten",
        "else": "Neuer Eintrag"
      },
      "children": [
        {
          "component": "choice-group",
          "data": {
            "id": "cl-type",
            "name": "type",
            "legend": "Art",
            "type": "radio",
            "options": [
              {
                "value": "vacation",
                "label": "Ferien",
                "hint": "kein Training",
                "checked": {
                  "$not": {
                    "$eq": [
                      {
                        "$bind": "closures.form.type"
                      },
                      "event"
                    ]
                  }
                }
              },
              {
                "value": "event",
                "label": "Event",
                "hint": "reguläres Training fällt aus, z.B. Gurtprüfung",
                "checked": {
                  "$eq": [
                    {
                      "$bind": "closures.form.type"
                    },
                    "event"
                  ]
                }
              }
            ]
          }
        },
        {
          "layout": "grid",
          "min": "12rem",
          "children": [
            {
              "component": "field",
              "data": {
                "id": "cl-title",
                "name": "title",
                "label": "Titel",
                "placeholder": "z.B. Herbstferien, Gurtprüfung",
                "maxlength": 80,
                "value": {
                  "$bind": "closures.form.title"
                }
              }
            },
            {
              "component": "field",
              "data": {
                "id": "cl-from",
                "name": "from",
                "label": "Von",
                "type": "date",
                "required": true,
                "value": {
                  "$bind": "closures.form.from"
                }
              }
            },
            {
              "component": "field",
              "data": {
                "id": "cl-to",
                "name": "to",
                "label": "Bis",
                "type": "date",
                "required": true,
                "value": {
                  "$bind": "closures.form.to"
                }
              }
            }
          ]
        },
        {
          "component": "choice-group",
          "data": {
            "id": "cl-groups",
            "name": "groups",
            "legend": "Betroffene Trainings",
            "type": "checkbox",
            "hint": "Keins gewählt = alle Trainings",
            "options": {
              "$each": "closures.groups",
              "as": "g",
              "map": {
                "value": {
                  "$bind": "g.key"
                },
                "label": {
                  "$bind": "g.label"
                },
                "checked": {
                  "$bind": "g.checked"
                }
              }
            }
          }
        },
        {
          "component": "field",
          "data": {
            "id": "cl-note",
            "name": "note",
            "label": "Notiz",
            "optional": true,
            "hint": "Wird in den Antworten erwähnt",
            "placeholder": "z.B. Ab 19.10. wieder normales Training",
            "maxlength": 300,
            "value": {
              "$bind": "closures.form.note"
            }
          }
        },
        {
          "layout": "cluster",
          "children": [
            {
              "component": "button",
              "data": {
                "label": {
                  "$if": {
                    "$bind": "closures.form.id"
                  },
                  "then": "Änderungen speichern",
                  "else": "Hinzufügen"
                },
                "variant": "primary",
                "action": "save"
              }
            },
            {
              "component": "button",
              "if": {
                "$bind": "closures.form.id"
              },
              "data": {
                "label": "Abbrechen",
                "variant": "ghost",
                "href": "?screen=emailhub.closures"
              }
            }
          ]
        }
      ]
    },
    {
      "each": "closures.items",
      "as": "c",
      "node": {
        "component": "card",
        "if": {
          "$not": {
            "$eq": [
              {
                "$bind": "c.id"
              },
              {
                "$bind": "params.deleted"
              }
            ]
          }
        },
        "data": {
          "title": {
            "$bind": "c.title"
          },
          "headingLevel": 2,
          "badge": {
            "$if": {
              "$bind": "c.running"
            },
            "then": {
              "label": "läuft",
              "tone": "success"
            }
          },
          "meta": {
            "$text": "{c.range} · {c.kind}"
          },
          "body": {
            "$bind": "c.lines"
          },
          "actions": [
            {
              "label": "Bearbeiten",
              "action": "edit",
              "actionId": {
                "$bind": "c.id"
              }
            },
            {
              "label": "Löschen",
              "variant": "danger-ghost",
              "action": "delete",
              "actionId": {
                "$bind": "c.id"
              }
            }
          ]
        }
      }
    }
  ]
}

emailhub.email

email-hubflow · 2 steps

Route /m/e/:id · 5 components: message, segmented, field, button, kv · actions: send (irreversible), save (safe), template (safe), move-to-inbox (irreversible)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.email",
  "kind": "flow",
  "version": 3,
  "app": "email-hub",
  "route": "/m/e/:id",
  "title": {
    "$bind": "email.from"
  },
  "modes": {
    "guided": false,
    "compact": true
  },
  "density": "dense",
  "sections": "cards",
  "data": {
    "email": {
      "source": "emails.get",
      "params": {
        "id": {
          "$bind": "params.id"
        }
      }
    }
  },
  "chrome": {
    "title": {
      "$bind": "email.from"
    },
    "subtitle": {
      "$bind": "email.fromEmail"
    },
    "back": {
      "label": "Posteingang",
      "href": {
        "$text": "?screen=emailhub.inbox&sent={params.sent}&moved={params.moved}"
      }
    },
    "menu": {
      "$if": {
        "$not": {
          "$bind": "email.lock"
        }
      },
      "then": {
        "label": "Weitere Aktionen",
        "items": [
          {
            "label": "Als Vorlage speichern",
            "icon": "list",
            "action": "template"
          },
          {
            "label": "Keine Anfrage: zurück in Gmail",
            "icon": "arrow-left",
            "action": "move-to-inbox",
            "danger": true
          }
        ]
      }
    },
    "tabbarOnPhone": false
  },
  "readonly": {
    "$bind": "email.lock"
  },
  "draftScope": {
    "$bind": "params.id"
  },
  "derive": {
    "reply": {
      "from": [
        "register"
      ],
      "source": "emails.draft",
      "rewritten": "Antwort neu geschrieben – deine Änderungen wurden ersetzt."
    }
  },
  "actions": {
    "send": {
      "handler": "emails.send",
      "risk": "irreversible",
      "success": {
        "$text": "Gesendet an {email.fromEmail}"
      }
    },
    "save": {
      "handler": "emails.saveReply",
      "risk": "safe",
      "success": "Entwurf gespeichert"
    },
    "template": {
      "handler": "emails.saveTemplate",
      "risk": "safe",
      "success": "Als Vorlage gespeichert"
    },
    "move-to-inbox": {
      "handler": "emails.moveToInbox",
      "risk": "irreversible",
      "confirm": {
        "title": "Keine Probetraining-Anfrage?",
        "body": "Die E-Mail geht zurück in den normalen Gmail-Posteingang und verschwindet hier.",
        "confirmLabel": "Zurück in Gmail",
        "tone": "danger"
      },
      "success": "Zurück in Gmail verschoben",
      "next": {
        "$text": "?screen=emailhub.inbox&sent={params.sent}&moved={params.id},{params.moved}"
      }
    }
  },
  "lead": [
    {
      "component": "alert",
      "if": {
        "$bind": "email.lock"
      },
      "data": {
        "tone": "neutral",
        "title": {
          "$text": "Wird gerade von {email.lock} bearbeitet"
        },
        "body": "Du kannst lesen, aber nicht ändern."
      }
    },
    {
      "component": "page-header",
      "data": {
        "variant": "sub",
        "title": {
          "$bind": "email.subject"
        },
        "meta": {
          "$bind": "email.dateLine"
        }
      }
    },
    {
      "layout": "cluster",
      "children": [
        {
          "each": "email.phoneTags",
          "as": "t",
          "node": {
            "component": "badge",
            "data": {
              "label": {
                "$bind": "t.label"
              },
              "tone": {
                "$bind": "t.tone"
              },
              "kind": {
                "$bind": "t.kind"
              },
              "icon": {
                "$bind": "t.icon"
              }
            }
          }
        }
      ]
    }
  ],
  "submit": {
    "action": "send",
    "label": "Senden",
    "icon": "mail"
  },
  "navActions": [
    {
      "action": "save",
      "label": "Speichern"
    }
  ],
  "done": {
    "href": {
      "$text": "?screen=emailhub.inbox&sent={params.id},{params.sent}&moved={params.moved}"
    }
  },
  "steps": [
    {
      "id": "message",
      "title": "Nachricht",
      "body": [
        {
          "component": "message",
          "data": {
            "bare": true,
            "body": {
              "$bind": "email.body"
            }
          }
        }
      ]
    },
    {
      "id": "reply",
      "title": "Antwort",
      "head": [
        {
          "component": "segmented",
          "if": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "email.language"
                  },
                  "de"
                ]
              },
              {
                "$not": {
                  "$bind": "email.lock"
                }
              }
            ]
          },
          "data": {
            "id": "register",
            "name": "register",
            "legend": "Anrede",
            "hideLegend": true,
            "kind": "address",
            "value": {
              "$bind": "email.register"
            },
            "options": [
              {
                "value": "du",
                "label": "Du"
              },
              {
                "value": "ihr",
                "label": "ihr"
              },
              {
                "value": "sie",
                "label": "Sie"
              }
            ]
          }
        }
      ],
      "body": [
        {
          "component": "field",
          "data": {
            "id": "reply",
            "name": "reply",
            "label": "Antwort",
            "hideLabel": true,
            "control": "textarea",
            "rows": 10,
            "required": true,
            "hint": {
              "$bind": "email.draftMeta"
            },
            "disabled": {
              "$not": {
                "$not": {
                  "$bind": "email.lock"
                }
              }
            }
          }
        },
        {
          "component": "button",
          "if": {
            "$not": {
              "$bind": "email.lock"
            }
          },
          "data": {
            "label": "Neu schreiben",
            "icon": "sparkles",
            "kind": "ai",
            "block": "always",
            "action": "flow-derive",
            "actionId": "reply"
          }
        },
        {
          "component": "kv",
          "data": {
            "items": [
              {
                "term": "An",
                "value": {
                  "$text": "{email.from} <{email.fromEmail}>"
                }
              }
            ]
          }
        }
      ]
    }
  ],
  "review": {
    "confirm": true,
    "title": {
      "$text": "Antwort jetzt an {email.from} senden?"
    },
    "intro": {
      "$text": "An: {email.from} <{email.fromEmail}>"
    },
    "backLabel": "Abbrechen"
  }
}

emailhub.help

email-hubscreen

Route /hilfe · 2 components: page-header, card · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.help",
  "version": 1,
  "app": "email-hub",
  "route": "/hilfe",
  "title": "Hilfe",
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Hilfe",
        "meta": "So funktioniert der Email Hub"
      }
    },
    {
      "layout": "grid",
      "min": "18rem",
      "children": [
        {
          "component": "card",
          "data": {
            "title": "1. Anfrage öffnen",
            "body": [
              "Neue Schnuppertraining-Anfragen aus dem Gmail-Label «ClaudeSchnupperer» erscheinen im Posteingang. Ein Klick öffnet die Anfrage; solange du sie offen hast, sehen die anderen ein Schloss."
            ]
          }
        },
        {
          "component": "card",
          "data": {
            "title": "2. Antwort prüfen",
            "body": [
              "Die AI hat eine Antwort mit den passenden Trainingszeiten vorbereitet. Mit Du / ihr / Sie wird sie in der gewählten Anrede neu geschrieben, «Neu schreiben» erstellt eine neue Version."
            ]
          }
        },
        {
          "component": "card",
          "data": {
            "title": "3. Senden",
            "body": [
              "«Senden» schickt die Antwort und verschiebt die Anfrage nach «ClaudeDone». «Speichern» behält den Entwurf für alle im Team."
            ]
          }
        },
        {
          "component": "card",
          "data": {
            "title": "Ferien und Wochenplan",
            "body": [
              "Trainingszeiten kommen aus dem Wochenplan, Ausfälle aus «Ferien & Events». Die Antworten erwähnen sie automatisch."
            ]
          }
        }
      ]
    }
  ]
}

emailhub.inbox

email-hubscreen

Route / · 10 components: page-header, list, stat, alert, button, message, field, kv, chip-group, empty-state · actions: sendAll (irreversible), send (irreversible), save (safe), regenerate (safe), template (safe), moveToInbox (irreversible), refresh (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.inbox",
  "version": 1,
  "app": "email-hub",
  "route": "/",
  "title": "Posteingang",
  "data": {
    "emails": {
      "source": "emails.list"
    }
  },
  "actions": {
    "sendAll": {
      "handler": "emails.sendAll",
      "risk": "irreversible",
      "confirm": {
        "title": {
          "$join": [
            "Alle ",
            {
              "$count": "emails.items",
              "as": "r",
              "where": {
                "$and": [
                  {
                    "$eq": [
                      {
                        "$bind": "r.status"
                      },
                      "pending"
                    ]
                  },
                  {
                    "$not": {
                      "$bind": "r.done"
                    }
                  }
                ]
              }
            },
            " vorbereiteten Antworten jetzt absenden?"
          ]
        },
        "body": "Bitte stelle sicher, dass du alle Antworten geprüft hast.",
        "consequences": {
          "$each": "emails.items",
          "as": "r",
          "where": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "r.status"
                  },
                  "pending"
                ]
              },
              {
                "$not": {
                  "$bind": "r.done"
                }
              }
            ]
          },
          "map": {
            "$text": "An {r.from} <{r.fromEmail}>"
          }
        },
        "confirmLabel": "Alle senden",
        "tone": "primary"
      },
      "success": "Alle Antworten gesendet",
      "next": {
        "$join": [
          "?screen=emailhub.inbox&sent=",
          {
            "$each": "emails.items",
            "as": "r",
            "where": {
              "$and": [
                {
                  "$eq": [
                    {
                      "$bind": "r.status"
                    },
                    "pending"
                  ]
                },
                {
                  "$not": {
                    "$bind": "r.done"
                  }
                }
              ]
            },
            "map": {
              "$bind": "r.id"
            }
          },
          ",",
          {
            "$bind": "params.sent"
          },
          "&moved=",
          {
            "$bind": "params.moved"
          }
        ]
      }
    },
    "send": {
      "handler": "emails.send",
      "risk": "irreversible",
      "confirm": {
        "title": "Antwort jetzt senden?",
        "body": "Danach geschieht Folgendes:",
        "consequences": [
          "Die Antwort geht an die Absenderin oder den Absender der Anfrage.",
          "Die Anfrage wird in Gmail nach «ClaudeDone» verschoben und erscheint unter «Gesendet» und im Sende-Log."
        ],
        "confirmLabel": "Senden",
        "tone": "primary"
      },
      "success": "Antwort gesendet!",
      "next": {
        "$text": "?screen=emailhub.inbox&sent={target.id},{params.sent}&moved={params.moved}"
      }
    },
    "save": {
      "handler": "emails.saveReply",
      "risk": "safe",
      "success": "Entwurf gespeichert – für alle im Team sichtbar"
    },
    "regenerate": {
      "handler": "emails.regenerate",
      "risk": "safe",
      "success": "AI-Antwort generiert"
    },
    "template": {
      "handler": "emails.saveTemplate",
      "risk": "safe",
      "success": "Als Vorlage gespeichert"
    },
    "moveToInbox": {
      "handler": "emails.moveToInbox",
      "risk": "irreversible",
      "confirm": {
        "title": "Keine Schnuppertraining-Anfrage?",
        "body": "Die E-Mail wird zurück in den normalen Gmail-Posteingang verschoben und hier entfernt.",
        "confirmLabel": "Zurück in Posteingang",
        "tone": "danger"
      },
      "success": "E-Mail zurück in den Posteingang verschoben",
      "next": {
        "$text": "?screen=emailhub.inbox&sent={params.sent}&moved={target.id},{params.moved}"
      }
    },
    "refresh": {
      "handler": "emails.reload",
      "risk": "safe",
      "success": "Posteingang neu geladen"
    }
  },
  "body": [
    {
      "component": "page-header",
      "media": "phone",
      "data": {
        "title": "Posteingang"
      }
    },
    {
      "component": "list",
      "media": "phone",
      "if": {
        "$count": "emails.items",
        "as": "r",
        "where": {
          "$and": [
            {
              "$eq": [
                {
                  "$bind": "r.status"
                },
                "pending"
              ]
            },
            {
              "$not": {
                "$bind": "r.done"
              }
            }
          ]
        }
      },
      "data": {
        "label": "Offene Anfragen",
        "variant": "cards",
        "items": {
          "$each": "emails.items",
          "as": "r",
          "where": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "r.status"
                  },
                  "pending"
                ]
              },
              {
                "$not": {
                  "$bind": "r.done"
                }
              }
            ]
          },
          "map": {
            "id": {
              "$bind": "r.id"
            },
            "title": {
              "$bind": "r.from"
            },
            "time": {
              "$bind": "r.time"
            },
            "timeTone": {
              "$bind": "r.timeTone"
            },
            "meta": {
              "$bind": "r.subject"
            },
            "excerpt": {
              "$bind": "r.snippet"
            },
            "tags": {
              "$each": "r.phoneTags",
              "as": "t",
              "map": {
                "label": {
                  "$bind": "t.label"
                },
                "tone": {
                  "$bind": "t.tone"
                },
                "kind": {
                  "$bind": "t.kind"
                },
                "icon": {
                  "$bind": "t.icon"
                }
              }
            },
            "href": {
              "$text": "?screen=emailhub.email&id={r.id}&sent={params.sent}&moved={params.moved}"
            }
          }
        }
      }
    },
    {
      "component": "page-header",
      "data": {
        "title": "Posteingang",
        "meta": "Schnuppertraining-Anfragen prüfen, bearbeiten und beantworten"
      },
      "media": "wide"
    },
    {
      "layout": "grid",
      "min": "12rem",
      "children": [
        {
          "component": "stat",
          "data": {
            "label": "Ausstehend",
            "value": {
              "$count": "emails.items",
              "as": "r",
              "where": {
                "$and": [
                  {
                    "$eq": [
                      {
                        "$bind": "r.status"
                      },
                      "pending"
                    ]
                  },
                  {
                    "$not": {
                      "$bind": "r.done"
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "component": "stat",
          "data": {
            "label": "Beantwortet",
            "value": {
              "$count": "emails.items",
              "as": "r",
              "where": {
                "$or": [
                  {
                    "$eq": [
                      {
                        "$bind": "r.status"
                      },
                      "sent"
                    ]
                  },
                  {
                    "$bind": "r.sent"
                  }
                ]
              }
            }
          }
        }
      ],
      "media": "wide"
    },
    {
      "layout": "cluster",
      "justify": "between",
      "if": {
        "$gte": [
          {
            "$count": "emails.items",
            "as": "r",
            "where": {
              "$and": [
                {
                  "$eq": [
                    {
                      "$bind": "r.status"
                    },
                    "pending"
                  ]
                },
                {
                  "$not": {
                    "$bind": "r.done"
                  }
                }
              ]
            }
          },
          2
        ]
      },
      "children": [
        {
          "component": "alert",
          "data": {
            "tone": "neutral",
            "title": "Klicke auf eine Anfrage, um die Antwort zu prüfen und zu bearbeiten."
          }
        },
        {
          "component": "button",
          "data": {
            "label": {
              "$join": [
                "Alle senden (",
                {
                  "$count": "emails.items",
                  "as": "r",
                  "where": {
                    "$and": [
                      {
                        "$eq": [
                          {
                            "$bind": "r.status"
                          },
                          "pending"
                        ]
                      },
                      {
                        "$not": {
                          "$bind": "r.done"
                        }
                      }
                    ]
                  }
                },
                ")"
              ]
            },
            "icon": "mail",
            "action": "sendAll"
          }
        }
      ],
      "media": "wide"
    },
    {
      "layout": "stack",
      "gap": "sm",
      "children": [
        {
          "each": "emails.items",
          "as": "r",
          "node": {
            "layout": "details",
            "id": {
              "$text": "card-{r.id}"
            },
            "group": "inbox",
            "open": {
              "$eq": [
                {
                  "$bind": "r.id"
                },
                {
                  "$bind": "params.open"
                }
              ]
            },
            "title": {
              "$text": "{r.from} · {r.fromEmail}"
            },
            "meta": {
              "$bind": "r.subject"
            },
            "tags": {
              "$bind": "r.tags"
            },
            "aside": {
              "$bind": "r.dateLabel"
            },
            "children": [
              {
                "component": "alert",
                "if": {
                  "$bind": "r.lock"
                },
                "data": {
                  "tone": "warning",
                  "title": {
                    "$text": "Wird gerade von {r.lock} bearbeitet"
                  },
                  "body": "Du kannst die Antwort lesen, aber nicht ändern."
                }
              },
              {
                "layout": "grid",
                "min": "20rem",
                "children": [
                  {
                    "component": "message",
                    "data": {
                      "label": "Originalanfrage",
                      "from": {
                        "$text": "{r.from} <{r.fromEmail}>"
                      },
                      "dateLabel": {
                        "$bind": "r.dateLabel"
                      },
                      "body": {
                        "$bind": "r.body"
                      }
                    }
                  },
                  {
                    "layout": "stack",
                    "children": [
                      {
                        "component": "field",
                        "data": {
                          "id": {
                            "$text": "reply-{r.id}"
                          },
                          "name": {
                            "$text": "reply-{r.id}"
                          },
                          "label": "Vorbereitete Antwort",
                          "control": "textarea",
                          "rows": 14,
                          "value": {
                            "$bind": "r.replyDraft"
                          },
                          "hint": {
                            "$bind": "r.draftMeta"
                          },
                          "disabled": {
                            "$not": {
                              "$not": {
                                "$bind": "r.lock"
                              }
                            }
                          }
                        }
                      },
                      {
                        "component": "kv",
                        "data": {
                          "items": [
                            {
                              "term": "An",
                              "value": {
                                "$text": "{r.from} <{r.fromEmail}>"
                              }
                            }
                          ]
                        }
                      },
                      {
                        "component": "chip-group",
                        "if": {
                          "$and": [
                            {
                              "$eq": [
                                {
                                  "$bind": "r.language"
                                },
                                "de"
                              ]
                            },
                            {
                              "$not": {
                                "$bind": "r.lock"
                              }
                            }
                          ]
                        },
                        "data": {
                          "label": "Anrede – die AI schreibt die Antwort neu",
                          "name": "register",
                          "chips": [
                            {
                              "value": "du",
                              "label": "Du",
                              "pressed": {
                                "$eq": [
                                  {
                                    "$bind": "r.register"
                                  },
                                  "du"
                                ]
                              },
                              "href": {
                                "$text": "?screen=emailhub.inbox&open={r.id}&register=du&sent={params.sent}&moved={params.moved}"
                              }
                            },
                            {
                              "value": "ihr",
                              "label": "ihr",
                              "pressed": {
                                "$eq": [
                                  {
                                    "$bind": "r.register"
                                  },
                                  "ihr"
                                ]
                              },
                              "href": {
                                "$text": "?screen=emailhub.inbox&open={r.id}&register=ihr&sent={params.sent}&moved={params.moved}"
                              }
                            },
                            {
                              "value": "sie",
                              "label": "Sie",
                              "pressed": {
                                "$eq": [
                                  {
                                    "$bind": "r.register"
                                  },
                                  "sie"
                                ]
                              },
                              "href": {
                                "$text": "?screen=emailhub.inbox&open={r.id}&register=sie&sent={params.sent}&moved={params.moved}"
                              }
                            }
                          ],
                          "kind": "address"
                        }
                      },
                      {
                        "layout": "cluster",
                        "if": {
                          "$not": {
                            "$bind": "r.lock"
                          }
                        },
                        "children": [
                          {
                            "component": "button",
                            "data": {
                              "label": "Senden",
                              "variant": "primary",
                              "icon": "mail",
                              "action": "send",
                              "actionId": {
                                "$bind": "r.id"
                              }
                            }
                          },
                          {
                            "component": "button",
                            "data": {
                              "label": "Speichern",
                              "action": "save",
                              "actionId": {
                                "$bind": "r.id"
                              }
                            }
                          },
                          {
                            "component": "button",
                            "data": {
                              "label": "Neu schreiben",
                              "icon": "sparkles",
                              "action": "regenerate",
                              "actionId": {
                                "$bind": "r.id"
                              },
                              "kind": "ai"
                            }
                          },
                          {
                            "component": "button",
                            "data": {
                              "label": "Vorlage",
                              "icon": "list",
                              "action": "template",
                              "actionId": {
                                "$bind": "r.id"
                              }
                            }
                          },
                          {
                            "component": "button",
                            "data": {
                              "label": "Zurück in Posteingang",
                              "variant": "danger-ghost",
                              "icon": "arrow-left",
                              "action": "moveToInbox",
                              "actionId": {
                                "$bind": "r.id"
                              }
                            }
                          }
                        ]
                      },
                      {
                        "component": "alert",
                        "if": {
                          "$not": {
                            "$bind": "r.lock"
                          }
                        },
                        "data": {
                          "tone": "neutral",
                          "title": "Prüfe die Antwort, bevor du sie absendest. Mit «Speichern» wird der Entwurf für alle Teamkollegen sichtbar."
                        }
                      }
                    ]
                  }
                ]
              }
            ]
          },
          "where": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "r.status"
                  },
                  "pending"
                ]
              },
              {
                "$not": {
                  "$bind": "r.done"
                }
              }
            ]
          }
        }
      ],
      "media": "wide"
    },
    {
      "component": "empty-state",
      "if": {
        "$not": {
          "$count": "emails.items",
          "as": "r",
          "where": {
            "$and": [
              {
                "$eq": [
                  {
                    "$bind": "r.status"
                  },
                  "pending"
                ]
              },
              {
                "$not": {
                  "$bind": "r.done"
                }
              }
            ]
          }
        }
      },
      "data": {
        "icon": "check-circle",
        "title": "Alles erledigt!",
        "text": "Keine neuen Schnuppertraining-Anfragen vorhanden. Sobald neue Anfragen eintreffen, erscheinen sie hier automatisch. Bereits gesendete Antworten findest du unter «Gesendet».",
        "action": {
          "label": "Gesendet",
          "href": "?screen=emailhub.sent"
        }
      }
    }
  ],
  "chrome": {
    "title": "Email Hub",
    "subtitle": {
      "$if": {
        "$count": "emails.items",
        "as": "r",
        "where": {
          "$and": [
            {
              "$eq": [
                {
                  "$bind": "r.status"
                },
                "pending"
              ]
            },
            {
              "$not": {
                "$bind": "r.done"
              }
            }
          ]
        }
      },
      "then": {
        "$join": [
          {
            "$count": "emails.items",
            "as": "r",
            "where": {
              "$and": [
                {
                  "$eq": [
                    {
                      "$bind": "r.status"
                    },
                    "pending"
                  ]
                },
                {
                  "$not": {
                    "$bind": "r.done"
                  }
                }
              ]
            }
          },
          " offen"
        ]
      },
      "else": "Posteingang"
    },
    "actions": [
      {
        "icon": "refresh",
        "iconOnly": true,
        "variant": "ghost",
        "ariaLabel": "Neu laden",
        "action": "refresh"
      }
    ],
    "tabbarOnPhone": false
  }
}

emailhub.more

email-hubscreen

Route /mehr · 2 components: page-header, list · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.more",
  "version": 1,
  "app": "email-hub",
  "route": "/mehr",
  "title": "Mehr",
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Mehr"
      }
    },
    {
      "component": "list",
      "data": {
        "label": "Weitere Seiten",
        "items": [
          {
            "id": "schedule",
            "title": "Wochenplan",
            "meta": "Trainingszeiten aller Gruppen",
            "href": "?screen=emailhub.schedule"
          },
          {
            "id": "admin",
            "title": "Benutzer",
            "meta": "Gmail Labels, Betreff, Wochenplan, Team",
            "href": "?screen=emailhub.admin"
          },
          {
            "id": "sendlog",
            "title": "Sende-Log",
            "meta": "Wer hat wann an wen geantwortet",
            "href": "?screen=emailhub.sendlog"
          },
          {
            "id": "phone",
            "title": "Handy-App",
            "meta": "Auf den Home-Bildschirm legen",
            "href": "?screen=emailhub.phone"
          },
          {
            "id": "help",
            "title": "Hilfe",
            "meta": "So funktioniert der Email Hub",
            "href": "?screen=emailhub.help"
          },
          {
            "id": "logout",
            "title": "Abmelden",
            "meta": "Sandra Meier · Email Responder",
            "href": "#"
          }
        ]
      }
    }
  ]
}

emailhub.phone

email-hubscreen

Route /handy · 3 components: page-header, alert, card · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.phone",
  "version": 1,
  "app": "email-hub",
  "route": "/handy",
  "title": "Handy-App",
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Handy-App",
        "meta": "Anfragen unterwegs beantworten"
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "info",
        "title": "Diese Seite auf dem Handy öffnen und zum Home-Bildschirm hinzufügen",
        "body": "Der Email Hub funktioniert auf dem Handy wie am Computer: gleiche Anmeldung, gleiche Anfragen, gleiche Entwürfe."
      }
    },
    {
      "layout": "grid",
      "min": "16rem",
      "children": [
        {
          "component": "card",
          "data": {
            "title": "iPhone",
            "body": [
              "In Safari unten auf «Teilen» tippen.",
              "«Zum Home-Bildschirm» wählen."
            ]
          }
        },
        {
          "component": "card",
          "data": {
            "title": "Android",
            "body": [
              "In Chrome oben rechts auf das Menü (⋮) tippen.",
              "«App installieren» oder «Zum Startbildschirm hinzufügen» wählen."
            ]
          }
        }
      ]
    }
  ]
}

emailhub.schedule

email-hubscreen

Route /wochenplan · 4 components: page-header, alert, chip-group, table · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.schedule",
  "version": 1,
  "app": "email-hub",
  "route": "/wochenplan",
  "title": "Wochenplan",
  "data": {
    "schedule": {
      "source": "schedule.get"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Wochenplan",
        "meta": "Trainingszeiten für alle Gruppen — Quelle: live aus dem Google Kalender"
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "neutral",
        "title": "Diese Zeiten werden automatisch in die generierten Antworten eingefügt, passend zur erkannten Altersgruppe."
      }
    },
    {
      "component": "chip-group",
      "data": {
        "label": "Sortierung",
        "name": "sort",
        "chips": [
          {
            "value": "class",
            "label": "Nach Klasse",
            "pressed": {
              "$not": {
                "$eq": [
                  {
                    "$bind": "params.sort"
                  },
                  "day"
                ]
              }
            },
            "href": "?screen=emailhub.schedule&sort=class"
          },
          {
            "value": "day",
            "label": "Nach Tag",
            "pressed": {
              "$eq": [
                {
                  "$bind": "params.sort"
                },
                "day"
              ]
            },
            "href": "?screen=emailhub.schedule&sort=day"
          }
        ]
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "warning",
        "title": "Ausfälle & Änderungen",
        "body": {
          "$bind": "schedule.cancellationsText"
        }
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "info",
        "title": "Ferien & Events",
        "body": {
          "$bind": "schedule.closuresText"
        },
        "link": {
          "label": "bearbeiten",
          "href": "?screen=emailhub.closures"
        }
      }
    },
    {
      "component": "alert",
      "data": {
        "tone": "neutral",
        "title": "Besondere Termine",
        "body": {
          "$bind": "schedule.specialText"
        }
      }
    },
    {
      "layout": "grid",
      "min": "20rem",
      "if": {
        "$not": {
          "$eq": [
            {
              "$bind": "params.sort"
            },
            "day"
          ]
        }
      },
      "children": [
        {
          "each": "schedule.groups",
          "as": "g",
          "node": {
            "component": "table",
            "data": {
              "caption": {
                "$bind": "g.label"
              },
              "density": "dense",
              "stack": false,
              "columns": [
                {
                  "key": "day",
                  "label": "Tag"
                },
                {
                  "key": "time",
                  "label": "Zeit"
                },
                {
                  "key": "name",
                  "label": "Training"
                }
              ],
              "rows": {
                "$each": "g.sessions",
                "as": "s",
                "map": {
                  "cells": {
                    "day": {
                      "$bind": "s.day"
                    },
                    "time": {
                      "$bind": "s.time"
                    },
                    "name": {
                      "$bind": "s.name"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "layout": "grid",
      "min": "20rem",
      "if": {
        "$eq": [
          {
            "$bind": "params.sort"
          },
          "day"
        ]
      },
      "children": [
        {
          "each": "schedule.days",
          "as": "d",
          "node": {
            "component": "table",
            "data": {
              "caption": {
                "$bind": "d.day"
              },
              "density": "dense",
              "stack": false,
              "columns": [
                {
                  "key": "time",
                  "label": "Zeit"
                },
                {
                  "key": "name",
                  "label": "Training"
                },
                {
                  "key": "group",
                  "label": "Gruppe"
                }
              ],
              "rows": {
                "$each": "d.sessions",
                "as": "s",
                "map": {
                  "cells": {
                    "time": {
                      "$bind": "s.time"
                    },
                    "name": {
                      "$bind": "s.name"
                    },
                    "group": {
                      "$bind": "s.group"
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  ]
}

emailhub.sendlog

email-hubscreen

Route /sende-log · 2 components: page-header, table · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.sendlog",
  "version": 1,
  "app": "email-hub",
  "route": "/sende-log",
  "title": "Sende-Log",
  "data": {
    "log": {
      "source": "emails.sendLog"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Sende-Log",
        "meta": "Protokoll aller gesendeten Antworten — wer hat wann an wen geantwortet"
      }
    },
    {
      "component": "table",
      "data": {
        "caption": "Gesendete Antworten",
        "captionHidden": true,
        "columns": [
          {
            "key": "to",
            "label": "Empfänger"
          },
          {
            "key": "subject",
            "label": "Betreff"
          },
          {
            "key": "category",
            "label": "Kategorie"
          },
          {
            "key": "by",
            "label": "Gesendet von"
          },
          {
            "key": "at",
            "label": "Zeitpunkt"
          }
        ],
        "rowHeaderKey": "to",
        "rows": {
          "$each": "log.entries",
          "as": "l",
          "map": {
            "id": {
              "$bind": "l.id"
            },
            "cells": {
              "to": {
                "$text": "{l.from} · {l.fromEmail}"
              },
              "subject": {
                "$bind": "l.subject"
              },
              "category": {
                "badge": {
                  "label": {
                    "$bind": "l.category"
                  }
                }
              },
              "by": {
                "$bind": "l.sentBy"
              },
              "at": {
                "$bind": "l.sentLabel"
              }
            }
          }
        }
      }
    }
  ]
}

emailhub.sent

email-hubscreen

Route /gesendet · 2 components: page-header, message · actions: —

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "emailhub.sent",
  "version": 1,
  "app": "email-hub",
  "route": "/gesendet",
  "title": "Gesendet",
  "data": {
    "categories": {
      "source": "emails.categories"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Gesendete Antworten",
        "meta": {
          "$join": [
            {
              "$bind": "categories.total"
            },
            " beantwortete Anfragen, sortiert nach Trainingsgruppe"
          ]
        }
      }
    },
    {
      "each": "categories.groups",
      "as": "g",
      "node": {
        "layout": "section",
        "title": {
          "$text": "{g.name} · {g.age} · {g.count}"
        },
        "children": [
          {
            "each": "g.items",
            "as": "e",
            "node": {
              "layout": "details",
              "group": "sent",
              "title": {
                "$bind": "e.from"
              },
              "meta": {
                "$bind": "e.subject"
              },
              "aside": {
                "$text": "{e.sentBy} · {e.dateLabel}"
              },
              "children": [
                {
                  "layout": "grid",
                  "min": "20rem",
                  "children": [
                    {
                      "component": "message",
                      "data": {
                        "label": "Originalanfrage",
                        "from": {
                          "$text": "{e.from} <{e.fromEmail}>"
                        },
                        "dateLabel": {
                          "$bind": "e.dateLabel"
                        },
                        "body": {
                          "$bind": "e.body"
                        }
                      }
                    },
                    {
                      "component": "message",
                      "data": {
                        "direction": "out",
                        "label": "Gesendete Antwort",
                        "from": "Taekwondo Bern <[email protected]>",
                        "to": {
                          "$text": "{e.from} <{e.fromEmail}>"
                        },
                        "dateLabel": {
                          "$bind": "e.sentLabel"
                        },
                        "body": {
                          "$bind": "e.replyDraft"
                        }
                      }
                    }
                  ]
                }
              ]
            }
          }
        ]
      }
    }
  ]
}

grading.close-test

adminflow · 2 steps

Route /pruefungen/:testId/abschliessen · 4 components: segmented, field, switch, kv · actions: closeTest (irreversible)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "grading.close-test",
  "kind": "flow",
  "version": 1,
  "app": "admin",
  "route": "/pruefungen/:testId/abschliessen",
  "title": "Gurtprüfung abschliessen",
  "intro": "Hier hältst du die Resultate fest. Wenn du abschliesst, werden die neuen Gurte und die Rechnungen in Webling gespeichert – das lässt sich nicht automatisch rückgängig machen.",
  "requires": ["grading.tests"],
  "modes": { "default": "auto", "compactAfter": 2 },
  "data": {
    "test": { "source": "grading.tests.get", "params": { "id": { "$bind": "params.testId" } } }
  },
  "actions": {
    "closeTest": {
      "handler": "grading.closeTest",
      "risk": "irreversible",
      "success": { "$text": "Prüfung vom {test.dateLabel} abgeschlossen" }
    }
  },
  "submit": { "action": "closeTest", "label": "Prüfung abschliessen" },
  "steps": [
    {
      "id": "results",
      "title": "Resultate",
      "help": "Wähle für jede Person das Resultat. «Bestanden» erhöht den Gurt um eine Stufe. Streifen zählen nicht für das Resultat – sie werden nach der Prüfung zurückgesetzt.",
      "body": [
        {
          "each": "test.applicants",
          "as": "a",
          "node": {
            "component": "segmented",
            "data": {
              "id": { "$text": "result-{a.id}" },
              "name": { "$text": "result-{a.id}" },
              "legend": { "$text": "{a.name} · {a.from} → {a.to}" },
              "value": { "$bind": "a.result" },
              "block": true,
              "options": [
                { "value": "passed", "label": "Bestanden" },
                { "value": "failed", "label": "Nicht bestanden" },
                { "value": "absent", "label": "Abwesend" }
              ]
            }
          }
        }
      ]
    },
    {
      "id": "billing",
      "title": "Rechnungen",
      "help": "Für jede Person, die angetreten ist, entsteht eine Rechnung in Webling. Die Gebühr kommt aus den Prüfungseinstellungen; ändere sie hier nur für diese Prüfung.",
      "body": [
        { "component": "field", "data": { "id": "fee", "name": "fee", "label": "Prüfungsgebühr (CHF)", "type": "number", "inputmode": "decimal", "required": true, "value": { "$bind": "test.fee" } } },
        { "component": "switch", "data": { "id": "send-invoices", "name": "sendInvoices", "label": "Rechnungen gleich per E-Mail verschicken", "hint": "Sonst bleiben sie in Webling, bis du sie versendest.", "checked": true } }
      ]
    }
  ],
  "review": {
    "title": "Prüfen",
    "intro": "So wird die Prüfung abgeschlossen. Prüfe die Zahlen – danach sind die Daten in Webling.",
    "source": "grading.tests.close.dryRun",
    "summary": [
      {
        "component": "kv",
        "data": {
          "items": [
            { "term": "Prüfung", "value": { "$text": "{test.title} · {test.dateLabel}" } },
            { "term": "Prüfungsgebühr", "value": { "$fmt": "chf", "value": { "$bind": "values.fee" } } }
          ]
        }
      }
    ],
    "effectsTitle": "Was passiert, wenn du abschliesst:",
    "effects": { "$bind": "review.effects" }
  },
  "cancel": { "label": "Abbrechen", "href": "?screen=members.registrations" }
}

members.registration-form

publicflow · 4 steps

Route /mitglied-werden · 3 components: field, choice-group, kv · actions: submitRegistration (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "members.registration-form",
  "kind": "flow",
  "version": 1,
  "app": "public",
  "route": "/mitglied-werden",
  "title": "Mitglied werden",
  "intro": "Dauert etwa 5 Minuten. Du erhältst danach eine Bestätigung per E-Mail; das Trainingsteam meldet sich innerhalb von 3 Tagen.",
  "modes": { "compact": false },
  "actions": {
    "submitRegistration": { "handler": "members.submitRegistration", "risk": "safe", "success": "Anmeldung gesendet – schau in dein E-Mail-Postfach." }
  },
  "submit": { "action": "submitRegistration", "label": "Anmeldung absenden" },
  "steps": [
    {
      "id": "person",
      "title": "Person",
      "help": "Wer möchte trainieren? Aus dem Geburtsdatum schlagen wir die passende Trainingsgruppe vor.",
      "body": [
        {
          "layout": "grid",
          "min": "12rem",
          "children": [
            { "component": "field", "data": { "id": "first", "name": "first", "label": "Vorname", "autocomplete": "given-name", "required": true } },
            { "component": "field", "data": { "id": "last", "name": "last", "label": "Nachname", "autocomplete": "family-name", "required": true } }
          ]
        },
        { "component": "field", "data": { "id": "birthdate", "name": "birthdate", "label": "Geburtsdatum", "type": "date", "autocomplete": "bday", "required": true } }
      ]
    },
    {
      "id": "guardian",
      "title": "Erziehungsberechtigte Person",
      "if": { "$lt": [{ "$age": { "$bind": "values.birthdate" } }, 16] },
      "help": "Unter 16 Jahren melden die Eltern an. An diese Adresse gehen Bestätigung, Rechnungen und Infos zum Training.",
      "body": [
        { "component": "field", "data": { "id": "guardian-name", "name": "guardianName", "label": "Name", "autocomplete": "name", "required": true } },
        { "component": "field", "data": { "id": "guardian-email", "name": "guardianEmail", "label": "E-Mail", "type": "email", "inputmode": "email", "autocomplete": "email", "required": true } },
        { "component": "field", "data": { "id": "guardian-phone", "name": "guardianPhone", "label": "Telefon", "type": "tel", "autocomplete": "tel", "optional": true } }
      ]
    },
    {
      "id": "contact",
      "title": "Kontakt",
      "help": "Die Adresse brauchen wir für die Mitgliederliste und die Rechnung. Wir geben sie nicht weiter.",
      "body": [
        {
          "component": "field",
          "if": { "$not": { "$lt": [{ "$age": { "$bind": "values.birthdate" } }, 16] } },
          "data": { "id": "email", "name": "email", "label": "E-Mail", "type": "email", "inputmode": "email", "autocomplete": "email", "required": true, "hint": "An diese Adresse schicken wir die Bestätigung." }
        },
        { "component": "field", "data": { "id": "street", "name": "street", "label": "Strasse und Nr.", "autocomplete": "street-address", "required": true } },
        {
          "layout": "grid",
          "min": "12rem",
          "children": [
            { "component": "field", "data": { "id": "zip", "name": "zip", "label": "PLZ", "inputmode": "numeric", "autocomplete": "postal-code", "maxlength": 6, "required": true } },
            { "component": "field", "data": { "id": "city", "name": "city", "label": "Ort", "autocomplete": "address-level2", "required": true } }
          ]
        }
      ]
    },
    {
      "id": "training",
      "title": "Training",
      "help": "Du kannst die Gruppe später noch wechseln. Die Mitgliedschaft bestimmt den Beitrag; Familien zahlen ab der zweiten Person weniger.",
      "body": [
        {
          "component": "field",
          "data": {
            "id": "group", "name": "group", "label": "Trainingsgruppe", "control": "select", "required": true,
            "value": { "$if": { "$lt": [{ "$age": { "$bind": "values.birthdate" } }, 11] }, "then": "Kinder 7–10", "else": "Erwachsene" },
            "options": [
              { "value": "Tigers (4–6)", "label": "Tigers (4–6)" },
              { "value": "Kinder 7–10", "label": "Kinder 7–10" },
              { "value": "Jugend 11–15", "label": "Jugend 11–15" },
              { "value": "Erwachsene", "label": "Erwachsene" }
            ]
          }
        },
        {
          "component": "choice-group",
          "data": {
            "id": "membership", "name": "membership", "legend": "Mitgliedschaft", "type": "radio", "required": true,
            "options": [
              { "value": "Einzelmitglied", "label": "Einzelmitglied", "hint": "CHF 480.– pro Jahr", "checked": true },
              { "value": "Familie", "label": "Familie", "hint": "ab 2 Personen, CHF 780.– pro Jahr" }
            ]
          }
        },
        {
          "component": "choice-group",
          "data": { "id": "photos", "name": "photos", "legend": "Fotos", "type": "checkbox", "optional": true,
            "options": [{ "value": "yes", "label": "Fotos dürfen veröffentlicht werden", "hint": "Website, Newsletter, Social Media. Jederzeit widerrufbar." }] }
        },
        {
          "component": "choice-group",
          "data": { "id": "statutes", "name": "statutes", "legend": "Statuten", "type": "checkbox", "required": true,
            "options": [{ "value": "accepted", "label": "Ich habe die Statuten gelesen und akzeptiere sie" }] }
        }
      ]
    }
  ],
  "review": {
    "title": "Prüfen",
    "intro": "Stimmt alles? Du kannst jeden Schritt über «Zurück» noch ändern.",
    "summary": [
      {
        "component": "kv",
        "data": {
          "items": [
            { "term": "Name", "value": { "$text": "{values.first} {values.last}" } },
            { "term": "Geburtsdatum", "value": { "$fmt": "date", "value": { "$bind": "values.birthdate" } } },
            { "term": "Kontakt", "value": { "$if": { "$bind": "values.guardianEmail" }, "then": { "$text": "{values.guardianName} · {values.guardianEmail}" }, "else": { "$text": "{values.email}" } } },
            { "term": "Adresse", "value": { "$text": "{values.street}, {values.zip} {values.city}" } },
            { "term": "Gruppe", "value": { "$text": "{values.group}" } },
            { "term": "Mitgliedschaft", "value": { "$text": "{values.membership}" } }
          ]
        }
      }
    ],
    "effectsTitle": "Was danach passiert:",
    "effects": [
      { "$text": "Bestätigung an {values.guardianEmail}{values.email}" },
      "Das Trainingsteam meldet sich innerhalb von 3 Tagen für das erste Training.",
      "Die Rechnung kommt nach der Freigabe, im Eintrittsjahr anteilig."
    ]
  },
  "cancel": { "label": "Abbrechen", "href": "../index.html" }
}

members.registrations

adminscreen

Route /mitglieder/anmeldungen/:id · 7 components: page-header, chip-group, list, empty-state, kv, alert, button · actions: approve (irreversible), reject (reversible), edit (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "members.registrations",
  "version": 1,
  "app": "admin",
  "route": "/mitglieder/anmeldungen/:id",
  "title": "Anmeldungen",
  "nav": { "label": "Mitglieder", "icon": "users", "order": 2, "tab": true },
  "requires": ["members.registrations"],
  "data": {
    "registrations": { "source": "members.registrations.list", "params": { "status": { "$bind": "params.status" } } },
    "selected": { "source": "members.registrations.get", "params": { "id": { "$bind": "params.id" } } }
  },
  "actions": {
    "approve": {
      "handler": "members.approveRegistration",
      "risk": "irreversible",
      "confirm": {
        "title": { "$text": "{selected.name} freigeben?" },
        "body": "Danach geschieht Folgendes:",
        "consequences": { "$bind": "selected.approvalEffects" },
        "confirmLabel": "Freigeben",
        "tone": "primary"
      },
      "success": { "$text": "{selected.name} freigegeben" }
    },
    "reject": { "handler": "members.rejectRegistration", "risk": "reversible", "success": "Anmeldung abgelehnt" },
    "edit": { "handler": "members.editRegistration", "risk": "safe" }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": "Anmeldungen",
        "meta": { "$text": "{registrations.openCount} warten auf Freigabe · Formular online" },
        "actions": [{ "label": "Formular ansehen", "icon": "external-link", "href": "../examples/public-registration.html" }]
      }
    },
    {
      "component": "chip-group",
      "data": {
        "label": "Status",
        "mode": "single",
        "chips": [
          { "value": "pending", "label": "Offen", "count": { "$bind": "registrations.openCount" }, "pressed": true },
          { "value": "approved", "label": "Freigegeben", "count": { "$bind": "registrations.approvedCount" } },
          { "value": "rejected", "label": "Abgelehnt", "count": { "$bind": "registrations.rejectedCount" } }
        ]
      }
    },
    {
      "layout": "split",
      "children": [
        {
          "component": "list",
          "if": { "$bind": "registrations.items.length" },
          "data": {
            "label": "Offene Anmeldungen",
            "items": {
              "$each": "registrations.items",
              "as": "r",
              "map": {
                "id": { "$bind": "r.id" },
                "title": { "$bind": "r.name" },
                "meta": { "$text": "{r.age} Jahre · eingegangen {r.receivedLabel}" },
                "href": { "$text": "?screen=members.registrations&id={r.id}" },
                "avatar": { "$bind": "r.initials" },
                "current": { "$bind": "r.selected" },
                "badge": { "$if": { "$bind": "r.flag" }, "then": { "label": { "$bind": "r.flag.label" }, "tone": { "$bind": "r.flag.tone" } } }
              }
            }
          }
        },
        {
          "component": "empty-state",
          "if": { "$not": { "$bind": "registrations.items.length" } },
          "data": { "icon": "check-circle", "title": "Keine offenen Anmeldungen", "text": "Neue Anmeldungen aus dem Online-Formular erscheinen hier." }
        },
        {
          "layout": "card",
          "if": { "$bind": "selected" },
          "children": [
            { "component": "page-header", "data": { "title": { "$bind": "selected.name" }, "meta": { "$bind": "selected.statusLabel" } } },
            {
              "component": "kv",
              "data": {
                "items": [
                  { "term": "Geburtsdatum", "value": { "$text": "{selected.birthDateLabel} ({selected.age} Jahre)" } },
                  { "term": "Erziehungsberechtigt", "value": { "$bind": "selected.guardian" } },
                  { "term": "Gewünschte Gruppe", "value": { "$bind": "selected.group" } },
                  { "term": "Mitgliedschaft", "value": { "$bind": "selected.membership" } },
                  { "term": "Fotos", "value": { "$bind": "selected.photoConsent" } }
                ]
              }
            },
            {
              "component": "alert",
              "if": { "$bind": "selected.suggestion" },
              "data": { "tone": "info", "title": { "$bind": "selected.suggestion.title" }, "body": { "$bind": "selected.suggestion.body" } }
            },
            {
              "layout": "cluster",
              "justify": "end",
              "children": [
                { "component": "button", "data": { "label": "Ablehnen", "variant": "ghost", "action": "reject", "actionId": { "$bind": "selected.id" } } },
                { "component": "button", "data": { "label": "Bearbeiten", "action": "edit", "actionId": { "$bind": "selected.id" } } },
                { "component": "button", "data": { "label": "Freigeben", "variant": "primary", "action": "approve", "actionId": { "$bind": "selected.id" } } }
              ]
            }
          ]
        }
      ]
    }
  ]
}

performance.programme

memberscreen

Route /plaene/:planId · 5 components: page-header, progress, alert, list, note · actions: done (reversible), set (reversible), reset (reversible), details (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "performance.programme",
  "version": 1,
  "app": "member",
  "route": "/plaene/:planId",
  "title": {
    "$bind": "programme.title"
  },
  "nav": {
    "label": "Pläne",
    "icon": "list",
    "order": 2,
    "tab": true
  },
  "requires": [
    "performance.programmes"
  ],
  "data": {
    "programme": {
      "source": "performance.programmes.today",
      "params": {
        "planId": {
          "$bind": "params.planId"
        }
      },
      "offline": true
    }
  },
  "actions": {
    "done": {
      "handler": "performance.completeExercise",
      "risk": "reversible",
      "success": "Übung fertig"
    },
    "set": {
      "handler": "performance.completeSet",
      "risk": "reversible",
      "success": "Satz geschafft"
    },
    "reset": {
      "handler": "performance.resetExercise",
      "risk": "reversible",
      "success": "Zurückgesetzt"
    },
    "details": {
      "handler": "performance.openExercise",
      "risk": "safe"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": {
          "$bind": "programme.title"
        },
        "meta": {
          "$text": "Woche {programme.week} von {programme.weeks} · {programme.doneToday} von {programme.total} Übungen heute"
        },
        "back": {
          "label": "Pläne",
          "href": "#"
        }
      }
    },
    {
      "component": "progress",
      "data": {
        "label": "Heute",
        "value": {
          "$bind": "programme.doneToday"
        },
        "max": {
          "$bind": "programme.total"
        },
        "text": {
          "$text": "{programme.doneToday} von {programme.total} Übungen"
        },
        "id": "today-progress"
      }
    },
    {
      "component": "alert",
      "if": {
        "$bind": "programme.focus"
      },
      "data": {
        "tone": "warning",
        "title": {
          "$bind": "programme.focus"
        }
      }
    },
    {
      "component": "list",
      "data": {
        "label": "Deine Übungen",
        "gestures": "primary",
        "swipeHint": {
          "id": "training-swipe",
          "title": "So geht es",
          "items": [
            "Nach rechts wischen: Übung fertig",
            "Nach links wischen: ein Satz geschafft",
            "Menü (⋯): Details und Zurücksetzen"
          ]
        },
        "items": {
          "$each": "programme.exercises",
          "as": "ex",
          "map": {
            "id": {
              "$bind": "ex.id"
            },
            "title": {
              "$bind": "ex.title"
            },
            "meta": {
              "$bind": "ex.scheme"
            },
            "done": {
              "$bind": "ex.done"
            },
            "progress": {
              "done": {
                "$bind": "ex.setsDone"
              },
              "total": {
                "$bind": "ex.sets"
              }
            },
            "quickAction": {
              "action": "done",
              "label": "Fertig",
              "icon": "check"
            },
            "swipe": {
              "mode": "commit",
              "start": {
                "action": "done",
                "label": "Übung fertig",
                "icon": "check",
                "tone": "success"
              },
              "end": {
                "action": "set",
                "label": "Satz geschafft",
                "icon": "plus",
                "tone": "accent"
              }
            },
            "actions": [
              {
                "action": "done",
                "label": "Übung fertig",
                "icon": "check"
              },
              {
                "action": "set",
                "label": "Ein Satz geschafft",
                "icon": "plus"
              },
              {
                "action": "details",
                "label": "Details, Bilder, Video",
                "icon": "info"
              },
              {
                "action": "reset",
                "label": "Zurücksetzen",
                "icon": "undo"
              }
            ]
          }
        }
      }
    },
    {
      "component": "note",
      "if": {
        "$bind": "programme.coachNote"
      },
      "data": {
        "author": {
          "$bind": "programme.coachNote.author"
        },
        "dateLabel": {
          "$bind": "programme.coachNote.dateLabel"
        },
        "text": {
          "$bind": "programme.coachNote.text"
        }
      }
    }
  ]
}

training.today

trainerscreen

Route /heute · 5 components: page-header, action-tile, badge, save-status, list · actions: markAbsent (reversible), addNote (safe)

Screen definition
{
  "$schema": "../../packages/ui/screens/screen.schema.json",
  "id": "training.today",
  "version": 1,
  "app": "trainer",
  "route": "/heute",
  "title": "Heute",
  "nav": {
    "label": "Heute",
    "icon": "home",
    "order": 1,
    "tab": true
  },
  "requires": [
    "training.attendance"
  ],
  "data": {
    "today": {
      "source": "training.sessions.today",
      "offline": true
    },
    "current": {
      "source": "training.sessions.attendance",
      "params": {
        "id": {
          "$bind": "today.next.id"
        }
      },
      "offline": true
    }
  },
  "actions": {
    "markAbsent": {
      "handler": "training.markAbsent",
      "risk": "reversible",
      "success": "Als abwesend markiert"
    },
    "addNote": {
      "handler": "training.addNote",
      "risk": "safe"
    }
  },
  "body": [
    {
      "component": "page-header",
      "data": {
        "title": {
          "$text": "Hallo {user.firstName}"
        },
        "meta": {
          "$text": "{today.dateLabel} · {today.count} Trainings"
        }
      }
    },
    {
      "component": "action-tile",
      "if": {
        "$bind": "today.next"
      },
      "data": {
        "href": "#praesenz",
        "eyebrow": {
          "$text": "Jetzt · {today.next.timeLabel}"
        },
        "title": "Präsenz",
        "icon": "chevron-right",
        "meta": {
          "$text": "{today.next.className} · {today.next.roleLabel}"
        }
      }
    },
    {
      "layout": "section",
      "id": "praesenz",
      "title": {
        "$bind": "current.className"
      },
      "children": [
        {
          "layout": "cluster",
          "justify": "between",
          "children": [
            {
              "component": "badge",
              "data": {
                "label": {
                  "$text": "{current.presentCount} von {current.total} da"
                },
                "tone": "info"
              }
            },
            {
              "component": "save-status",
              "data": {
                "state": {
                  "$bind": "current.sync.state"
                },
                "count": {
                  "$bind": "current.sync.pending"
                }
              }
            }
          ]
        },
        {
          "component": "list",
          "data": {
            "label": {
              "$text": "Teilnehmende {current.className}"
            },
            "items": {
              "$each": "current.students",
              "as": "s",
              "map": {
                "id": {
                  "$bind": "s.id"
                },
                "title": {
                  "$bind": "s.name"
                },
                "meta": {
                  "$bind": "s.note"
                },
                "avatar": {
                  "$bind": "s.initials"
                },
                "belt": {
                  "label": {
                    "$bind": "s.belt.label"
                  },
                  "color": {
                    "$bind": "s.belt.color"
                  }
                },
                "done": {
                  "$not": {
                    "$bind": "s.present"
                  }
                },
                "actions": [
                  {
                    "action": "markAbsent",
                    "label": "Als abwesend markieren",
                    "icon": "x"
                  },
                  {
                    "action": "addNote",
                    "label": "Notiz hinzufügen",
                    "icon": "edit"
                  }
                ],
                "swipe": {
                  "mode": "reveal",
                  "end": {
                    "action": "markAbsent",
                    "label": "War nicht da",
                    "icon": "x",
                    "tone": "danger"
                  }
                }
              }
            }
          }
        }
      ]
    },
    {
      "layout": "section",
      "id": "spaeter",
      "title": "Später",
      "if": {
        "$bind": "today.later.length"
      },
      "children": [
        {
          "component": "list",
          "data": {
            "label": "Weitere Trainings heute",
            "items": {
              "$each": "today.later",
              "as": "t",
              "map": {
                "id": {
                  "$bind": "t.id"
                },
                "title": {
                  "$bind": "t.title"
                },
                "meta": {
                  "$bind": "t.meta"
                },
                "href": "#"
              }
            }
          }
        }
      ]
    }
  ]
}

A screen is a small JSON file, not hand-written JS. It says which components appear, with which data, in which layout, and which actions they can trigger. The engine (packages/ui/js/screen.js) renders it, validates every component's data against that component's contract, and wires actions with the safeguard their risk class requires.

Feature code is left with what only code can do: loading data through the SDK (the screen names the sources) and the action handlers.

File

<feature>.<screen>.json, validated by packages/ui/screens/screen.schema.json:

FieldPurpose
id<feature>.<screen>, e.g. members.registrations. The feature prefix decides which distributions include the screen.
appadmin · trainer · member · public · screens · operator: the shell it renders in
routeURL inside the app; :id segments become params.id
title, navPage title; label, icon, order and tab-bar flag for the navigation
requiresCapabilities (entitlement ∧ setting ∧ flag ∧ permission). Without them the screen doesn't exist for the user.
dataNamed data sources: { "registrations": { "source": "members.registrations.list", "params": {…} } }. The app loads them through the SDK; results are bound by name. offline: true caches them for the Trainer/Member apps.
actions{ "approve": { "handler": "members.approveRegistration", "risk": "irreversible", "confirm": {…}, "success": "…" } }
bodyThe node tree
chromeWhat the screen puts into the top bar: title, subtitle ("4 offen", an e-mail address), back (arrow on phones), menu (⋯ with the screen's rare actions), actions (icon buttons), tabbarOnPhone: false for focused phone screens (inbox → message), current (the screen id whose tab or menu item is marked, or false for none, e.g. settings opened from the top bar). Expressions allowed.

The app shell comes from styleguide/screens/apps/<app>.json (app-shell data). Two fields are for the app, not the shell: note (comment) and theme ("dark" for an app that is always dark, like the athlete app; ?theme=light overrides it in the viewer).

Nodes

  • Component node: { "component": "list", "data": { … } }. Any component from the reference (../reference/index.html); data must satisfy its contract.
  • Layout node: { "layout": "stack" | "cluster" | "grid" | "tiles" | "split" | "section" | "card" | "details", "children": [ … ] }, with title, gap, justify and min where they apply.
    • cluster with "grow": "first" | "last": that child takes the remaining room (a reply field beside its send button, badges beside a ring).
    • tiles: home tiles — the first child (the action tile) spans two rows, the others stack beside it (athlete app «Heute»).
    • section with "variant": "label": the heading is a small uppercase label ("Weitere Pläne", "Vom Coach").
    • card with title, tags (badge data at the end of the title row, e.g. "+30 P."), meta (a muted line) and itemId (the record the card is about: actions inside it get it as target.id, e.g. «Erledigt melden» on one challenge).
  • Expandable card ("layout": "details"): a card that opens in place (native <details>). The header comes from title, meta, tags (badge data) and aside (e.g. a date); the children are shown when it is open. group makes cards exclusive (one open at a time), open opens one initially (e.g. { "$eq": ["r.id", "params.open"] }). Use it where people work through items in place, like the legacy inbox; for longer tasks, open a page or a flow.
  • Repeated node: { "each": "path", "as": "r", "where": <expr>, "node": { … } } renders a node per item; where keeps only matching items.
  • Any node may have "if": <expression> and "requires": ["capability"].

Expressions (inside data, title, if, action options)

ExpressionResult
{ "$bind": "selected.name" }Value at a path in the context (data sources, params, user, target)
{ "$text": "Hallo {user.firstName}" }String with {path} placeholders
{ "$t": "members.title", "args": {…} }Translation from the module's catalogue
{ "$fmt": "date" | "datetime" | "number" | "chf" | "percent" | "url", "value": <expr> }Formatted with Intl (de-CH by default); url encodes text for a link (a reply typed by the user in an action's next)
{ "$each": "registrations.items", "as": "r", "map": { … } }Maps an array; inside the template, r.… is bound
{ "$if": <expr>, "then": …, "else": … }, { "$not": <expr> }Conditions
{ "$count": "inquiries.items", "as": "r", "where": <expr> }Number of items (matching where), e.g. open inquiries not yet answered
{ "$find": "challenges.items", "as": "c", "where": <expr>, "get": "points" }The first matching item, or a path in it — e.g. the points of the challenge that was just reported (target.id)
{ "$join": ["Alle senden (", <expr>, ")"] }Parts joined into one string (arrays become comma lists)
{ "$flag": "anfragen.trial-date" }true when the feature flag is on (see Feature flags below)
"where" on $eachKeeps only matching items: { "$each": "emails.items", "as": "r", "where": <expr>, "map": … }
"sortBy" on $eachSorts by a value of the item, false/smaller first, otherwise in order: "sortBy": "ex.done" puts finished exercises last

Values that resolve to undefined are dropped, so optional component fields stay optional.

There is no way to put HTML in a screen. Every string ends up in a component's escaped output (a test proves it).

Actions and risk

Components emit data-action="<name>" (buttons via action, list menus via actions[].action, proposals). The nearest data-id is the target. The engine then:

riskEngine behaviour (UX guide §5)
safeCalls the handler; shows success if given
reversibleCalls the handler; shows a toast with Rückgängig if the handler returns { undo }
irreversibleShows a confirm dialog first (confirm.title, body, consequences[], confirmLabel), then calls the handler

An action can name next (literal or expression): where the app goes after success; the success toast is shown there (e.g. back to the inbox after sending).

An action can celebrate after success (athlete app, UX guide §13.1): { "kind": "small" | "exercise" | "big" | "huge", "points": <expr>, "message": <expr or array, one picked at random>, "style": "full" | "calm" | "off", "pref": <true: the device setting «Feiern» wins> }; it bursts from the row or button that was used. A screen-level celebrate with if and once celebrates on view (a reward just unlocked), once per session.

Handlers get values: the screen's named form fields at the moment of the click (the wellness check-in, a reply field, a dialog's fields), also in expressions as values.<name>. A dialog footer button with action runs that action and closes the dialog. A link to #<id> of a sheet or dialog on the page opens it (a list row whose href is #sheet-e2 opens that exercise's details).

Handlers are registered by the feature: handlers["members.approveRegistration"] = async ({ id, ctx }) => { … return { undo } }.

Feature flags

New features are added behind a flag, so a tool can be shown with and without them, compared, and switched on per club.

  • Registry: styleguide/screens/flags.json (later: one file per feature module) with id (<tool>.<feature>), tool, title, description, default, status. The tests fail when a screen uses an unregistered flag or a flag is registered but unused, and every screen and flow is rendered with all flags off and on.
  • In screens: { "$flag": "id" } is an ordinary expression: on a node ("if": { "$flag": … }), in data ("swipe": { "$if": { "$flag": … }, "then": … }), in flow settings (done.href, review.confirm, review.effects). Data sources can hold flag-specific variants (fixtures: sources.<op>.flagTemplates).
  • Rule: with all flags off, a tool must behave like the version it replaces (for Anfragen: the legacy Email Hub). A flag is removed once its feature is decided: the code stays, the condition goes.
  • Viewer: the panel «Funktionen» in the top bar switches the flags of the current tool (remembered per browser); ?flags=a,b in a link turns them on for whoever opens it.
  • Product: ctx.flags comes from the tenancy service, per club and user group (ARCHITECTURE.md §5: entitlement ∧ setting ∧ flag ∧ permission).

Checks

  • checkScreen(screen, components) checks the structure, validates literal component data fully, flags unknown fields in data that contains expressions, finds actions that are used but not declared, and finds missing risk classes.
  • packages/ui/tests/screens.test.js runs checkScreen on every screen and renders it with its fixture (<id>.data.json), with every component contract validated.

Where screens live

  • Today: styleguide/screens/*.json (examples, viewable at styleguide/screens/view.html?screen=<id>).
  • Target: features/<feature>/screens/*.json (ARCHITECTURE.md §9.3), included in a distribution with their feature. Because they are data, they can also be stored as versioned documents in Wren (labels draft/published), reviewed as diffs, and drafted by an LLM against the published schema and component contracts.

Flows: one task, two presentations

A flow ("kind": "flow") is a task: steps → review → submit. It is defined once and rendered by packages/ui/js/flow.js either guided (a wizard that explains the system) or compact (all steps as sections, fast for people who know it), on a page or in a sheet. See UX guide §4.4 for when each is used.

FieldPurpose
introOne or two sentences at the top of the first guided step: what the task does and what it changes
steps[]{ id, title, help, if?, body }. help is required: shown above the step (guided) or behind "?" (compact). if hides a step depending on values (e.g. the guardian step under 16).
review{ title, intro, source, summary, effectsTitle, effects }. source names the dry-run operation the app calls with the values; its result is review.*. effects is the list of what will happen.
submit{ action, label }. The action is declared in actions with its risk class; the review counts as the confirmation.
modes{ guided, compact, default: "auto"|"guided"|"compact", compactAfter }. Public forms set compact: false.
cancel, draftCancel link; whether to keep a draft (default true)
draftScopeExpression that separates drafts per record, e.g. { "$bind": "params.id" }: one draft per inquiry, not one per flow
deriveFields whose value is produced from other values: { "body": { "from": ["group", "slot", "address"], "source": "comms.inquiries.draft" } } (or "value": <expression>). Recomputed when an input changes or the field is empty; a person's edit stays until then, and overwriting it offers Rückgängig. A button with action: "flow-derive", actionId: "<field>" rewrites on request.
done{ "href": <expression> }: where the app goes after a successful submit (the success toast is shown there), e.g. the next item of a queue
aside, asideLabelNodes shown beside the task from 1440 px, e.g. the inbox list next to the reply; below that the back link leads to the list
back{ label, href }: back link in the page header (to the list on phones; hidden on wide screens when there is an aside)
density"dense" for queue work: title only in the top bar (still announced), small section labels, less spacing; when the flow column is ≥ 44 rem, the first section (what came in) and the rest (the answer) sit side by side
leadNodes above the steps, e.g. subject, date and tags of the message being answered
steps[].headNodes at the end of a step's heading row, e.g. the Anrede switch next to «Antwort»
sections"cards": in compact mode every step is a card with a small label, like the legacy phone apps
navActionsMore buttons in the action bar before the submit (e.g. «Speichern»); on phones the bar splits 1 : 2
review.confirmCompact mode: the review opens as a sheet on submit (the exact result and its effects, "Weiter bearbeiten" or submit) instead of a section on the page

Values. Every form control with a name becomes values.<name>. Steps, if conditions and the review can use them ({ "$bind": "values.birthdate" }). Expressions for conditions are $age, $lt, $gte, $eq, $and, $or and $not.

Repeated nodes. { "each": "test.applicants", "as": "a", "node": { … } } renders a node per item, e.g. one result control per applicant.

Engine behaviour:

  • Mode choice: public → guided; the person's choice; editing → compact; modes.default; otherwise guided until completed compactAfter times.
  • Guided: ?step=<id> in the URL, browser Back/Forward between steps, validation of the current step on "Weiter" (with an error summary that takes focus), and the review as the last step.
  • Compact: sections, help on request, the review summary above the submit button, and validation of everything on submit.
  • Drafts are saved on every input and restored on reload; they are deleted after a successful submit.
  • Submit runs the declared action (runAction with reviewed: true), marks the flow completed for the person, and calls onDone.

Checks. checkFlow() checks unique step ids, the help texts, the declared submit action, and every step body against the component contracts. The tests also render every guided step and the compact view, and assert that both contain exactly the same fields.

  • Values and defaults: every field's default (a suggested group, the first free date) is a value from the start, including fields in steps not shown yet. Only fields the person touched are written back when something re-renders; untouched fields keep the default the screen computes, which may depend on other values.
  • Live updates: when a change alters what the flow shows (a conditional step, the dates of the chosen group, the review summary in compact mode), only the changed nodes are replaced. The other fields and the buttons stay in place, so a click that ends an edit still lands.

Fixtures (styleguide/screens/<id>.data.json, applied by styleguide/screens/fixtures.js): data standing in for the sources, plus variants ({ "when": { "id": "i-099" }, "data": { … } }) deep-merged when the URL params match, e.g. another record or the state after an action (?sent=i-102; a comma list ?sent=i-099,i-100 matches several). For derived values, sources holds templates per value of one field. The tests render the base fixture and every variant.

The Anfragen tool (comms.*, app anfragen) has exactly the legacy Email Hub features (feature parity, nothing added) in the new layout: the inbox comms.inquiries (counts, «Alle senden», rows with preview and the extractor's tags) → the reply comms.inquiry-reply (compact and dense; list beside it from 1440 px; message and answer side by side; Du/ihr/Sie rewrites the draft; Speichern, Neu schreiben, Vorlage, Zurück in Posteingang; read-only while a colleague works on it; confirmation on Senden; then back to the inbox) and the legacy pages comms.sent, comms.schedule (from the iCal calendar), comms.closures, comms.admin, comms.sendlog, comms.help. There is no «Handy-App» page: the tool is the mobile version. Try ?id=e-2 (locked), e-3 (English), e-4 (contact form).

Examples: members.registration-form (public, guided only, guardian step under 16) and grading.close-test (guided and compact, review from the dry-run, irreversible submit).

The legacy Email Hub as a click prototype (emailhub.*, app email-hub): the legacy app's menu and pages rebuilt with the component library, for side-by-side comparison: Posteingang (expandable cards with original, draft, Du/ihr/Sie, Senden, Speichern, Neu schreiben, Vorlage, Zurück in Posteingang, Alle senden; locks), Gesendet (by training group, expandable), Wochenplan (by class / by day), Ferien & Events (form + list, edit and delete), Benutzer (Gmail labels, reply subject, Wochenplan, team), Sende-Log, Handy-App, Hilfe and, on phones, Mehr.