Repository navigation
feat(etb): foldable notes on user-written entries #990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,21 @@ | |
| <Style Selector="TextBox#EditTextBox"> | ||
| <Setter Property="Width" Value="420" /> | ||
| </Style> | ||
| <Style Selector="TextBox#EditNotesBox"> | ||
| <Setter Property="Width" Value="360" /> | ||
| </Style> | ||
| <!-- An entry's notes (#973), folded under its line: quieter than the entry, set off by a rule. --> | ||
| <Style Selector="Border.etb-notes"> | ||
| <Setter Property="BorderBrush" Value="{StaticResource BorderStrongBrush}" /> | ||
| <Setter Property="BorderThickness" Value="2,0,0,0" /> | ||
| <Setter Property="Padding" Value="8,2,0,2" /> | ||
| <Setter Property="Margin" Value="0,4,0,0" /> | ||
| </Style> | ||
| <Style Selector="Border.etb-notes > TextBlock"> | ||
| <Setter Property="FontSize" Value="12.5" /> | ||
| <Setter Property="TextWrapping" Value="Wrap" /> | ||
| <Setter Property="Foreground" Value="{StaticResource TextSecondaryBrush}" /> | ||
| </Style> | ||
|
|
||
| <Style Selector="Panel#WorkspaceRoot.narrow StackPanel#DockFields"> | ||
| <Setter Property="Orientation" Value="Vertical" /> | ||
|
|
@@ -78,6 +93,9 @@ | |
| <Style Selector="Panel#WorkspaceRoot.narrow TextBox#EtbTextBox"> | ||
| <Setter Property="Width" Value="NaN" /> | ||
| </Style> | ||
| <Style Selector="Panel#WorkspaceRoot.narrow TextBox#EditNotesBox"> | ||
| <Setter Property="Width" Value="NaN" /> | ||
| </Style> | ||
| <Style Selector="Panel#WorkspaceRoot.narrow TextBox#EditTextBox"> | ||
| <Setter Property="Width" Value="NaN" /> | ||
| </Style> | ||
|
|
@@ -212,6 +230,14 @@ | |
| <TextBox x:Name="EditTextBox" Text="{Binding EditText}" b:SnippetCompletion.Snippets="{Binding TextSnippets}" | ||
| b:EnterSubmit.Command="{Binding SaveEditCommand}" /> | ||
| </HeaderedContentControl> | ||
| <!-- Background and follow-up to the entry (#973), folded under its line. Multi-line: | ||
| Enter breaks the line here and SPEICHERN saves, because Overlay leaves Enter to an | ||
| AcceptsReturn field. --> | ||
| <HeaderedContentControl Classes="field" Header="NOTIZ"> | ||
| <TextBox x:Name="EditNotesBox" Text="{Binding EditNotes}" b:SnippetCompletion.Snippets="{Binding TextSnippets}" | ||
| AcceptsReturn="True" TextWrapping="Wrap" MinHeight="32" MaxHeight="120" | ||
| MaxLength="{x:Static etb:EtbEntry.MaxTextLength}" /> | ||
| </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}" | ||
|
|
@@ -267,7 +293,15 @@ | |
| <Panel KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.TabIndex="1"> | ||
| <Border x:Name="EtbGridPanel" Background="#0C1119" BorderBrush="{StaticResource HairlineBrush}" BorderThickness="1" | ||
| CornerRadius="{StaticResource RadiusMd}" ClipToBounds="True"> | ||
| <DataGrid x:Name="EtbGrid" b:GridCopy.IsEnabled="True" b:RowKeys.IsEnabled="True" b:SelectedRowTab.IsEnabled="True" ItemsSource="{Binding Entries}" IsReadOnly="True" CanUserSortColumns="False"> | ||
| <!-- Rows size to their content (#973): an entry's unfolded notes sit under its line, which | ||
| the shared 40px RowHeight from Styles.axaml would clip. A folded row keeps 40px. --> | ||
| <DataGrid x:Name="EtbGrid" b:GridCopy.IsEnabled="True" b:RowKeys.IsEnabled="True" b:SelectedRowTab.IsEnabled="True" ItemsSource="{Binding Entries}" IsReadOnly="True" CanUserSortColumns="False" | ||
| RowHeight="NaN"> | ||
| <DataGrid.Styles> | ||
| <Style Selector="DataGridCell"> | ||
| <Setter Property="MinHeight" Value="40" /> | ||
| </Style> | ||
| </DataGrid.Styles> | ||
| <DataGrid.Columns> | ||
| <DataGridTextColumn Header="ZEIT" Binding="{Binding Time}" /> | ||
| <DataGridTextColumn Header="VON" Binding="{Binding From}" /> | ||
|
|
@@ -283,11 +317,27 @@ | |
| IsVisible="{Binding HasTasks}" IsTabStop="False" | ||
| Content="{Binding TaskBadge}" Command="{Binding ShowTasksCommand}" | ||
| ToolTip.Tip="Die Aufgaben zu diesem Eintrag zeigen" /> | ||
| <StackPanel Orientation="Horizontal" Spacing="8" VerticalAlignment="Center"> | ||
| <Border Classes="lm-badge" IsVisible="{Binding SituationReportLabel, Converter={x:Static ObjectConverters.IsNotNull}}"> | ||
| <TextBlock Text="{Binding SituationReportLabel}" /> | ||
| <StackPanel VerticalAlignment="Center"> | ||
| <StackPanel Orientation="Horizontal" Spacing="8"> | ||
| <Border Classes="lm-badge" IsVisible="{Binding SituationReportLabel, Converter={x:Static ObjectConverters.IsNotNull}}"> | ||
| <TextBlock Text="{Binding SituationReportLabel}" /> | ||
| </Border> | ||
| <TextBlock Text="{Binding Text}" VerticalAlignment="Center" /> | ||
| <!-- Shows that the entry has notes and whether they are unfolded (#973). The row's own | ||
| click toggles them too; this is the target for a pointer that wants it spelled out. --> | ||
| <Button x:Name="NotesToggle" Classes="icon-btn" | ||
| IsVisible="{Binding HasNotes}" IsTabStop="False" Command="{Binding ToggleNotesCommand}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keyboard-only users cannot unfold notes from the entry row. The notes toggle is not a tab stop and has no
|
||
| ToolTip.Tip="{Binding NotesToggleLabel}" AutomationProperties.Name="{Binding NotesToggleLabel}"> | ||
| <StackPanel Orientation="Horizontal" Spacing="0"> | ||
| <PathIcon Width="14" Height="14" Data="M3 18h12v-2H3v2zM3 6v2h18V6H3zm0 7h18v-2H3v2z" /> | ||
| <PathIcon Width="12" Height="12" IsVisible="{Binding !IsNotesExpanded}" Data="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" /> | ||
| <PathIcon Width="12" Height="12" IsVisible="{Binding IsNotesExpanded}" Data="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z" /> | ||
| </StackPanel> | ||
| </Button> | ||
| </StackPanel> | ||
| <Border Classes="etb-notes" IsVisible="{Binding IsNotesExpanded}"> | ||
| <TextBlock Text="{Binding Notes}" /> | ||
| </Border> | ||
| <TextBlock Text="{Binding Text}" VerticalAlignment="Center" /> | ||
| </StackPanel> | ||
| </DockPanel> | ||
| </DataTemplate> | ||
|
|
@@ -358,6 +408,20 @@ | |
| </Border> | ||
| <TextBlock Text="{Binding Text}" TextWrapping="Wrap" | ||
| Foreground="{StaticResource TextPrimaryBrush}" /> | ||
| <!-- Shows that the entry has notes and whether they are unfolded (#973). The row's own | ||
| click toggles them too; this is the target for a pointer that wants it spelled out. --> | ||
| <Button x:Name="CardNotesToggle" HorizontalAlignment="Left" Classes="icon-btn card-action" | ||
| IsVisible="{Binding HasNotes}" IsTabStop="False" Command="{Binding ToggleNotesCommand}" | ||
| ToolTip.Tip="{Binding NotesToggleLabel}" AutomationProperties.Name="{Binding NotesToggleLabel}"> | ||
| <StackPanel Orientation="Horizontal" Spacing="0"> | ||
| <PathIcon Width="14" Height="14" Data="M3 18h12v-2H3v2zM3 6v2h18V6H3zm0 7h18v-2H3v2z" /> | ||
| <PathIcon Width="12" Height="12" IsVisible="{Binding !IsNotesExpanded}" Data="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" /> | ||
| <PathIcon Width="12" Height="12" IsVisible="{Binding IsNotesExpanded}" Data="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z" /> | ||
| </StackPanel> | ||
| </Button> | ||
| <Border Classes="etb-notes" Margin="0" IsVisible="{Binding IsNotesExpanded}"> | ||
| <TextBlock Text="{Binding Notes}" /> | ||
| </Border> | ||
| <Button Classes="badge" Classes.open="{Binding HasOpenTasks}" | ||
| IsVisible="{Binding HasTasks}" IsTabStop="False" HorizontalAlignment="Left" | ||
| Content="{Binding TaskBadge}" Command="{Binding ShowTasksCommand}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,39 @@ | ||
| using Avalonia; | ||
| using Avalonia.Controls; | ||
| using Avalonia.Input; | ||
| using Avalonia.VisualTree; | ||
| using LageBuch.AppLogic.ViewModels; | ||
|
|
||
| namespace LageBuch.App.Shared.Views; | ||
|
|
||
| public partial class EtbView : UserControl | ||
| { | ||
| // The form's first field, VON (#540), takes focus only when the user asked for the module | ||
| // (#542): see WorkspaceFocus and the dock's EntryForm.FirstField. | ||
| public EtbView() => 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<Button>(includeSelf: true) is not null | ||
| || source.DataContext is not EtbEntryRow row) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| row.ToggleNotesCommand.Execute(null); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,12 @@ private EtbEntry() | |
|
|
||
| public IReadOnlyList<EtbEntryEdit> Edits { get; private init; } = Array.Empty<EtbEntryEdit>(); | ||
|
|
||
| /// <summary> | ||
| /// Background or follow-up detail that belongs to this entry without lengthening its line | ||
| /// (#973). <see langword="null"/> when there is none; never blank. | ||
| /// </summary> | ||
| 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<EtbEntryEdit>? edits = null) | ||
| IEnumerable<EtbEntryEdit>? edits = null, | ||
| string? notes = null) | ||
| => new() | ||
| { | ||
| Id = id, | ||
|
|
@@ -78,6 +85,7 @@ public static EtbEntry Rehydrate( | |
| From = from, | ||
| To = to, | ||
| Edits = (edits ?? Enumerable.Empty<EtbEntryEdit>()).ToList(), | ||
| Notes = string.IsNullOrWhiteSpace(notes) ? null : notes, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enforce the notes cap during restoration. A stored value containing 4,001 nonblank characters passes through Apply a non-throwing sanitization policy here. Preserve valid notes and keep the incident loadable when restored notes exceed the cap. Based on learnings, “Every input that crosses the trust boundary has a cap, enforced on both ends.”
|
||
| }; | ||
|
|
||
| /// <summary> | ||
|
|
@@ -114,4 +122,21 @@ public EtbEntry WithEditedText(string newText, SessionOperator editor, DateTimeO | |
| var edits = new List<EtbEntryEdit>(Edits) { new(Text, editor.Display, editedAt) }; | ||
| return this with { Text = trimmed, Edits = edits }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Replaces this entry's notes; blank clears them. Unlike <see cref="WithEditedText"/> this | ||
| /// keeps no prior version: the notes are an annotation beside the record, not the record, and | ||
| /// <see cref="Incident.SetJournalEntryNotes"/> leaves a System line for every change. The same | ||
| /// value, ignoring surrounding whitespace, returns this instance, so a resend is no change. | ||
| /// </summary> | ||
| 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 }; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the edit form inside the panel in wide mode.
In wide mode,
EditFieldsstays horizontal. The entry field is fixed at 420 px and the notes field at 360 px. With the two buttons, spacing and the panel padding, the form needs more than 780 px. The panel does not wrap or scroll. Wide mode starts at a 641 px window width, soSPEICHERNandABBRECHENcan extend past the panel and out of the window at widths below the form's full width. Enter in the entry field still saves, but the buttons may be unreachable.Make the edit form fit or reflow at every wide-mode width. Choose the approach that keeps the narrow-mode rules unchanged.