Files
HC_APTBS/Views/Pages/ResultsPage.xaml
LucianoDev 0280a2fad1 feat: page-based navigation shell + Tests page wizard
Replace the monolithic MainWindow with a SelectedPage-driven shell
(Dashboard / Pump / Bench / Tests / Results / Settings). The Tests
page gets the Plan -> Preconditions -> Running -> Done wizard from
ui-structure.md \u00a74, backed by a 7-item precondition gate and
shared sub-views (PhaseCardView / TestSectionView / GraphicIndicatorView)
extracted from the now-deleted monolithic TestPanelView.

New VMs / views:
- Tests wizard: TestPreconditions, PhaseCard, GraphicIndicator,
  TestSection, TestPlan, TestRunning, TestDone
- Dashboard panels: DashboardConnection, DashboardReadings,
  DashboardAlarms, InterlockBanner, ResultHistory
- Pump / bench panels: PumpIdentificationPanel, PumpLiveData,
  UnlockPanel, BenchDriveControl, BenchReadings, RelayBank,
  TemperatureControl, DtcList, AuthGate
- Dialogs: generic ConfirmDialog, UserManageDialog, UserPromptDialog

Supporting changes:
- IsOilPumpOn exposed on MainViewModel for precondition evaluation
- RequiresAuth added to TestDefinition (XML round-trip)
- BipStatusDefinition + CompletedTestRun models
- ~35 new Test.* localization keys (en + es)
- Settings moved from modal dialog to full page
- Pause / Retry / Skip stubs in TestRunningView; full spec in
  docs/gap-test-running-controls.md for follow-up implementation
- docs/ui-structure.md captures the wizard design

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-18 13:11:34 +02:00

163 lines
8.7 KiB
XML

<UserControl x:Class="HC_APTBS.Views.Pages.ResultsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="clr-namespace:HC_APTBS.Views.UserControls"
mc:Ignorable="d"
d:DesignHeight="700" d:DesignWidth="1100">
<!--
Results — review completed test runs, edit observations, export PDF.
DataContext: ResultsPageViewModel. No live hardware data on this page.
-->
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<Style x:Key="DashCard" TargetType="Border">
<Setter Property="Background" Value="#FAFAFA"/>
<Setter Property="BorderBrush" Value="#DDD"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="Margin" Value="4"/>
</Style>
<Style x:Key="DashHeader" TargetType="TextBlock">
<Setter Property="FontSize" Value="13"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="#333"/>
<Setter Property="Margin" Value="0,0,0,6"/>
</Style>
</UserControl.Resources>
<Grid Margin="6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="320"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- ── Left: history list ─────────────────────────────────────────── -->
<Border Grid.Column="0" Style="{StaticResource DashCard}">
<uc:ResultHistoryView/>
</Border>
<!-- ── Right: detail pane ──────────────────────────────────────────── -->
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <!-- header -->
<RowDefinition Height="*"/> <!-- results table -->
<RowDefinition Height="Auto"/> <!-- observations -->
<RowDefinition Height="Auto"/> <!-- actions -->
</Grid.RowDefinitions>
<!-- Selected-run header -->
<Border Grid.Row="0" Style="{StaticResource DashCard}"
Visibility="{Binding SelectedRun, Converter={StaticResource BoolToVis}}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<TextBlock Style="{StaticResource DashHeader}">
<Run Text="{Binding SelectedRun.PumpModel, Mode=OneWay}"/>
<Run Text=" · "/>
<Run Text="{Binding SelectedRun.PumpSerial, Mode=OneWay}"/>
</TextBlock>
<TextBlock FontSize="11" Foreground="#666"
Text="{Binding SelectedRun.CompletedAt, StringFormat='{}{0:dd MMM yyyy HH:mm:ss}'}"/>
<TextBlock FontSize="11" Foreground="#666" Margin="0,2,0,0"
Text="{Binding SelectedRun.TestNames}"/>
</StackPanel>
<!-- Overall verdict pill -->
<Border Grid.Column="1" Padding="8,3" CornerRadius="3"
VerticalAlignment="Center">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="#B71C1C"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedRun.OverallPassed}" Value="True">
<Setter Property="Background" Value="#2E7D32"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelectedRun.Interrupted}" Value="True">
<Setter Property="Background" Value="#FFB020"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<TextBlock Foreground="White" FontSize="13" FontWeight="Bold">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="{DynamicResource Common.Fail}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedRun.OverallPassed}" Value="True">
<Setter Property="Text" Value="{DynamicResource Common.Pass}"/>
</DataTrigger>
<DataTrigger Binding="{Binding SelectedRun.Interrupted}" Value="True">
<Setter Property="Text" Value="{DynamicResource Results.InterruptedLabel}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
</Grid>
</Border>
<!-- Embedded ResultDisplayView — bound to the page's Detail VM -->
<Border Grid.Row="1" Style="{StaticResource DashCard}"
Visibility="{Binding SelectedRun, Converter={StaticResource BoolToVis}}">
<uc:ResultDisplayView DataContext="{Binding Detail}"/>
</Border>
<!-- Observations / notes -->
<Border Grid.Row="2" Style="{StaticResource DashCard}"
Visibility="{Binding SelectedRun, Converter={StaticResource BoolToVis}}">
<StackPanel>
<TextBlock Text="{DynamicResource Results.ObservationsLabel}"
Style="{StaticResource DashHeader}"/>
<TextBox Text="{Binding SelectedRun.Observations, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AcceptsReturn="True" TextWrapping="Wrap"
Height="80" VerticalScrollBarVisibility="Auto"
FontSize="12"/>
</StackPanel>
</Border>
<!-- Action row -->
<Border Grid.Row="3" Background="#F0F0F0" BorderBrush="#CCC"
BorderThickness="0,1,0,0" Padding="8" Margin="4,4,4,4"
Visibility="{Binding SelectedRun, Converter={StaticResource BoolToVis}}">
<DockPanel LastChildFill="False">
<Button DockPanel.Dock="Right"
Content="{DynamicResource Results.ExportButton}"
Command="{Binding ExportPdfCommand}"
Height="36" MinWidth="160" FontSize="13" FontWeight="Bold"
Foreground="White" Background="#1976D2" BorderBrush="#0D47A1"
BorderThickness="1"/>
</DockPanel>
</Border>
<!-- Empty-state when no selection (covers rows 0-3) -->
<Border Grid.Row="0" Grid.RowSpan="4"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Border.Style>
<Style TargetType="Border" BasedOn="{StaticResource DashCard}">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SelectedRun}" Value="{x:Null}">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<TextBlock Text="{DynamicResource Results.NoSelection}"
HorizontalAlignment="Center" VerticalAlignment="Center"
FontSize="13" Foreground="#888" FontStyle="Italic"
TextWrapping="Wrap" TextAlignment="Center"/>
</Border>
</Grid>
</Grid>
</UserControl>