diff --git a/changelog.d/+lagemeldung.added.md b/changelog.d/+lagemeldung.added.md index 9ddb7f41..1796d15f 100644 --- a/changelog.d/+lagemeldung.added.md +++ b/changelog.d/+lagemeldung.added.md @@ -1 +1 @@ -The ETB gains a LAGEMELDUNG tab (Strg+L, or from the Rückmeldung row) that drafts the periodic situation report to the ILS with Meldender, Einsatzstelle and Eingesetzte Einheiten prefilled, composes it into one Funkspruch, and on sending writes it to the ETB marked "LM n", restarts the Rückmeldung timer and lists it in the PDF Bericht, with a Buchstabier-Helfer (traditional, DIN 5009:2022 and NATO) beside it and in the journal (#592). +The ETB gains a LAGEMELDUNG tab (Strg+L, or from the Rückmeldung row) that drafts the periodic situation report to the ILS with Meldender and Einsatzstelle prefilled, composes it into one Funkspruch, and on sending writes it to the ETB marked "LM n", restarts the Rückmeldung timer and lists it in the PDF Bericht, with a Buchstabier-Helfer (traditional, DIN 5009:2022 and NATO) beside it and in the journal (#592). diff --git a/src/LageBuch.App.Shared/Views/SituationReportsView.axaml b/src/LageBuch.App.Shared/Views/SituationReportsView.axaml index aeb14db5..d90bb047 100644 --- a/src/LageBuch.App.Shared/Views/SituationReportsView.axaml +++ b/src/LageBuch.App.Shared/Views/SituationReportsView.axaml @@ -188,19 +188,9 @@ - - - - + diff --git a/src/LageBuch.AppLogic/ViewModels/SituationReportsViewModel.cs b/src/LageBuch.AppLogic/ViewModels/SituationReportsViewModel.cs index 4ac9ccbd..595cd034 100644 --- a/src/LageBuch.AppLogic/ViewModels/SituationReportsViewModel.cs +++ b/src/LageBuch.AppLogic/ViewModels/SituationReportsViewModel.cs @@ -219,7 +219,8 @@ partial void OnSelectedReportChanged(SituationReportRow? oldValue, SituationRepo /// /// Starts a new draft, prefilled from the incident: Meldender from the Lagebuchführer's - /// Funkrufname, Einsatzstelle from the street, Eingesetzte Einheiten from the Kräfte. + /// Funkrufname, Einsatzstelle from the street. Eingesetzte Einheiten stays free text — what is + /// reported there ("2 Trupps unter PA") is not a list of the Kräfte. /// [RelayCommand(CanExecute = nameof(CanAdd))] private void NewReport() @@ -232,7 +233,7 @@ private void NewReport() Formatting.StreetAddress(incident), null, null, - DescribeUnits(incident.Forces), + null, null)); } @@ -256,16 +257,6 @@ public void OpenNewestDraft() NewReport(); } - private bool CanRefreshUnits => IsEditable; - - /// Fills Eingesetzte Einheiten again from the Kräfte as they stand now. - [RelayCommand(CanExecute = nameof(CanRefreshUnits))] - private void RefreshUnits() - { - Units = DescribeUnits(_session.Incident.Forces); - CommitSelected(); - } - [RelayCommand] private void OpenHelper() => IsHelperOpen = true; @@ -327,31 +318,6 @@ private void DeleteDraft() () => Write(() => _session.RemoveSituationReport(row.Id))); } - /// - /// The Kräfte as Eingesetzte Einheiten: each unit's name and Stärke, as the ETB names them. - /// Null when there are none, so the field stays empty rather than saying so. - /// - public static string? DescribeUnits(IEnumerable forces) - { - ArgumentNullException.ThrowIfNull(forces); - var text = string.Join(", ", forces.Select(u => $"{u.Label} {u.StrengthText}")); - if (text.Length == 0) - { - return null; - } - - // A large Einsatz can name more units than the field holds; cut at the last whole unit. - if (text.Length > SituationReport.MaxFieldLength) - { - var cut = text.LastIndexOf(", ", SituationReport.MaxFieldLength - 2, StringComparison.Ordinal); - - // Stryker disable once Equality : a unit's label is never empty, so the text never starts with ", " and cut is never 0. - text = (cut > 0 ? text[..cut] : text[..(SituationReport.MaxFieldLength - 2)]) + " …"; - } - - return text; - } - private bool CommitSelected() => SelectedReport is not { } row || Commit(row.Id); // Writes the editor to the draft with this id, if it changed. False when a field is over its @@ -481,7 +447,6 @@ private void Load(SituationReport? report) OnPropertyChanged(nameof(EditorHeader)); SendCommand.NotifyCanExecuteChanged(); DeleteDraftCommand.NotifyCanExecuteChanged(); - RefreshUnitsCommand.NotifyCanExecuteChanged(); } private static string? Moved(string? before, string? now, string? editing) => diff --git a/tests/LageBuch.Acceptance.Tests/SituationReportsTabRenderTests.cs b/tests/LageBuch.Acceptance.Tests/SituationReportsTabRenderTests.cs index 2220cffa..dedc10d8 100644 --- a/tests/LageBuch.Acceptance.Tests/SituationReportsTabRenderTests.cs +++ b/tests/LageBuch.Acceptance.Tests/SituationReportsTabRenderTests.cs @@ -46,7 +46,7 @@ private static (Window Window, IncidentWorkspaceViewModel Vm, LocalIncidentSessi "Blumenstraße 13", "Feuer unter Kontrolle", "Nachlöscharbeiten, Wärmebildkamera", - "FF Musterstadt (HLF 1) 0/1/8/9, FF Beispieldorf (LF 2) 0/1/5/6", + "2 Trupps unter PA, Wasserversorgung durch LF 2", "1 RTW zur Bereitstellung"); var vm = new IncidentWorkspaceViewModel( session, diff --git a/tests/LageBuch.AppLogic.Tests/SituationReportsViewModelTests.cs b/tests/LageBuch.AppLogic.Tests/SituationReportsViewModelTests.cs index 8b3359e8..d73d7d25 100644 --- a/tests/LageBuch.AppLogic.Tests/SituationReportsViewModelTests.cs +++ b/tests/LageBuch.AppLogic.Tests/SituationReportsViewModelTests.cs @@ -27,7 +27,7 @@ private static SituationReportsViewModel NewVm( new(session, () => { }, "ILS", requestConfirm); [Fact] - public void A_new_report_is_prefilled_from_the_funkrufname_the_street_and_the_kraefte() + public void A_new_report_is_prefilled_from_the_funkrufname_and_the_street_but_leaves_the_units_free() { var (session, _) = NewSession(); session.SetAddress("Blumenstraße", "Nord", "13", "12345", "Musterstadt"); @@ -41,7 +41,7 @@ public void A_new_report_is_prefilled_from_the_funkrufname_the_street_and_the_kr Assert.Same(vm.Reports[0], vm.SelectedReport); Assert.Equal("Florian Musterstadt 11/1", vm.Reporter); Assert.Equal("Blumenstraße 13", vm.Location); - Assert.Equal("FF Musterstadt (HLF 1) 0/1/8/9, FF Beispieldorf 0/1/5/6", vm.Units); + Assert.Null(vm.Units); Assert.Null(vm.Situation); Assert.True(vm.IsEditable); } @@ -308,21 +308,6 @@ public void An_empty_draft_cannot_be_sent() Assert.False(vm.SendCommand.CanExecute(null)); } - [Fact] - public void RefreshUnits_takes_over_the_kraefte_as_they_stand_now() - { - var (session, _) = NewSession(); - using var vm = NewVm(session); - vm.NewReportCommand.Execute(null); - Assert.Null(vm.Units); - session.AddForceUnit("FF Musterstadt", 9, callSign: "HLF 1", officerCount: 1); - - vm.RefreshUnitsCommand.Execute(null); - - Assert.Equal("FF Musterstadt (HLF 1) 0/1/8/9", vm.Units); - Assert.Equal("FF Musterstadt (HLF 1) 0/1/8/9", session.Incident.SituationReports[0].Units); - } - [Fact] public void Discarding_a_draft_asks_first_and_takes_it_out() { @@ -399,18 +384,6 @@ public void A_field_handed_to_the_helper_is_spelled_and_opens_it_on_a_phone() Assert.StartsWith("Berta – Ludwig", vm.Helper.Spelled, StringComparison.Ordinal); } - [Fact] - public void Units_longer_than_the_field_are_cut_at_the_last_whole_unit() - { - var forces = Enumerable.Range(1, 60).Select(i => ForceUnit.Create($"FF Musterstadt {i}", 9)).ToList(); - - var text = SituationReportsViewModel.DescribeUnits(forces); - - Assert.NotNull(text); - Assert.True(text.Length <= SituationReportsViewModel.MaxFieldLength); - Assert.EndsWith("0/0/9/9 …", text, StringComparison.Ordinal); - } - // A draft with a Lage, saved, then opened read-only the way a closed Einsatz is reopened. private static LocalIncidentSession ReadOnlySessionWithADraft() { @@ -561,10 +534,8 @@ public void A_report_sent_elsewhere_locks_the_editor_and_announces_it() vm.PropertyChanged += (_, e) => changed.Add(e.PropertyName); var send = 0; var delete = 0; - var refresh = 0; vm.SendCommand.CanExecuteChanged += (_, _) => send++; vm.DeleteDraftCommand.CanExecuteChanged += (_, _) => delete++; - vm.RefreshUnitsCommand.CanExecuteChanged += (_, _) => refresh++; session.SendSituationReport(session.Incident.SituationReports[0].Id, "ILS"); @@ -576,7 +547,6 @@ public void A_report_sent_elsewhere_locks_the_editor_and_announces_it() Assert.Contains(nameof(SituationReportsViewModel.EditorHeader), changed); Assert.True(send > 0); Assert.True(delete > 0); - Assert.True(refresh > 0); Assert.False(vm.SendCommand.CanExecute(null)); } @@ -678,50 +648,6 @@ public void The_helper_opens_and_closes_on_a_phone_and_is_always_there_when_wide Assert.True(vm.ShowHelperButton); } - [Fact] - public void No_kraefte_means_no_eingesetzte_einheiten() - { - Assert.Null(SituationReportsViewModel.DescribeUnits([])); - } - - [Fact] - public void Units_exactly_as_long_as_the_field_are_not_cut() - { - // 290 + " 0/0/9/9" + ", " + 292 + " 0/0/9/9" = 600 characters. - ForceUnit[] forces = [ForceUnit.Create(new string('A', 290), 9), ForceUnit.Create(new string('B', 292), 9)]; - - var text = SituationReportsViewModel.DescribeUnits(forces); - - Assert.Equal(SituationReportsViewModel.MaxFieldLength, text?.Length); - Assert.EndsWith("B 0/0/9/9", text, StringComparison.Ordinal); - } - - [Fact] - public void A_cut_never_leaves_the_text_longer_than_the_field() - { - // The second separator sits at 599, just past where a cut may still start. - ForceUnit[] forces = - [ - ForceUnit.Create(new string('A', 291), 9), - ForceUnit.Create(new string('B', 290), 9), - ForceUnit.Create("C", 9), - ]; - - var text = SituationReportsViewModel.DescribeUnits(forces); - - Assert.NotNull(text); - Assert.True(text.Length <= SituationReportsViewModel.MaxFieldLength, $"{text.Length} characters"); - Assert.Equal(new string('A', 291) + " 0/0/9/9 …", text); - } - - [Fact] - public void A_single_unit_longer_than_the_field_is_cut_inside_its_name() - { - var text = SituationReportsViewModel.DescribeUnits([ForceUnit.Create(new string('A', 700), 9)]); - - Assert.Equal(new string('A', SituationReportsViewModel.MaxFieldLength - 2) + " …", text); - } - [Fact] public void A_row_shows_when_it_was_sent_or_else_when_it_was_started() {