diff --git a/changelog.d/+etb-entry-notes.added.md b/changelog.d/+etb-entry-notes.added.md
new file mode 100644
index 000000000..5500e2d9b
--- /dev/null
+++ b/changelog.d/+etb-entry-notes.added.md
@@ -0,0 +1 @@
+A user-written ETB entry can carry notes, entered through its edit button, folded under its line until a click unfolds them, and printed under the entry in the PDF (#973).
diff --git a/src/LageBuch.App.Shared/Views/EtbView.axaml b/src/LageBuch.App.Shared/Views/EtbView.axaml
index b851752cb..2f34a84bd 100644
--- a/src/LageBuch.App.Shared/Views/EtbView.axaml
+++ b/src/LageBuch.App.Shared/Views/EtbView.axaml
@@ -52,6 +52,21 @@
+
+
+
+
+
@@ -212,6 +230,14 @@
+
+
+
+
-
+
+
+
+
+
@@ -283,11 +317,27 @@
IsVisible="{Binding HasTasks}" IsTabStop="False"
Content="{Binding TaskBadge}" Command="{Binding ShowTasksCommand}"
ToolTip.Tip="Die Aufgaben zu diesem Eintrag zeigen" />
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -358,6 +408,20 @@
+
+
+
+
+
+
+
+
+
+
+
InitializeComponent();
+ public EtbView()
+ {
+ InitializeComponent();
+
+ // A click on an entry's line folds its notes in and out (#973), in the grid and on the
+ // cards alike. Tapped, not PointerReleased, as in ChecklistView: a touch scroll that ends
+ // over a row must not unfold it; a fast second click arrives as DoubleTapped and folds them
+ // back. A row without notes ignores the click.
+ EtbGrid.AddHandler(TappedEvent, OnRowTapped);
+ EtbGrid.AddHandler(DoubleTappedEvent, OnRowTapped);
+ EtbCards.AddHandler(TappedEvent, OnRowTapped);
+ EtbCards.AddHandler(DoubleTappedEvent, OnRowTapped);
+ }
+
+ private static void OnRowTapped(object? sender, TappedEventArgs e)
+ {
+ // A button in the row (edit, history, the fold glyph itself) has done its own thing.
+ if (e.Source is not Visual source
+ || source.FindAncestorOfType(includeSelf: true) is not null
+ || source.DataContext is not EtbEntryRow row)
+ {
+ return;
+ }
+
+ row.ToggleNotesCommand.Execute(null);
+ }
}
diff --git a/src/LageBuch.AppLogic/LocalIncidentSession.cs b/src/LageBuch.AppLogic/LocalIncidentSession.cs
index 88fa8d14b..d7991587a 100644
--- a/src/LageBuch.AppLogic/LocalIncidentSession.cs
+++ b/src/LageBuch.AppLogic/LocalIncidentSession.cs
@@ -135,6 +135,9 @@ public Guid AddJournalEntry(EtbDirection direction, string text, string? from =
public void EditJournalEntry(Guid entryId, string text) =>
Mutate(() => Incident.EditJournalEntry(_clock, RequireOperator(), entryId, text));
+ public void SetJournalEntryNotes(Guid entryId, string? notes) =>
+ Mutate(() => Incident.SetJournalEntryNotes(_clock, RequireOperator(), entryId, notes));
+
public void ToggleChecklistItem(Guid itemId) => Mutate(() => Incident.ToggleChecklistItem(_clock, RequireOperator(), itemId));
public void AssignRole(
diff --git a/src/LageBuch.AppLogic/ViewModels/EtbViewModel.cs b/src/LageBuch.AppLogic/ViewModels/EtbViewModel.cs
index 7df9d55dd..dfeca2fc5 100644
--- a/src/LageBuch.AppLogic/ViewModels/EtbViewModel.cs
+++ b/src/LageBuch.AppLogic/ViewModels/EtbViewModel.cs
@@ -116,7 +116,8 @@ public void Sync()
foreach (var entry in journal)
{
- if (!_byId.TryGetValue(entry.Id, out var current) || current.Edits.Count == entry.Edits.Count)
+ if (!_byId.TryGetValue(entry.Id, out var current)
+ || (current.Edits.Count == entry.Edits.Count && string.Equals(current.Notes, entry.Notes, StringComparison.Ordinal)))
{
continue;
}
@@ -388,6 +389,10 @@ private void ShowAddErrors(bool shown)
[NotifyPropertyChangedFor(nameof(EditErrorSummary))]
private string _editText = string.Empty;
+ /// The NOTIZ field of the edit panel (#973); blank clears the entry's notes.
+ [ObservableProperty]
+ private string _editNotes = string.Empty;
+
public bool IsEditing => EditingEntry is not null;
private bool CanEdit(EtbEntryRow row) => !IsReadOnly && row.IsEditable;
@@ -396,6 +401,7 @@ private void BeginEdit(EtbEntryRow row)
{
EditingEntry = row;
EditText = row.Text;
+ EditNotes = row.Notes ?? string.Empty;
ShowEditErrors(false); // a freshly opened panel starts quiet
HistoryEntry = null; // editing and viewing history are separate panels; only one at a time
}
@@ -415,15 +421,27 @@ private void BeginEdit(EtbEntryRow row)
private void SaveEdit()
{
ShowEditErrors(true);
- if (EditTextError is not null)
+ if (EditTextError is not null || EditingEntry is not { } row)
{
return;
}
- _session.EditJournalEntry(EditingEntry!.Id, EditText); // Changed → Sync() renders it
- EditingEntry = null;
- EditText = string.Empty;
- ShowEditErrors(false);
+ // Read everything first: the first write raises Changed, and Sync() closes the panel when
+ // the entry it shows has changed. Each half goes out only when it changed, so a notes-only
+ // save leaves no "bearbeitet" line and sends a joined host one command, not two.
+ var text = EditText;
+ var notes = string.IsNullOrWhiteSpace(EditNotes) ? null : EditNotes.Trim();
+ if (!string.Equals(text.Trim(), row.Text, StringComparison.Ordinal))
+ {
+ _session.EditJournalEntry(row.Id, text); // Changed → Sync() renders it
+ }
+
+ if (!string.Equals(notes, row.Notes, StringComparison.Ordinal))
+ {
+ _session.SetJournalEntryNotes(row.Id, notes);
+ }
+
+ CancelEdit();
_onChanged();
}
@@ -432,6 +450,7 @@ private void CancelEdit()
{
EditingEntry = null;
EditText = string.Empty;
+ EditNotes = string.Empty;
ShowEditErrors(false);
}
@@ -486,6 +505,7 @@ private EtbEntryRow ToRow(EtbEntry e) =>
public sealed class EtbEntryRow : ObservableObject
{
private int? _situationReportNumber;
+ private bool _isNotesExpanded;
public EtbEntryRow(
EtbEntry entry,
@@ -508,8 +528,13 @@ public EtbEntryRow(
WasEdited = entry.Edits.Count > 0;
Edits = entry.Edits;
IsEditable = !EtbDirections.IsAppWritten(entry.Direction);
+ Notes = entry.Notes;
BeginEditCommand = new RelayCommand(() => beginEdit(this), () => canEdit(this));
+ // A click on the row folds its notes in and out (#973); a row without notes has nothing to
+ // fold. Not gated on IsReadOnly: reading the notes of a closed incident is still reading.
+ ToggleNotesCommand = new RelayCommand(() => IsNotesExpanded = HasNotes && !IsNotesExpanded, () => HasNotes);
+
// Deliberately not gated on IsReadOnly/IsEditable like BeginEditCommand: a closed or
// remotely-joined-read-only incident must still let its history be read, since that is the
// one thing that makes an edit acceptable in the first place.
@@ -543,6 +568,29 @@ public EtbEntryRow(
public bool IsEditable { get; }
+ /// The entry's notes (#973), or null when it has none.
+ public string? Notes { get; private set; }
+
+ public bool HasNotes => Notes is not null;
+
+ /// Whether the notes show below the line. Each row starts folded.
+ public bool IsNotesExpanded
+ {
+ get => _isNotesExpanded;
+ private set
+ {
+ if (SetProperty(ref _isNotesExpanded, value))
+ {
+ OnPropertyChanged(nameof(NotesToggleLabel));
+ }
+ }
+ }
+
+ /// What the fold glyph does next, for its tooltip and automation name.
+ public string NotesToggleLabel => IsNotesExpanded ? "Notiz ausblenden" : "Notiz einblenden";
+
+ public IRelayCommand ToggleNotesCommand { get; }
+
public bool CanCreateTask { get; }
public ICommand BeginEditCommand { get; }
@@ -609,7 +657,8 @@ public int? SituationReportNumber
///
/// Re-points this row at the current version of its entry, instead of the view model replacing
/// the row object, which the grid sees as a different item and deselects. An edit changes only
- /// the text and its history ( ), so nothing else is touched.
+ /// the text and its history ( ) or the notes
+ /// ( ), so nothing else is touched.
///
public void Update(EtbEntry entry)
{
@@ -628,5 +677,18 @@ public void Update(EtbEntry entry)
// The first edit is what makes the history viewable at all.
ShowHistoryCommand.NotifyCanExecuteChanged();
+
+ if (!string.Equals(Notes, entry.Notes, StringComparison.Ordinal))
+ {
+ Notes = entry.Notes;
+ OnPropertyChanged(nameof(Notes));
+ OnPropertyChanged(nameof(HasNotes));
+ if (Notes is null)
+ {
+ IsNotesExpanded = false; // nothing left to show
+ }
+
+ ToggleNotesCommand.NotifyCanExecuteChanged();
+ }
}
}
diff --git a/src/LageBuch.Documents/Sections/EtbSection.cs b/src/LageBuch.Documents/Sections/EtbSection.cs
index 56c192f9b..b470bd0e5 100644
--- a/src/LageBuch.Documents/Sections/EtbSection.cs
+++ b/src/LageBuch.Documents/Sections/EtbSection.cs
@@ -53,6 +53,11 @@ public static void Compose(IContainer container, Incident incident)
table.Cell().Element(BodyCell).Column(col =>
{
col.Item().Text(entry.Text);
+ if (entry.Notes is { } notes)
+ {
+ col.Item().PaddingTop(1).Text($"Notiz: {notes}").FontSize(8).FontColor(Colors.Grey.Darken2);
+ }
+
foreach (var edit in entry.Edits)
{
col.Item().Text($"bearbeitet {Formatting.Timestamp(edit.EditedAt)} von {edit.EditedBy}, zuvor: „{edit.PreviousText}“")
diff --git a/src/LageBuch.Domain/Etb/EtbEntry.cs b/src/LageBuch.Domain/Etb/EtbEntry.cs
index db770c9bf..d8aa17cb3 100644
--- a/src/LageBuch.Domain/Etb/EtbEntry.cs
+++ b/src/LageBuch.Domain/Etb/EtbEntry.cs
@@ -26,6 +26,12 @@ private EtbEntry()
public IReadOnlyList Edits { get; private init; } = Array.Empty();
+ ///
+ /// Background or follow-up detail that belongs to this entry without lengthening its line
+ /// (#973). when there is none; never blank.
+ ///
+ public string? Notes { get; private init; }
+
public static EtbEntry Create(
DateTimeOffset timestamp,
EtbDirection direction,
@@ -67,7 +73,8 @@ public static EtbEntry Rehydrate(
string enteredBy,
string? from,
string? to,
- IEnumerable? edits = null)
+ IEnumerable? edits = null,
+ string? notes = null)
=> new()
{
Id = id,
@@ -78,6 +85,7 @@ public static EtbEntry Rehydrate(
From = from,
To = to,
Edits = (edits ?? Enumerable.Empty()).ToList(),
+ Notes = string.IsNullOrWhiteSpace(notes) ? null : notes,
};
///
@@ -114,4 +122,21 @@ public EtbEntry WithEditedText(string newText, SessionOperator editor, DateTimeO
var edits = new List(Edits) { new(Text, editor.Display, editedAt) };
return this with { Text = trimmed, Edits = edits };
}
+
+ ///
+ /// Replaces this entry's notes; blank clears them. Unlike this
+ /// keeps no prior version: the notes are an annotation beside the record, not the record, and
+ /// leaves a System line for every change. The same
+ /// value, ignoring surrounding whitespace, returns this instance, so a resend is no change.
+ ///
+ public EtbEntry WithNotes(string? notes)
+ {
+ if (notes is not null && notes.Length > MaxTextLength)
+ {
+ throw new ArgumentException($"Notiz ist länger als das Limit von {MaxTextLength} Zeichen.", nameof(notes));
+ }
+
+ var normalized = string.IsNullOrWhiteSpace(notes) ? null : notes.Trim();
+ return string.Equals(normalized, Notes, StringComparison.Ordinal) ? this : this with { Notes = normalized };
+ }
}
diff --git a/src/LageBuch.Domain/Incident.cs b/src/LageBuch.Domain/Incident.cs
index 377d72670..05c07874f 100644
--- a/src/LageBuch.Domain/Incident.cs
+++ b/src/LageBuch.Domain/Incident.cs
@@ -570,6 +570,40 @@ public EtbEntry EditJournalEntry(IClock clock, SessionOperator op, Guid entryId,
return edited;
}
+ ///
+ /// Sets or clears the notes of a manually-typed ETB entry (#973). App-written entries carry no
+ /// notes, for the same reason refuses them. A change appends a
+ /// System line, so an annotation added after the fact is as visible as a corrected wording.
+ ///
+ public EtbEntry SetJournalEntryNotes(IClock clock, SessionOperator op, Guid entryId, string? notes)
+ {
+ EnsureOpen();
+ ArgumentNullException.ThrowIfNull(clock);
+ ArgumentNullException.ThrowIfNull(op);
+
+ var index = _journal.FindIndex(e => e.Id == entryId);
+ if (index < 0)
+ {
+ throw new KeyNotFoundException($"ETB-Eintrag {entryId} nicht gefunden.");
+ }
+
+ var existing = _journal[index];
+ if (EtbDirections.IsAppWritten(existing.Direction))
+ {
+ throw new InvalidOperationException(
+ "Automatisch erzeugte Einträge haben keine Notiz.");
+ }
+
+ var updated = existing.WithNotes(notes);
+ if (!ReferenceEquals(updated, existing))
+ {
+ _journal[index] = updated;
+ AppendSystemEntry(clock, op, $"Notiz zu ETB-Eintrag {existing.Timestamp:HH:mm} geändert");
+ }
+
+ return updated;
+ }
+
///
/// Records a new assignment and logs it to the ETB. Mirrors and
/// : creating a new record is always a reportable event, so this logs
diff --git a/src/LageBuch.Persistence/IncidentRepository.cs b/src/LageBuch.Persistence/IncidentRepository.cs
index 975868a14..da5df55ae 100644
--- a/src/LageBuch.Persistence/IncidentRepository.cs
+++ b/src/LageBuch.Persistence/IncidentRepository.cs
@@ -138,7 +138,7 @@ private static void WriteJournal(InsertCommands inserts, Incident incident)
var e = incident.Journal[i];
Run(
inserts,
- "INSERT INTO etb_entries (id, ordinal, timestamp, direction, from_party, to_party, text, entered_by) VALUES ($id,$o,$ts,$dir,$from,$to,$txt,$by);",
+ "INSERT INTO etb_entries (id, ordinal, timestamp, direction, from_party, to_party, text, entered_by, notes) VALUES ($id,$o,$ts,$dir,$from,$to,$txt,$by,$notes);",
p =>
{
p("$id", e.Id.ToString());
@@ -149,6 +149,7 @@ private static void WriteJournal(InsertCommands inserts, Incident incident)
p("$to", (object?)e.To ?? DBNull.Value);
p("$txt", e.Text);
p("$by", e.EnteredBy);
+ p("$notes", (object?)e.Notes ?? DBNull.Value);
});
for (var j = 0; j < e.Edits.Count; j++)
@@ -755,7 +756,7 @@ public static Incident Load(string path)
var journal = ReadAll(
cn,
- "SELECT id, timestamp, direction, from_party, to_party, text, entered_by FROM etb_entries ORDER BY ordinal;",
+ "SELECT id, timestamp, direction, from_party, to_party, text, entered_by, notes FROM etb_entries ORDER BY ordinal;",
r =>
{
var id = Guid.Parse(r.GetString(0));
@@ -767,7 +768,8 @@ public static Incident Load(string path)
r.GetString(6),
Str(r, 3),
Str(r, 4),
- editsByEntry.TryGetValue(id, out var eds) ? eds : null);
+ editsByEntry.TryGetValue(id, out var eds) ? eds : null,
+ Str(r, 7));
});
var roles = ReadAll(
diff --git a/src/LageBuch.Persistence/Sqlite/Migrations.cs b/src/LageBuch.Persistence/Sqlite/Migrations.cs
index b7e4000be..d20ec0878 100644
--- a/src/LageBuch.Persistence/Sqlite/Migrations.cs
+++ b/src/LageBuch.Persistence/Sqlite/Migrations.cs
@@ -8,7 +8,7 @@ namespace LageBuch.Persistence.Sqlite;
public static class Migrations
{
- public const int CurrentVersion = 45;
+ public const int CurrentVersion = 46;
public static int GetVersion(SqliteConnection cn)
{
@@ -310,6 +310,11 @@ public static void Migrate(SqliteConnection cn)
ApplyV45(cn, tx);
}
+ if (version < 46)
+ {
+ ApplyV46(cn, tx);
+ }
+
// The version gate above is not proof that the steps it skipped ever ran: a build from a
// parallel branch numbers its own migrations too, so a file can carry a marker this lineage
// never put there and be missing a column no `version < N` will ever add back. Reconcile the
@@ -1364,6 +1369,16 @@ private static void ApplyV45(SqliteConnection cn, SqliteTransaction tx)
// Stryker restore all
}
+ // The notes folded under a user-written ETB entry (#973). Additive and nullable: an entry
+ // from an older file has none, so it reads exactly as it did.
+ // Stryker disable all : SchemaGuard.Reconcile adds this same column on every open (see V26).
+ private static void ApplyV46(SqliteConnection cn, SqliteTransaction tx)
+ {
+ SchemaHelpers.AddColumnIfMissing(cn, tx, "etb_entries", "notes", "TEXT");
+
+ // Stryker restore all
+ }
+
[SuppressMessage(
"Security",
"CA2100",
diff --git a/src/LageBuch.Persistence/Sqlite/SchemaGuard.cs b/src/LageBuch.Persistence/Sqlite/SchemaGuard.cs
index d86164622..704797758 100644
--- a/src/LageBuch.Persistence/Sqlite/SchemaGuard.cs
+++ b/src/LageBuch.Persistence/Sqlite/SchemaGuard.cs
@@ -99,6 +99,7 @@ internal static class SchemaGuard
new("command_nodes", "fuehrungsfahrzeug", "TEXT", false, null),
new("etb_entries", "from_party", "TEXT", false, null),
new("etb_entries", "to_party", "TEXT", false, null),
+ new("etb_entries", "notes", "TEXT", false, null),
new("force_unit_edits", "previous_zugfuehrer_count", "INTEGER", true, "0"),
new("force_units", "call_sign", "TEXT", false, null),
new("force_units", "status", "TEXT", false, null),
diff --git a/src/LageBuch.Sync/CommandApplier.cs b/src/LageBuch.Sync/CommandApplier.cs
index 017a19e38..2b2dbbd37 100644
--- a/src/LageBuch.Sync/CommandApplier.cs
+++ b/src/LageBuch.Sync/CommandApplier.cs
@@ -45,6 +45,9 @@ public static class CommandApplier
case EditJournalEntryCommand c:
incident.EditJournalEntry(clock, Operator(c.Operator), c.EntryId, c.Text);
break;
+ case SetJournalEntryNotesCommand c:
+ incident.SetJournalEntryNotes(clock, Operator(c.Operator), c.EntryId, c.Notes);
+ break;
case ChangeOperatorCommand c:
incident.ChangeOperator(clock, Operator(c.From), Operator(c.To));
break;
diff --git a/src/LageBuch.Sync/IIncidentSession.cs b/src/LageBuch.Sync/IIncidentSession.cs
index 751c666f0..4c5307a89 100644
--- a/src/LageBuch.Sync/IIncidentSession.cs
+++ b/src/LageBuch.Sync/IIncidentSession.cs
@@ -62,6 +62,9 @@ public interface IIncidentSession
void EditJournalEntry(Guid entryId, string text);
+ /// Sets the notes of a user-written ETB entry; null or blank clears them (#973).
+ void SetJournalEntryNotes(Guid entryId, string? notes);
+
void ToggleChecklistItem(Guid itemId);
void AssignRole(
diff --git a/src/LageBuch.Sync/IncidentSnapshot.cs b/src/LageBuch.Sync/IncidentSnapshot.cs
index 53cb41df5..4700b0982 100644
--- a/src/LageBuch.Sync/IncidentSnapshot.cs
+++ b/src/LageBuch.Sync/IncidentSnapshot.cs
@@ -131,7 +131,8 @@ public sealed record EtbEntryDto(
string EnteredBy,
string? From,
string? To,
- IReadOnlyList Edits);
+ IReadOnlyList Edits,
+ string? Notes = null);
public sealed record EtbEntryEditDto(string PreviousText, string EditedBy, DateTimeOffset EditedAt);
diff --git a/src/LageBuch.Sync/RemoteIncidentSession.cs b/src/LageBuch.Sync/RemoteIncidentSession.cs
index 77b278c2a..9a312cf2b 100644
--- a/src/LageBuch.Sync/RemoteIncidentSession.cs
+++ b/src/LageBuch.Sync/RemoteIncidentSession.cs
@@ -457,6 +457,9 @@ public Guid AddJournalEntry(EtbDirection direction, string text, string? from =
public void EditJournalEntry(Guid entryId, string text) =>
Send(new EditJournalEntryCommand(Op(), entryId, text));
+ public void SetJournalEntryNotes(Guid entryId, string? notes) =>
+ Send(new SetJournalEntryNotesCommand(Op(), entryId, notes));
+
public void ToggleChecklistItem(Guid itemId) => Send(new ToggleChecklistItemCommand(Op(), itemId));
public void AssignRole(
diff --git a/src/LageBuch.Sync/SnapshotMapper.cs b/src/LageBuch.Sync/SnapshotMapper.cs
index d8fc2506c..c33f873a7 100644
--- a/src/LageBuch.Sync/SnapshotMapper.cs
+++ b/src/LageBuch.Sync/SnapshotMapper.cs
@@ -49,7 +49,8 @@ public static IncidentSnapshot ToSnapshot(Incident incident)
e.EnteredBy,
e.From,
e.To,
- e.Edits.Select(x => new EtbEntryEditDto(x.PreviousText, x.EditedBy, x.EditedAt)).ToList())).ToList(),
+ e.Edits.Select(x => new EtbEntryEditDto(x.PreviousText, x.EditedBy, x.EditedAt)).ToList(),
+ e.Notes)).ToList(),
incident.Roles.Select(r => new RoleAssignmentDto(r.Id, r.Role, r.PersonName, r.CallSign, r.From, r.To, r.Section, r.Phone, r.NodeId, r.Slot)).ToList(),
incident.Forces.Select(f => new ForceUnitDto(
f.Id,
@@ -190,7 +191,8 @@ public static Incident FromSnapshot(IncidentSnapshot snapshot)
e.EnteredBy,
e.From,
e.To,
- e.Edits.Select(x => new EtbEntryEdit(x.PreviousText, x.EditedBy, x.EditedAt)))),
+ e.Edits.Select(x => new EtbEntryEdit(x.PreviousText, x.EditedBy, x.EditedAt)),
+ e.Notes)),
snapshot.Roles.Select(r => new RoleAssignment(r.Id, r.Role, r.PersonName, r.CallSign, r.From, r.To, r.Section, r.Phone, r.NodeId, r.Slot)),
snapshot.Forces.Select(f => ForceUnit.Rehydrate(
f.Id,
diff --git a/src/LageBuch.Sync/SyncCommand.cs b/src/LageBuch.Sync/SyncCommand.cs
index e03ff4cf8..058e5d896 100644
--- a/src/LageBuch.Sync/SyncCommand.cs
+++ b/src/LageBuch.Sync/SyncCommand.cs
@@ -16,6 +16,7 @@ namespace LageBuch.Sync;
[JsonPolymorphic(TypeDiscriminatorPropertyName = "$type")]
[JsonDerivedType(typeof(AddJournalEntryCommand), "addJournalEntry")]
[JsonDerivedType(typeof(EditJournalEntryCommand), "editJournalEntry")]
+[JsonDerivedType(typeof(SetJournalEntryNotesCommand), "setJournalEntryNotes")]
[JsonDerivedType(typeof(ToggleChecklistItemCommand), "toggleChecklistItem")]
[JsonDerivedType(typeof(AssignRoleCommand), "assignRole")]
[JsonDerivedType(typeof(TransferRoleCommand), "transferRole")]
@@ -100,6 +101,9 @@ public sealed record AddJournalEntryCommand(
public sealed record EditJournalEntryCommand(OperatorDto Operator, Guid EntryId, string Text) : SyncCommand;
+/// Sets or clears (null ) the notes of a user-written ETB entry (#973).
+public sealed record SetJournalEntryNotesCommand(OperatorDto Operator, Guid EntryId, string? Notes) : SyncCommand;
+
/// A new Lagebuchführer takes over at the sending device (#469). Only the ETB line and
/// the audit event need the host: every later command already carries the new operator.
public sealed record ChangeOperatorCommand(OperatorDto From, OperatorDto To) : SyncCommand;
diff --git a/src/LageBuch.Sync/SyncProtocol.cs b/src/LageBuch.Sync/SyncProtocol.cs
index 5535bfb72..6bcd41cf4 100644
--- a/src/LageBuch.Sync/SyncProtocol.cs
+++ b/src/LageBuch.Sync/SyncProtocol.cs
@@ -249,15 +249,19 @@ public static class SyncProtocol
/// Fahrzeugtyp is filled from. A peer at 42 drops the key and reads none, which only leaves its
/// new vehicles to be typed by hand, so the floor stays at 40.
///
+ ///
+ /// 44: a client may send setJournalEntryNotes , and the snapshot's ETB entries carry an
+ /// optional notes (#973). A host at 43 would reject the command, so the floor rises to 44.
+ ///
///
- public const int ProtocolVersion = 43;
+ public const int ProtocolVersion = 44;
///
/// The oldest contract this build still speaks. A peer below it is refused with a message naming
/// which end to update; a peer at or above it is served. See for
/// when to raise this.
///
- public const int MinimumProtocolVersion = 40;
+ public const int MinimumProtocolVersion = 44;
///
/// What an absent or zero protocol number on the wire means: the contract as it stood at v0.6.1,
diff --git a/tests/LageBuch.Acceptance.Tests/AutomationPropertiesTests.cs b/tests/LageBuch.Acceptance.Tests/AutomationPropertiesTests.cs
index efaf7c527..56c771764 100644
--- a/tests/LageBuch.Acceptance.Tests/AutomationPropertiesTests.cs
+++ b/tests/LageBuch.Acceptance.Tests/AutomationPropertiesTests.cs
@@ -173,6 +173,7 @@ public void Etb_row_action_buttons_are_named_for_automation()
var row = vm.Entries[0];
row.BeginEditCommand.Execute(null);
vm.EditText = "Lagemeldung (korrigiert)";
+ vm.EditNotes = "Rückruf zugesagt"; // and the fold glyph shows (#973)
vm.SaveEditCommand.Execute(null);
var view = new EtbView { DataContext = vm };
@@ -181,7 +182,7 @@ public void Etb_row_action_buttons_are_named_for_automation()
Dispatcher.UIThread.RunJobs();
var buttons = IconButtons(view);
- Assert.Equal(3, buttons.Count); // Bearbeiten, Verlauf (bearbeitet), Aufgabe erstellen
+ Assert.Equal(4, buttons.Count); // Notiz einblenden, Bearbeiten, Verlauf (bearbeitet), Aufgabe erstellen
foreach (var button in buttons)
{
var tip = ToolTip.GetTip(button) as string;
diff --git a/tests/LageBuch.Acceptance.Tests/EtbNotesFoldTests.cs b/tests/LageBuch.Acceptance.Tests/EtbNotesFoldTests.cs
new file mode 100644
index 000000000..41bcb764b
--- /dev/null
+++ b/tests/LageBuch.Acceptance.Tests/EtbNotesFoldTests.cs
@@ -0,0 +1,169 @@
+using Avalonia;
+using Avalonia.Automation;
+using Avalonia.Controls;
+using Avalonia.Headless;
+using Avalonia.Headless.XUnit;
+using Avalonia.Input;
+using Avalonia.Threading;
+using Avalonia.VisualTree;
+using LageBuch.App.Shared.Views;
+using LageBuch.AppLogic.Services;
+using LageBuch.AppLogic.ViewModels;
+using LageBuch.Domain;
+using LageBuch.Persistence.MasterData;
+
+namespace LageBuch.Acceptance.Tests;
+
+// #973: a click on an entry's line unfolds its notes below it, and a second click folds them in.
+// With RENDER_OUT= the tests also write the PR's screenshots.
+public class EtbNotesFoldTests
+{
+ private const string Notes = "Rückruf über Festnetz zugesagt, Ansprechpartner vor Ort ist der Hausmeister.";
+
+ private static (Window Window, IncidentWorkspaceViewModel Vm) ShowWorkspace(double width = 1920)
+ {
+ var clock = new FixedClock();
+ var session = TestSession.StartNew(
+ new FakeStore(),
+ clock,
+ new SessionOperator(AnonymizedExampleData.OperatorSurname, "FFB 12/1"),
+ "/x.lagebuch",
+ Array.Empty<(string, bool)>(),
+ Array.Empty<(string, bool)>());
+ var vm = new IncidentWorkspaceViewModel(
+ session,
+ clock,
+ new NoopTicker(),
+ WorkspaceRenderHelper.MasterData(),
+ new FakeDialogs(),
+ new NoopAlarmService(),
+ new NoopIncidentHostController());
+ var window = new Window { Content = new IncidentWorkspaceView { DataContext = vm }, Width = width, Height = 1032 };
+ window.Show();
+ Dispatcher.UIThread.RunJobs();
+ WorkspaceRenderHelper.SelectTab(window, "ETB");
+ return (window, vm);
+ }
+
+ private static EtbEntryRow AddEntry(IncidentWorkspaceViewModel vm, string text, string? notes)
+ {
+ vm.Etb.NewFrom = AnonymizedExampleData.CallSign;
+ vm.Etb.NewTo = "ELW";
+ vm.Etb.NewText = text;
+ vm.Etb.AddEntryCommand.Execute(null);
+ var row = vm.Etb.Entries.Single(e => e.Text == text);
+ if (notes is not null)
+ {
+ row.BeginEditCommand.Execute(null);
+ vm.Etb.EditNotes = notes;
+ vm.Etb.SaveEditCommand.Execute(null);
+ }
+
+ Dispatcher.UIThread.RunJobs();
+ return row;
+ }
+
+ private static DataGrid Grid(Window window) =>
+ window.GetVisualDescendants().OfType().Single(g => g.Name == "EtbGrid");
+
+ private static DataGridCell TextCell(DataGrid grid, EtbEntryRow row) =>
+ grid.GetVisualDescendants().OfType()
+ .First(c => ReferenceEquals(c.DataContext, row)
+ && DataGridColumn.GetColumnContainingElement(c) is { Header: "EINTRAG" });
+
+ private static void Click(Window window, Visual target)
+ {
+ var point = target.TranslatePoint(new Point(4, 4), window) ?? throw new InvalidOperationException("Not in the window.");
+ window.MouseDown(point, MouseButton.Left, RawInputModifiers.None);
+ window.MouseUp(point, MouseButton.Left, RawInputModifiers.None);
+ Dispatcher.UIThread.RunJobs();
+ }
+
+ private static bool NotesShown(Visual within) =>
+ within.GetVisualDescendants().OfType().Any(t => t.Text == Notes && t.IsEffectivelyVisible);
+
+ private static void Shoot(Window window, string name)
+ {
+ if (Environment.GetEnvironmentVariable("RENDER_OUT") is not { Length: > 0 } dir)
+ {
+ return;
+ }
+
+ Directory.CreateDirectory(dir);
+ using var frame = window.CaptureRenderedFrame()!;
+ frame.SavePng(Path.Join(dir, name));
+ }
+
+ [AvaloniaFact]
+ public void Clicking_a_row_with_notes_unfolds_them_and_a_second_click_folds_them_in()
+ {
+ var (window, vm) = ShowWorkspace();
+ AddEntry(vm, "Erkundung Hauptstraße 12 abgeschlossen", null);
+ var row = AddEntry(vm, "Hausverwaltung verständigt", Notes);
+ var grid = Grid(window);
+ Assert.False(NotesShown(grid));
+
+ // The folded row says it has notes.
+ var toggle = TextCell(grid, row).GetVisualDescendants().OfType().Single(b => b.Name == "NotesToggle");
+ Assert.True(toggle.IsEffectivelyVisible);
+ Assert.Equal("Notiz einblenden", AutomationProperties.GetName(toggle));
+ Shoot(window, "etb-notes-folded.png");
+
+ Click(window, TextCell(grid, row));
+ Assert.True(row.IsNotesExpanded);
+ Assert.True(NotesShown(grid));
+ Assert.Equal("Notiz ausblenden", AutomationProperties.GetName(toggle));
+ Shoot(window, "etb-notes-unfolded.png");
+
+ // A second click in quick succession arrives as a double tap; it folds all the same.
+ Click(window, TextCell(grid, row));
+ Assert.False(row.IsNotesExpanded);
+ Assert.False(NotesShown(grid));
+ }
+
+ [AvaloniaFact]
+ public void Clicking_a_row_without_notes_unfolds_nothing_and_shows_no_glyph()
+ {
+ var (window, vm) = ShowWorkspace();
+ var row = AddEntry(vm, "Erkundung Hauptstraße 12 abgeschlossen", null);
+ var grid = Grid(window);
+
+ Click(window, TextCell(grid, row));
+
+ Assert.False(row.IsNotesExpanded);
+ Assert.False(TextCell(grid, row).GetVisualDescendants().OfType().Single(b => b.Name == "NotesToggle").IsEffectivelyVisible);
+ }
+
+ [AvaloniaFact]
+ public void Enter_on_a_clicked_row_with_notes_still_opens_the_edit_panel()
+ {
+ var (window, vm) = ShowWorkspace();
+ var row = AddEntry(vm, "Hausverwaltung verständigt", Notes);
+ var grid = Grid(window);
+ Click(window, TextCell(grid, row));
+
+ window.Press(PhysicalKey.Enter);
+
+ Assert.Same(row, vm.Etb.EditingEntry);
+ Assert.Equal(Notes, vm.Etb.EditNotes);
+ var notesBox = window.GetVisualDescendants().OfType().Single(t => t.Name == "EditNotesBox");
+ Assert.True(notesBox.IsEffectivelyVisible);
+ Shoot(window, "etb-notes-edit-panel.png");
+ }
+
+ [AvaloniaFact]
+ public void Tapping_a_card_with_notes_unfolds_them()
+ {
+ var (window, vm) = ShowWorkspace(width: 412);
+ var row = AddEntry(vm, "Hausverwaltung verständigt", Notes);
+ var cards = window.GetVisualDescendants().OfType().Single(i => i.Name == "EtbCards");
+ Assert.True(cards.IsEffectivelyVisible);
+ var card = cards.GetVisualDescendants().OfType()
+ .First(b => b.Classes.Contains("row-card") && ReferenceEquals(b.DataContext, row));
+
+ Click(window, card);
+
+ Assert.True(row.IsNotesExpanded);
+ Assert.True(NotesShown(cards));
+ }
+}
diff --git a/tests/LageBuch.AppLogic.Tests/CoMessprotokollViewModelTests.cs b/tests/LageBuch.AppLogic.Tests/CoMessprotokollViewModelTests.cs
index d693ecdb5..0052dc850 100644
--- a/tests/LageBuch.AppLogic.Tests/CoMessprotokollViewModelTests.cs
+++ b/tests/LageBuch.AppLogic.Tests/CoMessprotokollViewModelTests.cs
@@ -1260,6 +1260,8 @@ public Guid AddJournalEntry(EtbDirection direction, string text, string? from =
public void EditJournalEntry(Guid entryId, string text) => _inner.EditJournalEntry(entryId, text);
+ public void SetJournalEntryNotes(Guid entryId, string? notes) => _inner.SetJournalEntryNotes(entryId, notes);
+
public void ToggleChecklistItem(Guid itemId) => _inner.ToggleChecklistItem(itemId);
public void AssignRole(
diff --git a/tests/LageBuch.AppLogic.Tests/EtbViewModelTests.cs b/tests/LageBuch.AppLogic.Tests/EtbViewModelTests.cs
index 605582095..a13d1bd77 100644
--- a/tests/LageBuch.AppLogic.Tests/EtbViewModelTests.cs
+++ b/tests/LageBuch.AppLogic.Tests/EtbViewModelTests.cs
@@ -355,6 +355,245 @@ public void SaveEdit_writes_through_and_clears_edit_state()
Assert.True(row.WasEdited);
}
+ [Fact]
+ public void BeginEdit_populates_EditNotes_from_the_entry()
+ {
+ var vm = NewVm();
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+ vm.EditNotes = "Rückruf zugesagt";
+ vm.SaveEditCommand.Execute(null);
+ var row = Assert.Single(vm.Entries, e => e.Text == "Lagemeldung");
+
+ row.BeginEditCommand.Execute(null);
+
+ Assert.Equal("Rückruf zugesagt", vm.EditNotes);
+ }
+
+ [Fact]
+ public void SaveEdit_with_only_new_notes_sets_the_notes_and_leaves_the_text_unedited()
+ {
+ var vm = NewVm(out var session);
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+
+ vm.EditNotes = " Rückruf über Festnetz zugesagt ";
+ vm.SaveEditCommand.Execute(null);
+
+ Assert.False(vm.IsEditing);
+ Assert.Equal(string.Empty, vm.EditNotes);
+ var row = Assert.Single(vm.Entries, e => e.Text == "Lagemeldung");
+ Assert.Equal("Rückruf über Festnetz zugesagt", row.Notes);
+ Assert.True(row.HasNotes);
+ Assert.False(row.WasEdited);
+ Assert.DoesNotContain(session.Incident.Journal, e => e.Text.EndsWith("bearbeitet", StringComparison.Ordinal));
+ Assert.Single(session.Incident.Journal, e => e.Text.StartsWith("Notiz zu ETB-Eintrag", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void SaveEdit_with_only_new_text_writes_no_notes_trace()
+ {
+ var vm = NewVm(out var session);
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+
+ vm.EditText = "Lagemeldung korrigiert";
+ vm.SaveEditCommand.Execute(null);
+
+ var row = Assert.Single(vm.Entries, e => e.Text == "Lagemeldung korrigiert");
+ Assert.Null(row.Notes);
+ Assert.DoesNotContain(session.Incident.Journal, e => e.Text.StartsWith("Notiz zu", StringComparison.Ordinal));
+ }
+
+ [Fact]
+ public void SaveEdit_changes_text_and_notes_together()
+ {
+ var vm = NewVm(out _);
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+
+ vm.EditText = "Lagemeldung korrigiert";
+ vm.EditNotes = "Rückruf zugesagt";
+ vm.SaveEditCommand.Execute(null);
+
+ var row = Assert.Single(vm.Entries, e => e.Text == "Lagemeldung korrigiert");
+ Assert.Equal("Rückruf zugesagt", row.Notes);
+ Assert.True(row.WasEdited);
+ }
+
+ [Fact]
+ public void Emptying_the_notes_clears_them_and_folds_the_row()
+ {
+ var vm = NewVm();
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+ vm.EditNotes = "Rückruf zugesagt";
+ vm.SaveEditCommand.Execute(null);
+ var row = Assert.Single(vm.Entries, e => e.Text == "Lagemeldung");
+ row.ToggleNotesCommand.Execute(null);
+ Assert.True(row.IsNotesExpanded);
+
+ row.BeginEditCommand.Execute(null);
+ vm.EditNotes = " ";
+ vm.SaveEditCommand.Execute(null);
+
+ Assert.Null(row.Notes);
+ Assert.False(row.HasNotes);
+ Assert.False(row.IsNotesExpanded);
+ Assert.False(row.ToggleNotesCommand.CanExecute(null));
+ }
+
+ [Fact]
+ public void Notes_reach_the_row_through_a_snapshot_round_trip()
+ {
+ var clock = new FixedClock(T0);
+ var inner = TestSession.StartNew(
+ new FakeStore(),
+ clock,
+ new SessionOperator("Müller"),
+ "/x.lagebuch",
+ Array.Empty<(string, bool)>(),
+ Array.Empty<(string, bool)>());
+ var vm = new EtbViewModel(new SnapshotRoundTrippingSession(inner), clock, MasterDataSet.Empty, () => { });
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ var row = Assert.Single(vm.Entries, e => e.Text == "Lagemeldung");
+ row.BeginEditCommand.Execute(null);
+
+ vm.EditNotes = "Rückruf zugesagt";
+ vm.SaveEditCommand.Execute(null);
+
+ Assert.Same(row, Assert.Single(vm.Entries, e => e.Text == "Lagemeldung"));
+ Assert.Equal("Rückruf zugesagt", row.Notes);
+ }
+
+ [Fact]
+ public void ToggleNotes_unfolds_and_folds_a_row_with_notes()
+ {
+ var vm = NewVm();
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+ vm.EditNotes = "Rückruf zugesagt";
+ vm.SaveEditCommand.Execute(null);
+ var row = Assert.Single(vm.Entries, e => e.Text == "Lagemeldung");
+ Assert.False(row.IsNotesExpanded);
+ Assert.Equal("Notiz einblenden", row.NotesToggleLabel);
+
+ row.ToggleNotesCommand.Execute(null);
+ Assert.True(row.IsNotesExpanded);
+ Assert.Equal("Notiz ausblenden", row.NotesToggleLabel);
+
+ row.ToggleNotesCommand.Execute(null);
+ Assert.False(row.IsNotesExpanded);
+ }
+
+ [Fact]
+ public void Saving_unchanged_text_and_blank_notes_sends_nothing_and_closes_the_panel()
+ {
+ var vm = NewVm(out var session);
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+ vm.EditNotes = " ";
+ var changes = 0;
+ session.Changed += () => changes++;
+
+ vm.SaveEditCommand.Execute(null);
+
+ Assert.Equal(0, changes);
+ Assert.False(vm.IsEditing);
+ }
+
+ [Fact]
+ public void An_unrelated_change_leaves_the_edit_panel_open()
+ {
+ var vm = NewVm(out var session);
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ var row = vm.Entries[0];
+ row.BeginEditCommand.Execute(null);
+
+ session.AddJournalEntry(EtbDirection.Incoming, "Rückmeldung ILS");
+
+ Assert.Same(row, vm.EditingEntry);
+ }
+
+ [Fact]
+ public void Toggling_notes_announces_the_new_glyph_label()
+ {
+ var vm = NewVm();
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+ vm.EditNotes = "Rückruf zugesagt";
+ vm.SaveEditCommand.Execute(null);
+ var row = Assert.Single(vm.Entries, e => e.Text == "Lagemeldung");
+ var raised = new List();
+ row.PropertyChanged += (_, e) => raised.Add(e.PropertyName);
+
+ row.ToggleNotesCommand.Execute(null);
+
+ Assert.Contains(nameof(EtbEntryRow.IsNotesExpanded), raised);
+ Assert.Contains(nameof(EtbEntryRow.NotesToggleLabel), raised);
+ }
+
+ [Fact]
+ public void Notes_arriving_on_a_row_announce_themselves_and_enable_the_toggle()
+ {
+ var vm = NewVm();
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ var row = vm.Entries[0];
+ var raised = new List();
+ row.PropertyChanged += (_, e) => raised.Add(e.PropertyName);
+ var canExecuteChanged = 0;
+ row.ToggleNotesCommand.CanExecuteChanged += (_, _) => canExecuteChanged++;
+
+ row.BeginEditCommand.Execute(null);
+ vm.EditNotes = "Rückruf zugesagt";
+ vm.SaveEditCommand.Execute(null);
+
+ Assert.Contains(nameof(EtbEntryRow.Notes), raised);
+ Assert.Contains(nameof(EtbEntryRow.HasNotes), raised);
+ Assert.True(canExecuteChanged > 0);
+ Assert.True(row.ToggleNotesCommand.CanExecute(null));
+ }
+
+ [Fact]
+ public void ToggleNotes_does_nothing_on_a_row_without_notes()
+ {
+ var vm = NewVm();
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ var row = vm.Entries[0];
+
+ Assert.False(row.ToggleNotesCommand.CanExecute(null));
+ row.ToggleNotesCommand.Execute(null);
+
+ Assert.False(row.IsNotesExpanded);
+ }
+
+ [Fact]
+ public void Cancelling_the_edit_discards_typed_notes()
+ {
+ var vm = NewVm();
+ vm.NewText = "Lagemeldung";
+ vm.AddEntryCommand.Execute(null);
+ vm.Entries[0].BeginEditCommand.Execute(null);
+ vm.EditNotes = "Verworfen";
+
+ vm.CancelEditCommand.Execute(null);
+
+ Assert.Equal(string.Empty, vm.EditNotes);
+ Assert.Null(vm.Entries[0].Notes);
+ }
+
[Fact]
public void SaveEdit_names_the_emptied_entry_rather_than_going_grey()
{
@@ -810,6 +1049,19 @@ private static EtbViewModel NewVm(MasterDataSet masterData, Action offerReminder
NewSession(clock), clock, masterData, () => { }, createTask is null ? null : (text, _) => createTask(text), offerReminderReset);
}
+ private static EtbViewModel NewVm(out LocalIncidentSession session)
+ {
+ var clock = new FixedClock(T0);
+ session = TestSession.StartNew(
+ new FakeStore(),
+ clock,
+ new SessionOperator("Müller"),
+ "/x.lagebuch",
+ Array.Empty<(string, bool)>(),
+ Array.Empty<(string, bool)>());
+ return new EtbViewModel(session, clock, MasterDataSet.Empty, () => { });
+ }
+
private static EtbViewModel NewVm()
{
var clock = new FixedClock(T0);
diff --git a/tests/LageBuch.Documents.Tests/EtbSectionTests.cs b/tests/LageBuch.Documents.Tests/EtbSectionTests.cs
index f622cbe77..e270b057a 100644
--- a/tests/LageBuch.Documents.Tests/EtbSectionTests.cs
+++ b/tests/LageBuch.Documents.Tests/EtbSectionTests.cs
@@ -56,6 +56,21 @@ public void An_edited_entry_shows_its_current_text_and_every_earlier_wording_in_
"bearbeitet 22.06.2026 09:09 von Mayr, zuvor: „Zweit“ Huber");
}
+ // #973: the notes folded under an entry on screen are part of the record, so the Bericht prints them.
+ [Fact]
+ public void An_entrys_notes_print_under_its_text()
+ {
+ var clock = new FixedClock(Started);
+ var op = new SessionOperator("Huber");
+ var incident = Incident.Start(clock, op);
+ var entry = incident.AddJournalEntry(clock, op, EtbDirection.Incoming, "Lagemeldung");
+ incident.SetJournalEntryNotes(clock, op, entry.Id, "Rückruf über Festnetz zugesagt");
+
+ var text = PdfText.Of(incident, Started, IncidentPdfSections.Etb);
+
+ PdfText.AssertInOrder(text, "Lagemeldung Notiz: Rückruf über Festnetz zugesagt Huber");
+ }
+
[Fact]
public void Without_entries_the_section_says_so_instead_of_an_empty_table()
{
diff --git a/tests/LageBuch.Domain.Tests/EtbEntryTests.cs b/tests/LageBuch.Domain.Tests/EtbEntryTests.cs
index 68085a1d7..2810f43d6 100644
--- a/tests/LageBuch.Domain.Tests/EtbEntryTests.cs
+++ b/tests/LageBuch.Domain.Tests/EtbEntryTests.cs
@@ -147,4 +147,81 @@ public void Sequential_edits_accumulate_history_in_order()
Assert.Equal("v1", afterSecond.Edits[0].PreviousText);
Assert.Equal("v2", afterSecond.Edits[1].PreviousText);
}
+
+ [Fact]
+ public void A_new_entry_has_no_notes()
+ {
+ var entry = EtbEntry.Create(At, EtbDirection.Internal, "Lage erkundet", new SessionOperator("Müller"));
+
+ Assert.Null(entry.Notes);
+ }
+
+ [Fact]
+ public void WithNotes_sets_trimmed_notes_and_leaves_text_and_history_alone()
+ {
+ var entry = EtbEntry.Create(At, EtbDirection.Incoming, "Lagemeldung", new SessionOperator("Müller"), from: "ILS");
+
+ var noted = entry.WithNotes(" Rückruf über Festnetz zugesagt ");
+
+ Assert.Equal("Rückruf über Festnetz zugesagt", noted.Notes);
+ Assert.Equal(entry.Id, noted.Id);
+ Assert.Equal("Lagemeldung", noted.Text);
+ Assert.Empty(noted.Edits);
+ }
+
+ [Theory]
+ [InlineData(null)]
+ [InlineData("")]
+ [InlineData(" ")]
+ public void WithNotes_clears_the_notes_when_given_nothing(string? blank)
+ {
+ var noted = EtbEntry.Create(At, EtbDirection.Internal, "Lage", new SessionOperator("Müller")).WithNotes("Hinweis");
+
+ Assert.Null(noted.WithNotes(blank).Notes);
+ }
+
+ [Fact]
+ public void WithNotes_is_a_no_op_when_the_notes_are_unchanged()
+ {
+ var noted = EtbEntry.Create(At, EtbDirection.Internal, "Lage", new SessionOperator("Müller")).WithNotes("Hinweis");
+
+ Assert.Same(noted, noted.WithNotes(" Hinweis "));
+ }
+
+ [Fact]
+ public void WithNotes_rejects_notes_longer_than_the_limit()
+ {
+ var entry = EtbEntry.Create(At, EtbDirection.Internal, "Lage", new SessionOperator("Müller"));
+
+ var ex = Assert.Throws(() => entry.WithNotes(new string('x', EtbEntry.MaxTextLength + 1)));
+ Assert.StartsWith($"Notiz ist länger als das Limit von {EtbEntry.MaxTextLength} Zeichen.", ex.Message, StringComparison.Ordinal);
+ }
+
+ [Theory]
+ [InlineData(null, null)]
+ [InlineData("", null)]
+ [InlineData(" ", null)]
+ [InlineData("Rückruf zugesagt", "Rückruf zugesagt")]
+ public void Rehydrate_reads_blank_notes_as_none(string? stored, string? expected)
+ {
+ var entry = EtbEntry.Rehydrate(Guid.NewGuid(), At, EtbDirection.Internal, "Lage", "Müller", null, null, null, stored);
+
+ Assert.Equal(expected, entry.Notes);
+ }
+
+ [Fact]
+ public void WithNotes_accepts_notes_at_exactly_the_limit()
+ {
+ var entry = EtbEntry.Create(At, EtbDirection.Internal, "Lage", new SessionOperator("Müller"));
+
+ Assert.Equal(EtbEntry.MaxTextLength, entry.WithNotes(new string('x', EtbEntry.MaxTextLength)).Notes?.Length);
+ }
+
+ [Fact]
+ public void WithEditedText_keeps_the_notes()
+ {
+ var noted = EtbEntry.Create(At, EtbDirection.Internal, "Lage", new SessionOperator("Müller")).WithNotes("Hinweis");
+
+ Assert.Equal("Hinweis", noted.WithEditedText("Lage neu", new SessionOperator("Schmidt"), At).Notes);
+ }
}
diff --git a/tests/LageBuch.Domain.Tests/IncidentOperationsTests.cs b/tests/LageBuch.Domain.Tests/IncidentOperationsTests.cs
index 8b3fb9567..e0b45d8d8 100644
--- a/tests/LageBuch.Domain.Tests/IncidentOperationsTests.cs
+++ b/tests/LageBuch.Domain.Tests/IncidentOperationsTests.cs
@@ -401,6 +401,94 @@ public void Edit_journal_entry_throws_when_incident_closed()
() => incident.EditJournalEntry(clock, op, entry.Id, "Korrigiert"));
}
+ [Fact]
+ public void Setting_notes_on_an_entry_stores_them_and_appends_a_system_trace()
+ {
+ var incident = NewIncident(out var clock, out var op);
+ var entry = incident.AddJournalEntry(clock, op, EtbDirection.Incoming, "Lagemeldung");
+ clock.Now = T0.AddMinutes(5);
+
+ var noted = incident.SetJournalEntryNotes(clock, op, entry.Id, "Rückruf zugesagt");
+
+ Assert.Equal("Rückruf zugesagt", noted.Notes);
+ Assert.Equal(noted, incident.Journal.Single(e => e.Id == entry.Id));
+ var trace = incident.Journal[^1];
+ Assert.Equal(EtbDirection.System, trace.Direction);
+ Assert.Equal($"Notiz zu ETB-Eintrag {T0:HH:mm} geändert", trace.Text);
+ Assert.Equal(T0.AddMinutes(5), trace.Timestamp);
+ }
+
+ [Fact]
+ public void Setting_unchanged_notes_appends_no_system_trace()
+ {
+ var incident = NewIncident(out var clock, out var op);
+ var entry = incident.AddJournalEntry(clock, op, EtbDirection.Incoming, "Lagemeldung");
+ incident.SetJournalEntryNotes(clock, op, entry.Id, "Rückruf zugesagt");
+ var before = incident.Journal.Count;
+
+ incident.SetJournalEntryNotes(clock, op, entry.Id, "Rückruf zugesagt");
+
+ Assert.Equal(before, incident.Journal.Count);
+ }
+
+ [Fact]
+ public void Setting_notes_throws_on_a_System_entry()
+ {
+ var incident = NewIncident(out var clock, out var op);
+ incident.ResumeEditing(clock, op);
+ var systemEntry = incident.Journal.Single(e => e.Text == "Bearbeitung fortgesetzt");
+
+ var ex = Assert.Throws(
+ () => incident.SetJournalEntryNotes(clock, op, systemEntry.Id, "Notiz"));
+ Assert.Equal("Automatisch erzeugte Einträge haben keine Notiz.", ex.Message);
+ }
+
+ [Fact]
+ public void Setting_notes_on_the_first_journal_entry_is_refused_as_app_written_not_as_missing()
+ {
+ // Journal[0] is "Einsatz begonnen": found at index 0, and refused because the app wrote it.
+ var incident = NewIncident(out var clock, out var op);
+
+ Assert.Throws(
+ () => incident.SetJournalEntryNotes(clock, op, incident.Journal[0].Id, "Notiz"));
+ }
+
+ [Fact]
+ public void Setting_notes_throws_on_a_Measurement_entry()
+ {
+ var incident = NewIncident(out var clock, out var op);
+ incident.AddCoBuilding(clock, op, "Haus A", 2, 3);
+ incident.RecordCoValue(clock, op, incident.Buildings[0].Id, 0, 1, 45);
+ var measurement = incident.Journal[^1];
+ Assert.Equal(EtbDirection.Measurement, measurement.Direction);
+
+ Assert.Throws(
+ () => incident.SetJournalEntryNotes(clock, op, measurement.Id, "Notiz"));
+ }
+
+ [Fact]
+ public void Setting_notes_throws_when_entry_not_found()
+ {
+ var incident = NewIncident(out var clock, out var op);
+
+ var id = Guid.NewGuid();
+
+ var ex = Assert.Throws(
+ () => incident.SetJournalEntryNotes(clock, op, id, "Notiz"));
+ Assert.Equal($"ETB-Eintrag {id} nicht gefunden.", ex.Message);
+ }
+
+ [Fact]
+ public void Setting_notes_throws_when_incident_closed()
+ {
+ var incident = NewIncident(out var clock, out var op);
+ var entry = incident.AddJournalEntry(clock, op, EtbDirection.Incoming, "Lagemeldung");
+ incident.Close(clock, op);
+
+ Assert.Throws(
+ () => incident.SetJournalEntryNotes(clock, op, entry.Id, "Notiz"));
+ }
+
[Fact]
public void Resume_editing_logs_etb_entry()
{
diff --git a/tests/LageBuch.Persistence.Tests/IncidentRoundTripTests.cs b/tests/LageBuch.Persistence.Tests/IncidentRoundTripTests.cs
index 2d8ee7d9f..18dc81fe8 100644
--- a/tests/LageBuch.Persistence.Tests/IncidentRoundTripTests.cs
+++ b/tests/LageBuch.Persistence.Tests/IncidentRoundTripTests.cs
@@ -224,6 +224,23 @@ public void An_edited_status_and_bemerkung_survive_a_round_trip()
Assert.Equal(4, reloaded.ScbaCount);
}
+ [Fact]
+ public void An_etb_entrys_notes_survive_a_round_trip()
+ {
+ var clock = new Clock();
+ var op = new SessionOperator("Müller", "FFB 12/1");
+ var incident = Incident.Start(clock, op, "Brand");
+ var noted = incident.AddJournalEntry(clock, op, EtbDirection.Incoming, "Lagemeldung", from: "ILS");
+ var plain = incident.AddJournalEntry(clock, op, EtbDirection.Internal, "Lage erkundet");
+ incident.SetJournalEntryNotes(clock, op, noted.Id, "Rückruf über Festnetz zugesagt.\nZweite Zeile.");
+
+ IncidentRepository.Save(_path, incident);
+ var loaded = IncidentRepository.Load(_path);
+
+ Assert.Equal("Rückruf über Festnetz zugesagt.\nZweite Zeile.", loaded.Journal.Single(e => e.Id == noted.Id).Notes);
+ Assert.Null(loaded.Journal.Single(e => e.Id == plain.Id).Notes);
+ }
+
[Fact]
public void An_edited_etb_entry_and_its_history_survive_a_round_trip()
{
diff --git a/tests/LageBuch.Persistence.Tests/MigrationsTests.cs b/tests/LageBuch.Persistence.Tests/MigrationsTests.cs
index 8830b6939..180b11d16 100644
--- a/tests/LageBuch.Persistence.Tests/MigrationsTests.cs
+++ b/tests/LageBuch.Persistence.Tests/MigrationsTests.cs
@@ -619,4 +619,35 @@ INSERT INTO co_gases (id, ordinal, name, unit, direction, elevated, dangerous, l
Assert.True(r.IsDBNull(0));
Assert.Equal(("19", "25"), (r.GetString(1), r.GetString(2)));
}
+
+ [Fact]
+ public void V45_database_upgrades_to_v46_and_its_etb_entries_have_no_notes()
+ {
+ // A V45 file: today's schema minus etb_entries.notes, with one entry.
+ using (var cn = SqliteConnectionFactory.OpenReadWrite(_path))
+ {
+ Migrations.Migrate(cn);
+ using var cmd = cn.CreateCommand();
+ cmd.CommandText = """
+ ALTER TABLE etb_entries DROP COLUMN notes;
+ INSERT INTO etb_entries (id, ordinal, timestamp, direction, text, entered_by)
+ VALUES ('e', 0, '2026-06-22T09:00:00.0000000+02:00', 2, 'Lagemeldung', 'Müller');
+ DELETE FROM schema_version; INSERT INTO schema_version (version) VALUES (45);
+ """;
+ cmd.ExecuteNonQuery();
+ }
+
+ SqliteConnection.ClearAllPools();
+
+ using var cn2 = SqliteConnectionFactory.OpenReadWrite(_path);
+ Migrations.Migrate(cn2);
+ Assert.Equal(Migrations.CurrentVersion, Migrations.GetVersion(cn2));
+
+ using var check = cn2.CreateCommand();
+ check.CommandText = "SELECT notes, text FROM etb_entries WHERE id = 'e';";
+ using var r = check.ExecuteReader();
+ Assert.True(r.Read());
+ Assert.True(r.IsDBNull(0));
+ Assert.Equal("Lagemeldung", r.GetString(1));
+ }
}
diff --git a/tests/LageBuch.Sync.Tests/CommandApplierTests.cs b/tests/LageBuch.Sync.Tests/CommandApplierTests.cs
index 901a6357b..9ac4408a3 100644
--- a/tests/LageBuch.Sync.Tests/CommandApplierTests.cs
+++ b/tests/LageBuch.Sync.Tests/CommandApplierTests.cs
@@ -370,6 +370,61 @@ public void ChangeOperatorCommand_logs_the_handover_credited_to_the_new_operator
Assert.Contains(incident.Audit, a => a.Action == "operator-changed");
}
+ [Fact]
+ public void SetJournalEntryNotesCommand_sets_the_notes_of_the_entry()
+ {
+ var clock = new FixedClock();
+ var incident = NewIncident(clock);
+ ApplyOverWire(
+ new AddJournalEntryCommand(new OperatorDto("Client", "RUF 1"), EtbDirection.Incoming, "Lagemeldung", null, null),
+ incident,
+ clock);
+ var entry = incident.Journal.Last();
+
+ ApplyOverWire(
+ new SetJournalEntryNotesCommand(new OperatorDto("Editor", "RUF 2"), entry.Id, "Rückruf zugesagt"),
+ incident,
+ clock);
+
+ Assert.Equal("Rückruf zugesagt", incident.Journal.Single(e => e.Id == entry.Id).Notes);
+ Assert.Equal("Editor (RUF 2)", incident.Journal[^1].EnteredBy);
+ }
+
+ [Fact]
+ public void SetJournalEntryNotesCommand_on_a_System_entry_throws()
+ {
+ var clock = new FixedClock();
+ var incident = NewIncident(clock);
+ var systemEntry = incident.Journal.Single(e => e.Direction == EtbDirection.System);
+
+ Assert.Throws(() =>
+ ApplyOverWire(
+ new SetJournalEntryNotesCommand(new OperatorDto("Client", null), systemEntry.Id, "Manipuliert"),
+ incident,
+ clock));
+ }
+
+ [Fact]
+ public void SetJournalEntryNotesCommand_with_oversized_notes_throws_and_changes_nothing()
+ {
+ var clock = new FixedClock();
+ var incident = NewIncident(clock);
+ ApplyOverWire(
+ new AddJournalEntryCommand(new OperatorDto("Client", null), EtbDirection.Incoming, "Lagemeldung", null, null),
+ incident,
+ clock);
+ var entry = incident.Journal.Last();
+ var count = incident.Journal.Count;
+
+ Assert.Throws(() =>
+ ApplyOverWire(
+ new SetJournalEntryNotesCommand(new OperatorDto("Client", null), entry.Id, new string('x', EtbEntry.MaxTextLength + 1)),
+ incident,
+ clock));
+ Assert.Null(incident.Journal.Single(e => e.Id == entry.Id).Notes);
+ Assert.Equal(count, incident.Journal.Count);
+ }
+
[Fact]
public void EditJournalEntryCommand_on_a_System_entry_throws()
{
diff --git a/tests/LageBuch.Sync.Tests/CommandSerializationTests.cs b/tests/LageBuch.Sync.Tests/CommandSerializationTests.cs
index 425e32dba..0e9c1aefd 100644
--- a/tests/LageBuch.Sync.Tests/CommandSerializationTests.cs
+++ b/tests/LageBuch.Sync.Tests/CommandSerializationTests.cs
@@ -14,6 +14,8 @@ public class CommandSerializationTests
{
new AddJournalEntryCommand(Op, EtbDirection.Outgoing, "Text", "Von", "An"),
new EditJournalEntryCommand(Op, Guid.NewGuid(), "Korrigierter Text"),
+ new SetJournalEntryNotesCommand(Op, Guid.NewGuid(), "Rückruf zugesagt"),
+ new SetJournalEntryNotesCommand(Op, Guid.NewGuid(), null),
new ChangeOperatorCommand(Op, new OperatorDto("Schmidt", null)),
new ToggleChecklistItemCommand(Op, Guid.NewGuid()),
new AssignRoleCommand(Op, "EL", "Huber", "FFB 1", DateTimeOffset.UnixEpoch, null, "Abschnitt", "0171"),
diff --git a/tests/LageBuch.Sync.Tests/SnapshotRoundTripTests.cs b/tests/LageBuch.Sync.Tests/SnapshotRoundTripTests.cs
index 82d6daf35..40c4a4b81 100644
--- a/tests/LageBuch.Sync.Tests/SnapshotRoundTripTests.cs
+++ b/tests/LageBuch.Sync.Tests/SnapshotRoundTripTests.cs
@@ -31,6 +31,7 @@ private static Incident BuildRichIncident()
clock.Now = clock.Now.AddMinutes(1);
var journalEntry = incident.AddJournalEntry(clock, op, EtbDirection.Incoming, "Erstmeldung", from: "Leitstelle", to: "ELW");
incident.EditJournalEntry(clock, op, journalEntry.Id, "Erstmeldung korrigiert");
+ incident.SetJournalEntryNotes(clock, op, journalEntry.Id, "Rückruf über Festnetz zugesagt");
incident.ToggleChecklistItem(clock, op, incident.Checklists[0].Items[0].Id);
incident.AssignRole(clock, op, "EL", "Huber", callSign: "FFB 1", from: clock.Now, section: "Abschnitt 1", phone: "0171/1234567");
@@ -129,6 +130,7 @@ public void Round_trip_preserves_key_fields_and_collection_contents()
var editedEntry = r.Journal.Single(e => e.Text == "Erstmeldung korrigiert");
var history = Assert.Single(editedEntry.Edits);
Assert.Equal("Erstmeldung", history.PreviousText);
+ Assert.Equal("Rückruf über Festnetz zugesagt", editedEntry.Notes);
Assert.Equal(9, r.Forces[0].PersonnelCount);
Assert.Equal("Im Einsatz", r.Forces[0].Status);
diff --git a/tests/LageBuch.Sync.Tests/VersionHandshakeTests.cs b/tests/LageBuch.Sync.Tests/VersionHandshakeTests.cs
index a2fdc98f1..8ba71745c 100644
--- a/tests/LageBuch.Sync.Tests/VersionHandshakeTests.cs
+++ b/tests/LageBuch.Sync.Tests/VersionHandshakeTests.cs
@@ -385,7 +385,7 @@ public void The_alarm_place_names_raise_the_protocol_but_not_the_floor()
// 41 adds dispatchPlaceNames to /masterdata. A peer at 40 drops the key and only loses the
// pre-ticked Einsatzmittel of an alarm, so a 40 and a 41 still connect.
Assert.InRange(SyncProtocol.ProtocolVersion, 41, int.MaxValue);
- Assert.InRange(SyncProtocol.MinimumProtocolVersion, int.MinValue, 40);
+ Assert.InRange(SyncProtocol.MinimumProtocolVersion, int.MinValue, SyncProtocol.ProtocolVersion);
}
[Fact]
@@ -394,7 +394,7 @@ public void The_upper_alarm_of_a_falling_gas_raises_the_protocol_but_not_the_flo
// 42 adds an optional upperAlarm to every gas definition (#927). A peer at 41 drops it and
// only loses the enrichment colour of its O2, so a 41 and a 42 still connect.
Assert.InRange(SyncProtocol.ProtocolVersion, 42, int.MaxValue);
- Assert.InRange(SyncProtocol.MinimumProtocolVersion, int.MinValue, 40);
+ Assert.InRange(SyncProtocol.MinimumProtocolVersion, int.MinValue, SyncProtocol.ProtocolVersion);
}
[Fact]
@@ -402,7 +402,16 @@ public void The_fahrzeugkennungen_raise_the_protocol_but_not_the_floor()
{
// 43 adds vehicleTypeCodes to /masterdata. A peer at 42 drops the key and only types its
// new vehicles by hand, so a 42 and a 43 still connect.
- Assert.Equal(43, SyncProtocol.ProtocolVersion);
- Assert.Equal(40, SyncProtocol.MinimumProtocolVersion);
+ Assert.InRange(SyncProtocol.ProtocolVersion, 43, int.MaxValue);
+ Assert.InRange(SyncProtocol.MinimumProtocolVersion, int.MinValue, SyncProtocol.ProtocolVersion);
+ }
+
+ [Fact]
+ public void The_notes_of_an_etb_entry_raise_the_protocol_and_the_floor()
+ {
+ // 44 lets a client send setJournalEntryNotes (#973), a command a host at 43 cannot read, so
+ // the floor rises with it.
+ Assert.Equal(44, SyncProtocol.ProtocolVersion);
+ Assert.Equal(44, SyncProtocol.MinimumProtocolVersion);
}
}