Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/+etb-edit-von-an.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ETB edit panel now corrects an entry's Von and An as well as its Abschnitt and Eintrag, and the Verlauf and the PDF name the Von and An an edit replaced.
60 changes: 36 additions & 24 deletions src/LageBuch.App.Shared/Views/EtbView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
<Style Selector="StackPanel#EditFields">
<Setter Property="Orientation" Value="Horizontal" />
</Style>
<Style Selector="AutoCompleteBox#FromBox">
<Style Selector="AutoCompleteBox#FromBox, AutoCompleteBox#EditFromBox">
<Setter Property="Width" Value="150" />
</Style>
<Style Selector="AutoCompleteBox#ToBox">
<Style Selector="AutoCompleteBox#ToBox, AutoCompleteBox#EditToBox">
<Setter Property="Width" Value="150" />
</Style>
<Style Selector="ctrl|NodeChoicePicker#SectionEntryPicker">
Expand All @@ -89,8 +89,10 @@
<Style Selector="TextBox#EtbTextBox">
<Setter Property="Width" Value="320" />
</Style>
<!-- The dock's 320, not wider: the edit panel's row also carries VON, AN and ABSCHNITT, and
SPEICHERN and ABBRECHEN have to stay on a 1280px screen beside the nav rail. -->
<Style Selector="TextBox#EditTextBox">
<Setter Property="Width" Value="420" />
<Setter Property="Width" Value="320" />
</Style>
<!-- Wide enough for "Atemschutz Trupp 2" plus the count, and still one line on a phone. -->
<Style Selector="TextBox#EtbSearchBox">
Expand All @@ -113,10 +115,10 @@
</Style>

<!-- The dock stacks. -->
<Style Selector="Panel#WorkspaceRoot.narrow AutoCompleteBox#FromBox">
<Style Selector="Panel#WorkspaceRoot.narrow AutoCompleteBox#FromBox, Panel#WorkspaceRoot.narrow AutoCompleteBox#EditFromBox">
<Setter Property="Width" Value="NaN" />
</Style>
<Style Selector="Panel#WorkspaceRoot.narrow AutoCompleteBox#ToBox">
<Style Selector="Panel#WorkspaceRoot.narrow AutoCompleteBox#ToBox, Panel#WorkspaceRoot.narrow AutoCompleteBox#EditToBox">
<Setter Property="Width" Value="NaN" />
</Style>
<Style Selector="Panel#WorkspaceRoot.narrow ctrl|NodeChoicePicker#SectionEntryPicker">
Expand Down Expand Up @@ -257,13 +259,15 @@
a person's name) must stay enterable, so this is an AutoCompleteBox rather than a
ComboBox, mirroring ForcesView's Brigade field. -->
<HeaderedContentControl Classes="field suggest" Header="VON">
<AutoCompleteBox x:Name="FromBox" PlaceholderText="{x:Static md:AnonymizedExampleData.CallSignPlaceholder}"
<AutoCompleteBox x:Name="FromBox" MaxLength="{x:Static etb:EtbEntry.MaxPartyLength}"
PlaceholderText="{x:Static md:AnonymizedExampleData.CallSignPlaceholder}"
ItemsSource="{Binding CallSignOptions}"
FilterMode="ContainsOrdinal" MinimumPrefixLength="0"
Text="{Binding NewFrom}" />
</HeaderedContentControl>
<HeaderedContentControl Classes="field suggest" Header="AN">
<AutoCompleteBox x:Name="ToBox" PlaceholderText="{x:Static md:AnonymizedExampleData.SecondCallSignPlaceholder}"
<AutoCompleteBox x:Name="ToBox" MaxLength="{x:Static etb:EtbEntry.MaxPartyLength}"
PlaceholderText="{x:Static md:AnonymizedExampleData.SecondCallSignPlaceholder}"
ItemsSource="{Binding CallSignOptions}"
FilterMode="ContainsOrdinal" MinimumPrefixLength="0"
Text="{Binding NewTo}" />
Expand Down Expand Up @@ -313,6 +317,28 @@
b:Overlay.InitialFocus="{Binding #EditTextBox}" b:Overlay.FallbackFocus="{Binding #EtbTextBox}">
<StackPanel Spacing="6">
<StackPanel x:Name="EditFields" Spacing="8">
<!-- VON and AN correct a misheard Funkrufname; the same suggestion boxes as the dock's,
in the dock's order. Written with SPEICHERN, empty clears the field. -->
<HeaderedContentControl Classes="field suggest" Header="VON">
<AutoCompleteBox x:Name="EditFromBox" MaxLength="{x:Static etb:EtbEntry.MaxPartyLength}"
PlaceholderText="{x:Static md:AnonymizedExampleData.CallSignPlaceholder}"
ItemsSource="{Binding CallSignOptions}"
FilterMode="ContainsOrdinal" MinimumPrefixLength="0"
Text="{Binding EditFrom}" />
</HeaderedContentControl>
<HeaderedContentControl Classes="field suggest" Header="AN">
<AutoCompleteBox x:Name="EditToBox" MaxLength="{x:Static etb:EtbEntry.MaxPartyLength}"
PlaceholderText="{x:Static md:AnonymizedExampleData.SecondCallSignPlaceholder}"
ItemsSource="{Binding CallSignOptions}"
FilterMode="ContainsOrdinal" MinimumPrefixLength="0"
Text="{Binding EditTo}" />
</HeaderedContentControl>
<!-- Set, change or remove the entry's Einsatzabschnitt (#971); written with SPEICHERN. -->
<HeaderedContentControl Classes="field" Header="ABSCHNITT" IsVisible="{Binding HasEditSectionChoices}">
<ctrl:NodeChoicePicker x:Name="EditSectionPicker" Width="150"
Choices="{Binding EditSectionChoices}" Label="{Binding EditSectionLabel}"
PickerName="Abschnitt des Eintrags wählen" />
</HeaderedContentControl>
<HeaderedContentControl Classes="field required" Header="EINTRAG"
Classes.invalid="{Binding EditTextError, Converter={x:Static ObjectConverters.IsNotNull}}">
<!-- Freitext: kein Platzhalter, siehe #137 -->
Expand All @@ -321,12 +347,6 @@
<TextBox x:Name="EditTextBox" Text="{Binding EditText}" b:SnippetCompletion.Snippets="{Binding TextSnippets}"
b:EnterSubmit.Command="{Binding SaveEditCommand}" />
</HeaderedContentControl>
<!-- Set, change or remove the entry's Einsatzabschnitt (#971); written with SPEICHERN. -->
<HeaderedContentControl Classes="field" Header="ABSCHNITT" IsVisible="{Binding HasEditSectionChoices}">
<ctrl:NodeChoicePicker x:Name="EditSectionPicker" Width="200"
Choices="{Binding EditSectionChoices}" Label="{Binding EditSectionLabel}"
PickerName="Abschnitt des Eintrags wählen" />
</HeaderedContentControl>
<Button x:Name="SaveEditButton" Classes="signal dock-action" Content="SPEICHERN" Command="{Binding SaveEditCommand}"
VerticalAlignment="Bottom" Margin="0,0,0,1" />
<Button x:Name="CancelEditButton" Classes="dock-action" Content="ABBRECHEN" Command="{Binding CancelEditCommand}"
Expand Down Expand Up @@ -354,24 +374,16 @@
<TextBlock Grid.Column="0" Text="Verlauf" Classes="overline" VerticalAlignment="Center" />
<Button Grid.Column="1" Content="SCHLIESSEN" Command="{Binding CloseHistoryCommand}" />
</Grid>
<ItemsControl x:Name="HistoryList" ItemsSource="{Binding HistoryEntry.Edits}">
<ItemsControl x:Name="HistoryList" ItemsSource="{Binding HistoryEntry.HistoryLines}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="etb:EtbEntryEdit">
<DataTemplate x:DataType="x:String">
<!-- No Foreground here (#438): "mono" already paints TextSecondary, and the inline
override these rows used to carry pushed them down to TextMuted — a
semi-transparent token (#65728580, ~40% alpha) meant for disabled text, which
over the panel's #0F141D lands at roughly 1,9:1 against WCAG AA's 4,5:1. These
rows are the audit trail this panel exists for: the previous wording, who
rewrote it and when. Same fix as the Übergabe heading in #436. -->
<TextBlock Classes="mono" Margin="0,2" TextWrapping="Wrap">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}: „{1}“ ({2})">
<Binding Path="EditedAt" />
<Binding Path="PreviousText" />
<Binding Path="EditedBy" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Classes="mono" Margin="0,2" TextWrapping="Wrap" Text="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Expand Down
4 changes: 2 additions & 2 deletions src/LageBuch.AppLogic/LocalIncidentSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public Guid AddJournalEntry(EtbDirection direction, string text, string? from =
return id;
}

public void EditJournalEntry(Guid entryId, string text) =>
Mutate(() => Incident.EditJournalEntry(_clock, RequireOperator(), entryId, text));
public void EditJournalEntry(Guid entryId, string text, string? from, string? to) =>
Mutate(() => Incident.EditJournalEntry(_clock, RequireOperator(), entryId, text, from, to));

public void AssignJournalEntrySection(Guid entryId, Guid? sectionId) =>
Mutate(() => Incident.AssignJournalEntrySection(_clock, RequireOperator(), entryId, sectionId));
Expand Down
53 changes: 45 additions & 8 deletions src/LageBuch.AppLogic/ViewModels/EtbViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,14 @@ private void ShowAddErrors(bool shown)
[NotifyPropertyChangedFor(nameof(EditErrorSummary))]
private string _editText = string.Empty;

/// <summary>The edit panel's VON, written with SPEICHERN; blank clears it.</summary>
[ObservableProperty]
private string? _editFrom;

/// <summary>The edit panel's AN, written with SPEICHERN; blank clears it.</summary>
[ObservableProperty]
private string? _editTo;

public bool IsEditing => EditingEntry is not null;

private bool CanEdit(EtbEntryRow row) => !IsReadOnly && row.IsEditable;
Expand Down Expand Up @@ -670,6 +678,8 @@ private void BeginEdit(EtbEntryRow row)
{
EditingEntry = row;
EditText = row.Text;
EditFrom = row.From;
EditTo = row.To;
_editSectionId = row.SectionId;
EditSectionChoices = BuildEditSectionChoices();
ShowEditErrors(false); // a freshly opened panel starts quiet
Expand Down Expand Up @@ -700,23 +710,32 @@ private void SaveEdit()
var entry = EditingEntry!;
var section = _editSectionId;
var refiled = section != entry.SectionId;
_session.EditJournalEntry(entry.Id, EditText); // Changed → Sync() renders it
_session.EditJournalEntry(entry.Id, EditText, Touched(EditFrom, entry.From), Touched(EditTo, entry.To)); // Changed → Sync() renders it
if (refiled)
{
_session.AssignJournalEntrySection(entry.Id, section);
}

EditingEntry = null;
EditText = string.Empty;
ShowEditErrors(false);
ClearEditFields();
_onChanged();
}

// Null for a field left as the panel opened it, so the host keeps whatever Von or An it holds by
// now; blank for one the Lagebuchführer emptied, which clears it.
private static string? Touched(string? edited, string? opened) =>
string.Equals(edited?.Trim() ?? string.Empty, opened ?? string.Empty, StringComparison.Ordinal)
? null
: edited ?? string.Empty;

[RelayCommand]
private void CancelEdit()
private void CancelEdit() => ClearEditFields();

private void ClearEditFields()
{
EditingEntry = null;
EditText = string.Empty;
EditFrom = null;
EditTo = null;
ShowEditErrors(false);
}

Expand Down Expand Up @@ -798,6 +817,7 @@ public EtbEntryRow(
IsMeasurement = EtbDirections.IsMeasurement(entry.Direction, entry.Text);
WasEdited = entry.Edits.Count > 0;
Edits = entry.Edits;
HistoryLines = HistoryOf(entry);
_sectionId = entry.SectionId;
_sectionName = entry.SectionName;
IsEditable = !EtbDirections.IsAppWritten(entry.Direction);
Expand All @@ -820,9 +840,9 @@ public EtbEntryRow(

public string Time { get; }

public string? From { get; }
public string? From { get; private set; }

public string? To { get; }
public string? To { get; private set; }

public string Text { get; private set; }

Expand All @@ -842,6 +862,12 @@ public EtbEntryRow(

public IReadOnlyList<EtbEntryEdit> Edits { get; private set; }

/// <summary>
/// The Verlauf, one line per earlier version: when it was replaced, what it read (with Von and
/// An where that edit changed them) and who replaced it.
/// </summary>
public IReadOnlyList<string> HistoryLines { get; private set; }

public bool IsEditable { get; }

/// <summary>The Einsatzabschnitt the entry is filed under (#971), or null; what the quick filter matches.</summary>
Expand Down Expand Up @@ -918,7 +944,7 @@ public int? SituationReportNumber
/// <summary>
/// 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 (<see cref="EtbEntry.WithEditedText"/>), and a re-filing the
/// the text, Von, An and history (<see cref="EtbEntry.WithEdit"/>), and a re-filing the
/// Abschnitt (<see cref="EtbEntry.WithSection"/>), so nothing else is touched.
/// </summary>
public void Update(EtbEntry entry)
Expand All @@ -930,9 +956,15 @@ public void Update(EtbEntry entry)
}

Text = entry.Text;
From = entry.From;
To = entry.To;
Edits = entry.Edits;
HistoryLines = HistoryOf(entry);
WasEdited = entry.Edits.Count > 0;
OnPropertyChanged(nameof(Text));
OnPropertyChanged(nameof(HistoryLines));
OnPropertyChanged(nameof(From));
OnPropertyChanged(nameof(To));
OnPropertyChanged(nameof(Edits));
OnPropertyChanged(nameof(WasEdited));
if (_sectionId != entry.SectionId || !string.Equals(_sectionName, entry.SectionName, StringComparison.Ordinal))
Expand All @@ -947,6 +979,11 @@ public void Update(EtbEntry entry)
// The first edit is what makes the history viewable at all.
ShowHistoryCommand.NotifyCanExecuteChanged();
}

private static string[] HistoryOf(EtbEntry entry) =>
entry.Edits
.Select((edit, i) => $"{Formatting.Timestamp(edit.EditedAt)}: {Formatting.EtbPriorVersion(entry, i)} ({edit.EditedBy})")
.ToArray();
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions src/LageBuch.Documents/Sections/EtbSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ public static void Compose(IContainer container, Incident incident)
}

col.Item().Text(entry.Text);
foreach (var edit in entry.Edits)
for (var i = 0; i < entry.Edits.Count; i++)
{
col.Item().Text($"bearbeitet {Formatting.Timestamp(edit.EditedAt)} von {edit.EditedBy}, zuvor: „{edit.PreviousText}“")
var edit = entry.Edits[i];
col.Item().Text($"bearbeitet {Formatting.Timestamp(edit.EditedAt)} von {edit.EditedBy}, zuvor: {Formatting.EtbPriorVersion(entry, i)}")
.FontSize(8).Italic().FontColor(Colors.Grey.Medium);
}
});
Expand Down
Loading