fix: Briefe Kontaktauswahl
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-09-16 01:49:46 +02:00
parent 03a5e0dd9c
commit ef3e9dbbb6
9 changed files with 163 additions and 18 deletions
@@ -18,8 +18,7 @@ public static class LetterPlaceholderBuilder
string letterText, string teacherName, DrawingValue? attendanceCalendar = null,
DrawingValue? absenceDays = null)
{
var cityLine = string.Join(" ", new[] { contact?.PostalCode, contact?.City }.Where(x => !string.IsNullOrWhiteSpace(x)));
var address = string.Join(Environment.NewLine, new[] { contact?.Name, contact?.Street, cityLine }.Where(x => !string.IsNullOrWhiteSpace(x)));
var address = FormatAddress(contact);
return new Dictionary<string, PlaceholderValue>(StringComparer.Ordinal)
{
["Datum"] = new DateValue(date), ["CurrentDate"] = new DateValue(date),
@@ -36,6 +35,14 @@ public static class LetterPlaceholderBuilder
};
}
/// <summary>Mehrzeilige Anschrift (Name/Straße/PLZ Ort) für Adressvorschau im Dialog und
/// den <c>Contact.Address</c>-Platzhalter - eine Formatierung für beide Verwendungen.</summary>
public static string FormatAddress(Contact? contact)
{
var cityLine = string.Join(" ", new[] { contact?.PostalCode, contact?.City }.Where(x => !string.IsNullOrWhiteSpace(x)));
return string.Join(Environment.NewLine, new[] { contact?.Name, contact?.Street, cityLine }.Where(x => !string.IsNullOrWhiteSpace(x)));
}
public static bool IsEmpty(PlaceholderValue value) => value switch
{
TextValue x => string.IsNullOrWhiteSpace(x.Value),
@@ -37,9 +37,14 @@ public static class StudentAttendanceCalendarDrawingBuilder
AttendanceCalendarSize.Large => 1f,
_ => .85f,
};
var contentWidth = width * scale;
// Die Breite richtet sich nach der DRAWBOX-Deklaration im Layout-Skript (fest, unabhängig
// von der Größenwahl) - nur Schrift/Zellenhöhe skalieren mit "Größe". Würde die Breite mit
// skalieren, würde "Groß" (scale=1) exakt die Skript-Box ausfüllen, "Klein"/"Normal" aber
// nur einen Teil davon - und eine größere Skalierung als 1 liefe über die Box hinaus und
// würde am rechten Rand abgeschnitten (SVG overflow="hidden").
var contentWidth = width;
var cellHeight = 10 * scale;
var monthGapX = 6 * scale;
var monthGapX = 10f;
var first = options.NormalizedStartMonth;
var monthCount = options.NormalizedMonthCount;
var monthWidth = (contentWidth - monthGapX * (monthCount - 1)) / monthCount;
@@ -112,8 +117,10 @@ public static class StudentAbsenceDayListDrawingBuilder
AttendanceCalendarSize.Large => 1f,
_ => .88f,
};
var contentWidth = width * scale;
var rowHeight = 9 * scale;
// Breite bleibt an die DRAWBOX-Deklaration im Layout-Skript gebunden (siehe
// StudentAttendanceCalendarDrawingBuilder) - nur Zeilenhöhe/Schrift skalieren mit "Größe".
var contentWidth = width;
var rowHeight = 12 * scale;
var start = options.NormalizedStartMonth;
var end = start.AddMonths(options.NormalizedMonthCount).AddDays(-1);
var rows = absences
@@ -130,17 +137,17 @@ public static class StudentAbsenceDayListDrawingBuilder
DrawingTextAlignment.AlignLeft, 8 * scale, Color: "#6B7280"));
y += 10 * scale + 2 * scale;
commands.Add(new DrawRectangle(0, y, contentWidth, rowHeight, "#CBD5E1", .4f, "#F3F4F6"));
commands.Add(new DrawStringEx(2 * scale, y + scale, rowHeight - scale, 31 * scale, "Datum",
commands.Add(new DrawStringEx(2, y + scale, rowHeight - scale, 31, "Datum",
DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
commands.Add(new DrawStringEx(36 * scale, y + scale, rowHeight - scale, 75 * scale, "Umfang",
commands.Add(new DrawStringEx(36, y + scale, rowHeight - scale, 75, "Umfang",
DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
commands.Add(new DrawStringEx(113 * scale, y + scale, rowHeight - scale, 55 * scale, "Status",
commands.Add(new DrawStringEx(113, y + scale, rowHeight - scale, 55, "Status",
DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
y += rowHeight;
if (rows.Count == 0)
{
commands.Add(new DrawStringEx(2 * scale, y + 2 * scale, rowHeight, contentWidth - 4 * scale,
commands.Add(new DrawStringEx(2, y + 2 * scale, rowHeight, contentWidth - 4,
"Keine Fehltage im gewählten Zeitraum", DrawingTextAlignment.AlignLeft, 8 * scale,
Color: "#6B7280", Italic: true));
y += rowHeight + 3 * scale;
@@ -163,12 +170,12 @@ public static class StudentAbsenceDayListDrawingBuilder
: row.FriendlyStatusLabel;
var statusColor = row.IsUnexcused ? "#C62828" : "#2E7D32";
commands.Add(new DrawRectangle(0, y, contentWidth, rowHeight, "#E5E7EB", .3f, fill));
commands.Add(new DrawStringEx(2 * scale, y + scale, rowHeight - scale, 31 * scale,
commands.Add(new DrawStringEx(2, y + scale, rowHeight - scale, 31,
row.Date.ToString("dd.MM.yyyy"), DrawingTextAlignment.AlignLeft, 7.5f * scale,
Color: "#374151"));
commands.Add(new DrawStringEx(36 * scale, y + scale, rowHeight - scale, 75 * scale,
commands.Add(new DrawStringEx(36, y + scale, rowHeight - scale, 75,
extent, DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151"));
commands.Add(new DrawStringEx(113 * scale, y + scale, rowHeight - scale, 55 * scale,
commands.Add(new DrawStringEx(113, y + scale, rowHeight - scale, 55,
status, DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: statusColor,
Bold: row.IsUnexcused));
y += rowHeight;