Add order history card + view-all modal; improve device id; prep settings post button
- ScannerDashboard: added Order History card under employee panel (shows last 4 orders) - Added Today’s Order History modal (View All) with overlay close + close button - Wired modal state + bindings; added TodayOrderHistory collection and loaders - Fixed modal element naming for code-behind references - Updated device id storage to use readable machine/device identifier instead of GUID - Settings: placed Post Data button next to Sync Endpoint and added IsPosting/PostButtonText/CanPostNow state.pull/1/head
parent
90380bf4fb
commit
cb35b6581a
|
|
@ -0,0 +1,21 @@
|
|||
namespace UtopiaCanteenSystem.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One row in the Order History list (last 5 orders).
|
||||
/// </summary>
|
||||
public class OrderHistoryItem
|
||||
{
|
||||
public string EmployeeId { get; set; } = string.Empty;
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
public string Department { get; set; } = string.Empty;
|
||||
public string ScanId { get; set; } = string.Empty;
|
||||
public DateTime OrderTimeUtc { get; set; }
|
||||
/// <summary>The ordered item name, e.g. "Chicken Biryani" (modal only for now).</summary>
|
||||
public string OrderItem { get; set; } = string.Empty;
|
||||
/// <summary>Display label: "Today", "Yesterday", or short date.</summary>
|
||||
public string RelativeDateLabel { get; set; } = string.Empty;
|
||||
/// <summary>Time only, e.g. "09:54 AM".</summary>
|
||||
public string TimeDisplay { get; set; } = string.Empty;
|
||||
/// <summary>Optional avatar path; null = show placeholder.</summary>
|
||||
public string? AvatarPath { get; set; }
|
||||
}
|
||||
|
|
@ -61,7 +61,8 @@ public class ConfigService : IConfigService
|
|||
|
||||
public string GetDeviceId()
|
||||
{
|
||||
var id = _config.DeviceId ?? string.Empty;
|
||||
//var id = _config.DeviceId ?? string.Empty;
|
||||
var id = Environment.MachineName;
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
{
|
||||
id = Guid.NewGuid().ToString("N");
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ public interface IRfidService
|
|||
/// <summary>Returns the last scan record for display (e.g. dashboard).</summary>
|
||||
ScanRecord? GetLastScan();
|
||||
|
||||
/// <summary>Returns the most recent scan records, newest first (for order history).</summary>
|
||||
IReadOnlyList<ScanRecord> GetLastScans(int count);
|
||||
|
||||
/// <summary>Returns all scan records for today (local date), newest first.</summary>
|
||||
IReadOnlyList<ScanRecord> GetScansForToday();
|
||||
|
||||
/// <summary>Returns the count of scans recorded today (local date).</summary>
|
||||
int GetTodayScanCount();
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,29 @@ public class RfidService : IRfidService
|
|||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public IReadOnlyList<ScanRecord> GetLastScans(int count)
|
||||
{
|
||||
if (count <= 0) return Array.Empty<ScanRecord>();
|
||||
using var db = _dbFactory.CreateDbContext();
|
||||
return db.ScanRecords
|
||||
.OrderByDescending(r => r.ScanTime)
|
||||
.Take(count)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IReadOnlyList<ScanRecord> GetScansForToday()
|
||||
{
|
||||
var startOfTodayLocal = DateTime.Today;
|
||||
var startOfTomorrowLocal = startOfTodayLocal.AddDays(1);
|
||||
var startUtc = startOfTodayLocal.ToUniversalTime();
|
||||
var endUtc = startOfTomorrowLocal.ToUniversalTime();
|
||||
using var db = _dbFactory.CreateDbContext();
|
||||
return db.ScanRecords
|
||||
.Where(r => r.ScanTime >= startUtc && r.ScanTime < endUtc)
|
||||
.OrderByDescending(r => r.ScanTime)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public int GetTodayScanCount()
|
||||
{
|
||||
// Define "today" by the local calendar day, but ScanTime is stored as UTC.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using DebounceTimer = System.Timers.Timer;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
|
@ -120,6 +121,21 @@ public partial class ScannerDashboardViewModel : ObservableObject
|
|||
[ObservableProperty]
|
||||
private string? _employeeProfileImagePath = "pack://siteoforigin:,,,/assets/emp-pic/emppic.jpeg";
|
||||
|
||||
/// <summary>Last 4 orders for the Order History card (newest first).</summary>
|
||||
public ObservableCollection<OrderHistoryItem> OrderHistory { get; } = new();
|
||||
|
||||
/// <summary>All orders for today, for the \"View All\" modal (newest first).</summary>
|
||||
public ObservableCollection<OrderHistoryItem> TodayOrderHistory { get; } = new();
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(HasOrderHistory))]
|
||||
private bool _orderHistoryEmpty;
|
||||
|
||||
public bool HasOrderHistory => !OrderHistoryEmpty;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isOrderHistoryModalOpen;
|
||||
|
||||
public ScannerDashboardViewModel(
|
||||
IRfidService rfidService,
|
||||
INavigationService navigation,
|
||||
|
|
@ -179,6 +195,15 @@ public partial class ScannerDashboardViewModel : ObservableObject
|
|||
_ = RefreshDashboardAsync();
|
||||
}
|
||||
|
||||
private static string GetRelativeDateLabel(DateTime utcTime)
|
||||
{
|
||||
var localDate = utcTime.ToLocalTime().Date;
|
||||
var today = DateTime.Today;
|
||||
if (localDate == today) return "Today";
|
||||
if (localDate == today.AddDays(-1)) return "Yesterday";
|
||||
return localDate.ToString("MMM d");
|
||||
}
|
||||
|
||||
partial void OnSiteNumberChanged(string value)
|
||||
{
|
||||
// Numeric only: filter to digits so display stays valid.
|
||||
|
|
@ -392,6 +417,7 @@ public partial class ScannerDashboardViewModel : ObservableObject
|
|||
TodaysScans = todayCount;
|
||||
TotalOrders = todayCount; // Total orders = today's total only (not previous days)
|
||||
ApplyLastScan(last);
|
||||
LoadOrderHistory();
|
||||
});
|
||||
}
|
||||
catch
|
||||
|
|
@ -413,6 +439,97 @@ public partial class ScannerDashboardViewModel : ObservableObject
|
|||
LastScanTimeDisplay = last.ScanTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
private void LoadOrderHistory()
|
||||
{
|
||||
var scans = _rfidService.GetLastScans(4);
|
||||
OrderHistory.Clear();
|
||||
foreach (var r in scans)
|
||||
{
|
||||
var local = r.ScanTime.ToLocalTime();
|
||||
// EmployeeId: placeholder format (will be replaced with real employee lookup later)
|
||||
var employeeId = string.IsNullOrEmpty(r.CardId)
|
||||
? "—"
|
||||
: $"EMP-{(r.CardId.Length >= 4 ? r.CardId[^4..] : r.CardId)}";
|
||||
var employeeName = string.IsNullOrEmpty(r.CardId)
|
||||
? "—"
|
||||
: $"Employee {(r.CardId.Length >= 4 ? r.CardId[^4..] : r.CardId)}";
|
||||
|
||||
OrderHistory.Add(new OrderHistoryItem
|
||||
{
|
||||
EmployeeId = employeeId,
|
||||
EmployeeName = employeeName,
|
||||
Department = "—",
|
||||
ScanId = r.CardId ?? string.Empty, // ScanId remains as CardId
|
||||
OrderTimeUtc = r.ScanTime,
|
||||
TimeDisplay = local.ToString("hh:mm tt"),
|
||||
RelativeDateLabel = GetRelativeDateLabel(r.ScanTime)
|
||||
});
|
||||
}
|
||||
|
||||
OrderHistoryEmpty = OrderHistory.Count == 0;
|
||||
}
|
||||
|
||||
private void LoadTodayOrderHistory()
|
||||
{
|
||||
var scans = _rfidService.GetScansForToday();
|
||||
TodayOrderHistory.Clear();
|
||||
foreach (var r in scans)
|
||||
{
|
||||
var local = r.ScanTime.ToLocalTime();
|
||||
// EmployeeId: placeholder format (will be replaced with real employee lookup later)
|
||||
var employeeId = string.IsNullOrEmpty(r.CardId)
|
||||
? "—"
|
||||
: $"EMP-{(r.CardId.Length >= 4 ? r.CardId[^4..] : r.CardId)}";
|
||||
var employeeName = string.IsNullOrEmpty(r.CardId)
|
||||
? "—"
|
||||
: $"Employee {(r.CardId.Length >= 4 ? r.CardId[^4..] : r.CardId)}";
|
||||
// Demo-only order item: rotate through a small list based on card hash
|
||||
var sampleOrders = new[]
|
||||
{
|
||||
"Chicken Biryani",
|
||||
"Veg Thali",
|
||||
"Grilled Sandwich",
|
||||
"Pasta Alfredo",
|
||||
"Chicken Shawarma",
|
||||
"Paneer Wrap"
|
||||
};
|
||||
var cardKey = r.CardId ?? string.Empty;
|
||||
var orderIndex = sampleOrders.Length == 0
|
||||
? 0
|
||||
: Math.Abs(cardKey.GetHashCode()) % sampleOrders.Length;
|
||||
var orderItem = sampleOrders[orderIndex];
|
||||
|
||||
TodayOrderHistory.Add(new OrderHistoryItem
|
||||
{
|
||||
EmployeeId = employeeId,
|
||||
EmployeeName = employeeName,
|
||||
Department = "—",
|
||||
ScanId = r.CardId ?? string.Empty, // ScanId remains as CardId
|
||||
OrderTimeUtc = r.ScanTime,
|
||||
OrderItem = orderItem,
|
||||
TimeDisplay = local.ToString("hh:mm tt"),
|
||||
RelativeDateLabel = GetRelativeDateLabel(r.ScanTime)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void OpenOrderHistoryModal()
|
||||
{
|
||||
// Delay opening by one UI tick to prevent the same mouse click from immediately closing the modal
|
||||
_uiDispatcher.BeginInvoke(() =>
|
||||
{
|
||||
LoadTodayOrderHistory();
|
||||
IsOrderHistoryModalOpen = true;
|
||||
}, DispatcherPriority.Loaded);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void CloseOrderHistoryModal()
|
||||
{
|
||||
IsOrderHistoryModalOpen = false;
|
||||
}
|
||||
|
||||
private void StartCooldownCountdown(int seconds)
|
||||
{
|
||||
if (seconds <= 0)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,19 @@ public partial class SettingsViewModel : ObservableObject
|
|||
[ObservableProperty]
|
||||
private bool _isSaving;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isPosting;
|
||||
|
||||
|
||||
public bool CanPostNow => !IsPosting;
|
||||
public string PostButtonText => IsPosting ? "Posting..." : "Post Data";
|
||||
|
||||
partial void OnIsPostingChanged(bool value)
|
||||
{
|
||||
OnPropertyChanged(nameof(PostButtonText));
|
||||
OnPropertyChanged(nameof(CanPostNow));
|
||||
}
|
||||
|
||||
public SettingsViewModel(IConfigService configService, INavigationService navigation, IAdminAuditService adminAudit)
|
||||
{
|
||||
_configService = configService;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
<UserControl x:Class="UtopiaCanteenSystem.Views.ScannerDashboardView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:UtopiaCanteenSystem.Converters">
|
||||
|
||||
<UserControl x:Class="UtopiaCanteenSystem.Views.ScannerDashboardView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:UtopiaCanteenSystem.Converters">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
|
||||
<local:StringToVisibilityConverter x:Key="StringToVisibility"/>
|
||||
<local:StringToImageSourceConverter x:Key="StringToImageSource"/>
|
||||
|
||||
<SolidColorBrush x:Key="AccentBrush" Color="#5BA3A0"/>
|
||||
<SolidColorBrush x:Key="AccentLightBrush" Color="#D4EDEB"/>
|
||||
<SolidColorBrush x:Key="AccentBorderBrush" Color="#995BA3A0"/>
|
||||
<SolidColorBrush x:Key="MutedTextBrush" Color="#718096"/>
|
||||
<SolidColorBrush x:Key="TitleTextBrush" Color="#2D3748"/>
|
||||
|
|
@ -27,17 +23,13 @@
|
|||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
CornerRadius="8"
|
||||
SnapsToDevicePixels="True">
|
||||
<ContentPresenter HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"/>
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="8" SnapsToDevicePixels="True">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SecondaryButtonStyle" TargetType="Button">
|
||||
<Setter Property="Foreground" Value="{StaticResource TitleTextBrush}"/>
|
||||
<Setter Property="Background" Value="#FFFFFF"/>
|
||||
|
|
@ -52,26 +44,11 @@
|
|||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="ButtonBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="10">
|
||||
<Border x:Name="ButtonBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Margin="8,0">
|
||||
<TextBlock Text="⚙"
|
||||
FontSize="16"
|
||||
Foreground="{StaticResource SettingsIconBrush}"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{TemplateBinding Content}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
FontWeight="{TemplateBinding FontWeight}"
|
||||
VerticalAlignment="Center"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8,0">
|
||||
<TextBlock Text="⚙" FontSize="16" Foreground="{StaticResource SettingsIconBrush}" Margin="0,0,8,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
|
@ -91,7 +68,6 @@
|
|||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LogoutLinkButtonStyle" TargetType="Button">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
|
|
@ -105,25 +81,11 @@
|
|||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="ButtonBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
CornerRadius="10"
|
||||
BorderBrush="#fee2e2"
|
||||
BorderThickness="1">
|
||||
<Border x:Name="ButtonBorder" Background="{TemplateBinding Background}" CornerRadius="10" BorderBrush="#fee2e2" BorderThickness="1">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<TextBlock Text="⎋"
|
||||
FontSize="16"
|
||||
Foreground="#e53e3e"
|
||||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock Text="Logout"
|
||||
Foreground="#e53e3e"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
FontWeight="{TemplateBinding FontWeight}"
|
||||
VerticalAlignment="Center"/>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Text="⎋" FontSize="16" Foreground="#e53e3e" Margin="0,0,8,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="Logout" Foreground="#e53e3e" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
|
@ -143,7 +105,6 @@
|
|||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StatusTextStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{StaticResource MutedTextBrush}"/>
|
||||
<Setter Property="FontSize" Value="15"/>
|
||||
|
|
@ -154,7 +115,6 @@
|
|||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StatusIconStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
|
||||
<Setter Property="FontSize" Value="16"/>
|
||||
|
|
@ -168,7 +128,6 @@
|
|||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StatusBorderStyle" TargetType="Border">
|
||||
<Setter Property="Background" Value="#dcfce7"/>
|
||||
<Setter Property="BorderBrush" Value="#86efac"/>
|
||||
|
|
@ -183,46 +142,21 @@
|
|||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Background="#F0F2F5" MinHeight="0" MinWidth="0">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
Padding="16"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<Grid MinHeight="{Binding ViewportHeight, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
|
||||
MinWidth="0"
|
||||
HorizontalAlignment="Stretch">
|
||||
<Border HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
MinWidth="360"
|
||||
Width="{Binding ViewportWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
|
||||
MaxWidth="1150"
|
||||
Padding="20"
|
||||
Background="White"
|
||||
CornerRadius="12">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Padding="16" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid MinHeight="{Binding ViewportHeight, RelativeSource={RelativeSource AncestorType=ScrollViewer}}" MinWidth="0" HorizontalAlignment="Stretch">
|
||||
<Border HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="360" Width="{Binding ViewportWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer}}" MaxWidth="1150" Padding="20" Background="White" CornerRadius="12">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="24"
|
||||
ShadowDepth="0"
|
||||
Opacity="0.08"
|
||||
Color="#000000"/>
|
||||
<DropShadowEffect BlurRadius="24" ShadowDepth="0" Opacity="0.08" Color="#000000"/>
|
||||
</Border.Effect>
|
||||
|
||||
<Grid MinWidth="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="0" MaxWidth="480"/>
|
||||
<ColumnDefinition Width="16"/>
|
||||
<ColumnDefinition Width="*" MinWidth="0"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Left Panel: Employee Information (larger text and profile to use space) -->
|
||||
<Border Grid.Column="0"
|
||||
MinWidth="0"
|
||||
Background="#f4f4f4"
|
||||
BorderBrush="#e2e8f0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="10"
|
||||
Padding="24">
|
||||
<Border Grid.Column="0" MinWidth="0" Background="#f4f4f4" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="10" Padding="24">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||
<StackPanel>
|
||||
<!-- Top row: circular profile image (left) + name (right) -->
|
||||
|
|
@ -234,19 +168,12 @@
|
|||
<!-- Profile image (circular); set EmployeeProfileImagePath to show photo -->
|
||||
<Grid Grid.Column="0" Width="110" Height="110" Margin="0,0,18,0">
|
||||
<Ellipse Fill="#e2e8f0"/>
|
||||
<Image Source="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToImageSource}}"
|
||||
Stretch="UniformToFill"
|
||||
Visibility="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToVisibility}}">
|
||||
<Image Source="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToImageSource}}" Stretch="UniformToFill" Visibility="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToVisibility}}">
|
||||
<Image.Clip>
|
||||
<EllipseGeometry Center="55,55" RadiusX="55" RadiusY="55"/>
|
||||
</Image.Clip>
|
||||
</Image>
|
||||
<TextBlock Text="—"
|
||||
FontSize="32"
|
||||
Foreground="{StaticResource MutedTextBrush}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToVisibility}, ConverterParameter=Invert}"/>
|
||||
<TextBlock Text="—" FontSize="32" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding EmployeeProfileImagePath, Converter={StaticResource StringToVisibility}, ConverterParameter=Invert}"/>
|
||||
</Grid>
|
||||
<StackPanel Grid.Column="1" VerticalAlignment="Center" MinWidth="0">
|
||||
<TextBlock Text="Name" FontSize="15" Foreground="{StaticResource MutedTextBrush}" Margin="0,0,0,4"/>
|
||||
|
|
@ -260,19 +187,100 @@
|
|||
<TextBlock Text="{Binding EmployeeId}" FontSize="19" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" Margin="0,0,0,18" TextTrimming="CharacterEllipsis"/>
|
||||
<TextBlock Text="Order" FontSize="15" Foreground="{StaticResource MutedTextBrush}" Margin="0,0,0,4"/>
|
||||
<TextBlock Text="{Binding EmployeeOrderItem}" FontSize="19" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" TextTrimming="CharacterEllipsis" TextWrapping="Wrap"/>
|
||||
<!-- Order History card (dashboard green accent) -->
|
||||
<Border Margin="0,20,0,0" Background="White" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="12" Padding="18">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="12" ShadowDepth="0" Opacity="0.08" Color="#000000"/>
|
||||
</Border.Effect>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Order History" FontSize="18" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}"/>
|
||||
<Border Height="2" Width="32" Background="{StaticResource AccentBrush}" Margin="0,6,0,0" HorizontalAlignment="Left"/>
|
||||
<TextBlock Text="Showing last 4 orders" FontSize="13" Foreground="{StaticResource MutedTextBrush}" Margin="0,8,0,14"/>
|
||||
<!-- Header row with divider -->
|
||||
<Grid Margin="0,0,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="0"/>
|
||||
<ColumnDefinition Width="110"/>
|
||||
<ColumnDefinition Width="90"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="Employee" FontSize="12" FontWeight="SemiBold" Foreground="{StaticResource MutedTextBrush}"/>
|
||||
<TextBlock Grid.Column="1" Text="Scan ID" FontSize="12" FontWeight="SemiBold" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" Text="Time" FontSize="12" FontWeight="SemiBold" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Right"/>
|
||||
</Grid>
|
||||
<Border Height="1" Background="#e2e8f0" Margin="0,8,0,0"/>
|
||||
<!-- Rows -->
|
||||
<ItemsControl ItemsSource="{Binding OrderHistory}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Padding="0,12,0,12" BorderBrush="#e2e8f0" BorderThickness="0,0,0,1">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="0"/>
|
||||
<ColumnDefinition Width="110"/>
|
||||
<ColumnDefinition Width="90"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<Border Width="36" Height="36" Margin="0,0,12,0" CornerRadius="18" Background="{StaticResource AccentLightBrush}" BorderBrush="{StaticResource AccentBrush}" BorderThickness="1">
|
||||
<TextBlock Text="—" FontSize="14" Foreground="{StaticResource AccentBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<!-- Employee column: show EmployeeId (top) + EmployeeName (bottom) -->
|
||||
<TextBlock Text="{Binding EmployeeId}" FontSize="14" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}" TextTrimming="CharacterEllipsis"/>
|
||||
<TextBlock Text="{Binding EmployeeName}" FontSize="12" Foreground="{StaticResource MutedTextBrush}" TextTrimming="CharacterEllipsis" Margin="0,1,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding ScanId}"
|
||||
FontSize="13"
|
||||
Foreground="{StaticResource TitleTextBrush}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
MaxWidth="110"/>
|
||||
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding TimeDisplay}" FontSize="13" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}"/>
|
||||
<TextBlock Text="{Binding RelativeDateLabel}" FontSize="11" Foreground="{StaticResource MutedTextBrush}" Margin="0,1,0,0"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<!-- Empty state -->
|
||||
<TextBlock Text="No orders yet." FontSize="14" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Center" Margin="0,20,0,8">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Collapsed"/>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding OrderHistoryEmpty}" Value="True">
|
||||
<Setter Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style></TextBlock>
|
||||
<!-- View All button -->
|
||||
<Button Command="{Binding OpenOrderHistoryModalCommand}" Margin="0,14,0,0" HorizontalAlignment="Right" Cursor="Hand" FontSize="13" FontWeight="SemiBold" Foreground="White" Background="{StaticResource AccentBrush}" BorderThickness="0" Padding="14,8" MinWidth="100">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="0" CornerRadius="8" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="View All" Foreground="White"/>
|
||||
<TextBlock Text=" →" Margin="4,0,0,0" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
<!-- Divider between panels -->
|
||||
<Border Grid.Column="1" Width="1" Background="#e2e8f0" HorizontalAlignment="Center" MinWidth="0"/>
|
||||
|
||||
<!-- Right Panel: Order placement + statistics -->
|
||||
<Border Grid.Column="2"
|
||||
MinWidth="0"
|
||||
Background="White"
|
||||
CornerRadius="10"
|
||||
Padding="16">
|
||||
<Border Grid.Column="2" MinWidth="0" Background="White" CornerRadius="10" Padding="16">
|
||||
<Grid MinWidth="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
|
|
@ -284,28 +292,8 @@
|
|||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Menu button (top-right) -->
|
||||
<ToggleButton x:Name="MenuToggleButton"
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,0,0,12"
|
||||
IsChecked="{Binding IsMenuOpen, Mode=TwoWay}"
|
||||
Unchecked="MenuToggleButton_Unchecked"
|
||||
Background="#f4f7f7"
|
||||
BorderBrush="#e2e8f0"
|
||||
BorderThickness="1"
|
||||
Padding="14,10"
|
||||
MinWidth="48"
|
||||
MinHeight="44"
|
||||
FontSize="22"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="{StaticResource TitleTextBrush}"
|
||||
Focusable="False"
|
||||
IsTabStop="False"
|
||||
ToolTip="Menu"
|
||||
Cursor="Hand">
|
||||
<ToggleButton x:Name="MenuToggleButton" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,0,12" IsChecked="{Binding IsMenuOpen, Mode=TwoWay}" Unchecked="MenuToggleButton_Unchecked" Background="#f4f7f7" BorderBrush="#e2e8f0" BorderThickness="1" Padding="14,10" MinWidth="48" MinHeight="44" FontSize="22" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" Focusable="False" IsTabStop="False" ToolTip="Menu" Cursor="Hand">
|
||||
<ToggleButton.Content>⋮</ToggleButton.Content>
|
||||
<ToggleButton.Style>
|
||||
<Style TargetType="ToggleButton">
|
||||
|
|
@ -331,50 +319,15 @@
|
|||
</Style>
|
||||
</ToggleButton.Style>
|
||||
</ToggleButton>
|
||||
|
||||
<!-- Inline menu panel (responsive: wraps; Settings/Logout with consistent sizing) -->
|
||||
<Border x:Name="MenuPanel"
|
||||
Grid.Row="1"
|
||||
MinWidth="0"
|
||||
Background="#f8fafc"
|
||||
BorderBrush="#e2e8f0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="8"
|
||||
Padding="14"
|
||||
Margin="0,0,0,12"
|
||||
Visibility="{Binding IsMenuOpen, Converter={StaticResource BoolToVisibility}}">
|
||||
<WrapPanel Orientation="Horizontal"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,2,0,2">
|
||||
<Border x:Name="MenuPanel" Grid.Row="1" MinWidth="0" Background="#f8fafc" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="8" Padding="14" Margin="0,0,0,12" Visibility="{Binding IsMenuOpen, Converter={StaticResource BoolToVisibility}}">
|
||||
<WrapPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,2,0,2">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,20,0">
|
||||
<TextBlock Text="SITE :" VerticalAlignment="Center" FontSize="14" FontWeight="SemiBold" Foreground="{StaticResource TitleTextBrush}" Margin="0,0,8,0"/>
|
||||
<TextBox x:Name="SiteNumberTextBox"
|
||||
Text="{Binding SiteNumber, UpdateSourceTrigger=PropertyChanged}"
|
||||
Width="72"
|
||||
MinWidth="56"
|
||||
FontSize="14"
|
||||
Padding="8,8"
|
||||
MinHeight="40"
|
||||
VerticalContentAlignment="Center"
|
||||
PreviewTextInput="SiteNumberTextBox_PreviewTextInput"/>
|
||||
<TextBox x:Name="SiteNumberTextBox" Text="{Binding SiteNumber, UpdateSourceTrigger=PropertyChanged}" Width="72" MinWidth="56" FontSize="14" Padding="8,8" MinHeight="40" VerticalContentAlignment="Center" PreviewTextInput="SiteNumberTextBox_PreviewTextInput"/>
|
||||
</StackPanel>
|
||||
<Button Content="Settings"
|
||||
Command="{Binding OpenSettingsCommand}"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Margin="0,0,10,0"
|
||||
MinWidth="100"
|
||||
MinHeight="44"
|
||||
Padding="16,10"
|
||||
FontSize="14"
|
||||
Focusable="False"
|
||||
IsTabStop="False"/>
|
||||
<Button Command="{Binding LogoutCommand}"
|
||||
Style="{StaticResource LogoutLinkButtonStyle}"
|
||||
MinWidth="100"
|
||||
MinHeight="44"
|
||||
Padding="16,10"
|
||||
Focusable="False"
|
||||
IsTabStop="False">
|
||||
<Button Content="Settings" Command="{Binding OpenSettingsCommand}" Style="{StaticResource SecondaryButtonStyle}" Margin="0,0,10,0" MinWidth="100" MinHeight="44" Padding="16,10" FontSize="14" Focusable="False" IsTabStop="False"/>
|
||||
<Button Command="{Binding LogoutCommand}" Style="{StaticResource LogoutLinkButtonStyle}" MinWidth="100" MinHeight="44" Padding="16,10" Focusable="False" IsTabStop="False">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<TextBlock Text="⎋" FontSize="14" Margin="0,0,8,0" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="Logout" FontSize="14" FontWeight="SemiBold" VerticalAlignment="Center"/>
|
||||
|
|
@ -382,90 +335,35 @@
|
|||
</Button>
|
||||
</WrapPanel>
|
||||
</Border>
|
||||
|
||||
<!-- Logo + instruction -->
|
||||
<StackPanel Grid.Row="2" HorizontalAlignment="Center" MinWidth="0">
|
||||
<Image Source="pack://siteoforigin:,,,/assets/logo4.png"
|
||||
Height="100"
|
||||
MaxWidth="320"
|
||||
Stretch="Uniform"
|
||||
Margin="0,0,0,8"/>
|
||||
<TextBlock Text="Tap card to place order"
|
||||
FontSize="16"
|
||||
Foreground="{StaticResource MutedTextBrush}"
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"/>
|
||||
<Image Source="pack://siteoforigin:,,,/assets/logo4.png" Height="100" MaxWidth="320" Stretch="Uniform" Margin="0,0,0,8"/>
|
||||
<TextBlock Text="Tap card to place order" FontSize="16" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Center" TextAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Scan box + Place Order button -->
|
||||
<StackPanel Grid.Row="3" Margin="0,16,0,0" MinWidth="0">
|
||||
<Border MinHeight="50"
|
||||
CornerRadius="8"
|
||||
BorderBrush="{StaticResource AccentBorderBrush}"
|
||||
BorderThickness="2">
|
||||
<Border MinHeight="50" CornerRadius="8" BorderBrush="{StaticResource AccentBorderBrush}" BorderThickness="2">
|
||||
<Grid>
|
||||
<TextBox x:Name="RfidInputTextBox"
|
||||
Text="{Binding CardIdInput, UpdateSourceTrigger=PropertyChanged}"
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
FontSize="18"
|
||||
MinHeight="50"
|
||||
VerticalContentAlignment="Center"
|
||||
HorizontalContentAlignment="Center"
|
||||
Focusable="True"
|
||||
KeyDown="RfidInputTextBox_OnKeyDown"
|
||||
LostKeyboardFocus="RfidInputTextBox_OnLostKeyboardFocus"/>
|
||||
<TextBlock Text="Scan..."
|
||||
Foreground="Gray"
|
||||
FontSize="18"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
IsHitTestVisible="False"
|
||||
Visibility="{Binding IsWatermarkVisible, Converter={StaticResource BoolToVisibility}}"/>
|
||||
<TextBox x:Name="RfidInputTextBox" Text="{Binding CardIdInput, UpdateSourceTrigger=PropertyChanged}" Background="Transparent" BorderThickness="0" FontSize="18" MinHeight="50" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Focusable="True" KeyDown="RfidInputTextBox_OnKeyDown" LostKeyboardFocus="RfidInputTextBox_OnLostKeyboardFocus"/>
|
||||
<TextBlock Text="Scan..." Foreground="Gray" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" IsHitTestVisible="False" Visibility="{Binding IsWatermarkVisible, Converter={StaticResource BoolToVisibility}}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Button Content="PLACE ORDER"
|
||||
Command="{Binding ScanCommand}"
|
||||
Margin="0,12,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
Style="{StaticResource RoundedButtonStyle}"/>
|
||||
<Button Content="PLACE ORDER" Command="{Binding ScanCommand}" Margin="0,12,0,0" HorizontalAlignment="Stretch" Style="{StaticResource RoundedButtonStyle}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Scanner status + timestamp -->
|
||||
<StackPanel Grid.Row="4" Margin="0,14,0,0" HorizontalAlignment="Center">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<TextBlock Style="{StaticResource StatusIconStyle}" Margin="0,0,8,0"/>
|
||||
<TextBlock Text="{Binding ScannerStatusDisplay}" Style="{StaticResource StatusTextStyle}"/>
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding CurrentTime}"
|
||||
FontSize="14"
|
||||
Foreground="{StaticResource MutedTextBrush}"
|
||||
Margin="0,6,0,0"
|
||||
HorizontalAlignment="Center"/>
|
||||
<TextBlock Text="{Binding CurrentTime}" FontSize="14" Foreground="{StaticResource MutedTextBrush}" Margin="0,6,0,0" HorizontalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Divider -->
|
||||
<Border Grid.Row="5" Height="1" Background="#e2e8f0" Margin="0,14,0,14"/>
|
||||
|
||||
<!-- Cooldown alert -->
|
||||
<Border Grid.Row="6"
|
||||
Background="#fef2f2"
|
||||
BorderBrush="#fca5a5"
|
||||
BorderThickness="2"
|
||||
CornerRadius="8"
|
||||
Padding="14"
|
||||
Margin="0,0,0,12"
|
||||
Visibility="{Binding ShowCooldownAlert, Converter={StaticResource BoolToVisibility}}">
|
||||
<TextBlock Text="{Binding CooldownAlertMessage}"
|
||||
FontSize="18"
|
||||
FontWeight="Bold"
|
||||
Foreground="{StaticResource ErrorTextBrush}"
|
||||
TextWrapping="Wrap"
|
||||
TextAlignment="Center"
|
||||
HorizontalAlignment="Center"/>
|
||||
<Border Grid.Row="6" Background="#fef2f2" BorderBrush="#fca5a5" BorderThickness="2" CornerRadius="8" Padding="14" Margin="0,0,0,12" Visibility="{Binding ShowCooldownAlert, Converter={StaticResource BoolToVisibility}}">
|
||||
<TextBlock Text="{Binding CooldownAlertMessage}" FontSize="18" FontWeight="Bold" Foreground="{StaticResource ErrorTextBrush}" TextWrapping="Wrap" TextAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<!-- Statistics -->
|
||||
<Grid Grid.Row="7" MinWidth="0">
|
||||
<Grid.RowDefinitions>
|
||||
|
|
@ -473,7 +371,6 @@
|
|||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0" Margin="0,0,0,12">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="0"/>
|
||||
|
|
@ -492,7 +389,6 @@
|
|||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="1" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="8" Padding="12" Margin="0,0,0,12">
|
||||
<Grid MinWidth="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
|
@ -509,10 +405,7 @@
|
|||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="2"
|
||||
Style="{StaticResource StatusBorderStyle}"
|
||||
Visibility="{Binding Message, Converter={StaticResource StringToVisibility}}">
|
||||
<Border Grid.Row="2" Style="{StaticResource StatusBorderStyle}" Visibility="{Binding Message, Converter={StaticResource StringToVisibility}}">
|
||||
<TextBlock Text="{Binding Message}" FontSize="16" FontWeight="SemiBold" TextWrapping="Wrap">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
|
|
@ -523,16 +416,96 @@
|
|||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</TextBlock.Style></TextBlock>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
<!-- Order History modal overlay (ZIndex ensures it appears on top) -->
|
||||
<Border x:Name="OrderHistoryModalOverlay" Panel.ZIndex="1000" Visibility="{Binding IsOrderHistoryModalOpen, Converter={StaticResource BoolToVisibility}}" Background="#80000000" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MouseLeftButtonDown="OrderHistoryModalOverlay_MouseLeftButtonDown">
|
||||
<Border x:Name="OrderHistoryModalContent" HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="480" MaxWidth="720" MaxHeight="640" Background="White" BorderBrush="#e2e8f0" BorderThickness="1" CornerRadius="12" Padding="0" Loaded="OrderHistoryModalContent_Loaded">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="24" ShadowDepth="0" Opacity="0.15" Color="#000000"/>
|
||||
</Border.Effect>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*" MinHeight="120"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Title + Close X -->
|
||||
<Grid Grid.Row="0" Margin="24,20,16,16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Today's Order History" FontSize="20" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}" VerticalAlignment="Center"/>
|
||||
<Button x:Name="OrderHistoryModalCloseXButton" Grid.Column="1" Click="OrderHistoryModalClose_Click" Background="Transparent" BorderThickness="0" Width="32" Height="32" Padding="0" Cursor="Hand" Content="✕" FontSize="16" Foreground="{StaticResource MutedTextBrush}" ToolTip="Close"/>
|
||||
</Grid>
|
||||
<!-- Scrollable list -->
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="24,4,24,12" Padding="0,0,4,0">
|
||||
<StackPanel>
|
||||
<!-- Header row -->
|
||||
<Grid Margin="0,0,0,10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="0"/>
|
||||
<ColumnDefinition Width="110"/>
|
||||
<ColumnDefinition Width="90"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="Employee" FontSize="12" FontWeight="SemiBold" Foreground="{StaticResource MutedTextBrush}"/>
|
||||
<TextBlock Grid.Column="1" Text="Scan ID" FontSize="12" FontWeight="SemiBold" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" Text="Time" FontSize="12" FontWeight="SemiBold" Foreground="{StaticResource MutedTextBrush}" HorizontalAlignment="Right"/>
|
||||
</Grid>
|
||||
<ItemsControl ItemsSource="{Binding TodayOrderHistory}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Padding="0,10,0,10" BorderBrush="#e2e8f0" BorderThickness="0,0,0,1">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="0"/>
|
||||
<ColumnDefinition Width="110"/>
|
||||
<ColumnDefinition Width="90"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<Border Width="36" Height="36" Margin="0,0,10,0" CornerRadius="18" Background="{StaticResource AccentLightBrush}" BorderBrush="{StaticResource AccentBrush}" BorderThickness="1">
|
||||
<TextBlock Text="—" FontSize="14" Foreground="{StaticResource AccentBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<!-- Employee column: show EmployeeId (top) + EmployeeName (middle) + Order item (bottom, muted) -->
|
||||
<TextBlock Text="{Binding EmployeeId}" FontSize="14" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}" TextTrimming="CharacterEllipsis"/>
|
||||
<TextBlock Text="{Binding EmployeeName}" FontSize="12" Foreground="{StaticResource MutedTextBrush}" TextTrimming="CharacterEllipsis" Margin="0,1,0,0"/>
|
||||
<TextBlock Text="{Binding OrderItem, StringFormat='Order: {0}'}" FontSize="11" Foreground="{StaticResource MutedTextBrush}" TextTrimming="CharacterEllipsis" Margin="0,1,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding ScanId}"
|
||||
FontSize="13"
|
||||
Foreground="{StaticResource TitleTextBrush}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
MaxWidth="110"/>
|
||||
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding TimeDisplay}" FontSize="13" FontWeight="Bold" Foreground="{StaticResource TitleTextBrush}"/>
|
||||
<TextBlock Text="{Binding RelativeDateLabel}" FontSize="11" Foreground="{StaticResource MutedTextBrush}" Margin="0,1,0,0"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<!-- Close button -->
|
||||
<Border Grid.Row="2" Padding="24,14,24,22" BorderBrush="#e2e8f0" BorderThickness="0,1,0,0" Background="#f8fafc" CornerRadius="0,0,12,12">
|
||||
<Button Content="Close" Click="OrderHistoryModalClose_Click" HorizontalAlignment="Center" MinWidth="120" Padding="20,12" FontSize="15" FontWeight="SemiBold" Foreground="White" Background="{StaticResource AccentBrush}" BorderThickness="0" Cursor="Hand"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
</UserControl>
|
||||
|
|
@ -14,6 +14,8 @@ namespace UtopiaCanteenSystem.Views;
|
|||
public partial class ScannerDashboardView : UserControl
|
||||
{
|
||||
private bool _isUnloaded;
|
||||
private bool _suppressScannerFocus;
|
||||
private DispatcherTimer? _focusSuppressionTimer;
|
||||
|
||||
public ScannerDashboardView()
|
||||
{
|
||||
|
|
@ -31,6 +33,10 @@ public partial class ScannerDashboardView : UserControl
|
|||
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_isUnloaded = true;
|
||||
|
||||
// Clean up timer
|
||||
_focusSuppressionTimer?.Stop();
|
||||
_focusSuppressionTimer = null;
|
||||
}
|
||||
|
||||
private void FocusRfidInput(bool selectAll, DispatcherPriority priority)
|
||||
|
|
@ -43,6 +49,14 @@ public partial class ScannerDashboardView : UserControl
|
|||
if (_isUnloaded || !IsVisible || !IsEnabled)
|
||||
return;
|
||||
|
||||
// Don't auto-focus scanner input if focus suppression is active
|
||||
if (_suppressScannerFocus)
|
||||
return;
|
||||
|
||||
// Don't auto-focus scanner input if the Order History modal is open
|
||||
if (DataContext is ScannerDashboardViewModel vm && vm.IsOrderHistoryModalOpen)
|
||||
return;
|
||||
|
||||
RfidInputTextBox.Focus();
|
||||
Keyboard.Focus(RfidInputTextBox);
|
||||
|
||||
|
|
@ -53,11 +67,45 @@ public partial class ScannerDashboardView : UserControl
|
|||
|
||||
private void RfidInputTextBox_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
|
||||
{
|
||||
// Don't auto-focus scanner input if focus suppression is active
|
||||
if (_suppressScannerFocus)
|
||||
return;
|
||||
|
||||
// Don't auto-focus scanner input if the Order History modal is open
|
||||
if (DataContext is ScannerDashboardViewModel vm && vm.IsOrderHistoryModalOpen)
|
||||
return;
|
||||
|
||||
// If focus moved into the menu panel (e.g. Site number field), don't steal it back.
|
||||
if (IsDescendantOf(MenuPanel, e.NewFocus as DependencyObject))
|
||||
return;
|
||||
// Otherwise keep view scan-ready (e.g. after closing menu or clicking elsewhere).
|
||||
FocusRfidInput(selectAll: false, DispatcherPriority.ApplicationIdle);
|
||||
|
||||
// SIMPLE FIX: Just add a small delay before refocusing
|
||||
// This gives buttons time to process their click events
|
||||
DispatcherTimer focusTimer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(150) // 150ms is enough for click to process
|
||||
};
|
||||
|
||||
focusTimer.Tick += (s, args) =>
|
||||
{
|
||||
focusTimer.Stop();
|
||||
|
||||
// Check conditions again after delay
|
||||
if (_suppressScannerFocus)
|
||||
return;
|
||||
|
||||
if (DataContext is ScannerDashboardViewModel viewModel && viewModel.IsOrderHistoryModalOpen)
|
||||
return;
|
||||
|
||||
// Only refocus if we're not already focused somewhere else
|
||||
// If modal opened, it will have focus now
|
||||
if (Keyboard.FocusedElement != RfidInputTextBox)
|
||||
{
|
||||
FocusRfidInput(selectAll: false, DispatcherPriority.ApplicationIdle);
|
||||
}
|
||||
};
|
||||
|
||||
focusTimer.Start();
|
||||
}
|
||||
|
||||
private static bool IsDescendantOf(DependencyObject? ancestor, DependencyObject? element)
|
||||
|
|
@ -93,5 +141,61 @@ public partial class ScannerDashboardView : UserControl
|
|||
// When user closes the menu, focus scanner input so they can scan without clicking it.
|
||||
FocusRfidInput(selectAll: false, DispatcherPriority.ApplicationIdle);
|
||||
}
|
||||
|
||||
private void OrderHistoryModalOverlay_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
// Only close if the user actually clicked the dark overlay background,
|
||||
// not when the event is bubbling from inside the dialog content.
|
||||
if (!ReferenceEquals(e.OriginalSource, sender))
|
||||
return;
|
||||
|
||||
CloseOrderHistoryModal();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OrderHistoryModalContent_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// No special behavior required here for now; this hook exists to satisfy XAML and
|
||||
// is a good place to move focus inside the dialog if needed later.
|
||||
}
|
||||
|
||||
private void OrderHistoryModalClose_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CloseOrderHistoryModal();
|
||||
}
|
||||
|
||||
private void CloseOrderHistoryModal()
|
||||
{
|
||||
if (DataContext is ScannerDashboardViewModel vm)
|
||||
{
|
||||
vm.IsOrderHistoryModalOpen = false;
|
||||
// Suppress scanner focus temporarily after closing modal
|
||||
SuppressScannerFocusTemporarily();
|
||||
}
|
||||
}
|
||||
|
||||
private void SuppressScannerFocusTemporarily()
|
||||
{
|
||||
_suppressScannerFocus = true;
|
||||
|
||||
// Clear any existing timer
|
||||
_focusSuppressionTimer?.Stop();
|
||||
|
||||
// Create a timer to clear suppression after UI settles
|
||||
_focusSuppressionTimer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(300) // Short delay to let UI settle
|
||||
};
|
||||
_focusSuppressionTimer.Tick += (s, e) =>
|
||||
{
|
||||
_suppressScannerFocus = false;
|
||||
_focusSuppressionTimer.Stop();
|
||||
_focusSuppressionTimer = null;
|
||||
|
||||
// Now restore scanner focus after suppression period
|
||||
FocusRfidInput(selectAll: false, DispatcherPriority.ApplicationIdle);
|
||||
};
|
||||
_focusSuppressionTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -244,13 +244,43 @@
|
|||
Foreground="{StaticResource MutedText}"
|
||||
Margin="0,0,0,20" />
|
||||
|
||||
<TextBlock Text="Sync API Endpoint (UIND)" FontSize="16" Foreground="{StaticResource PrimaryText}" FontWeight="SemiBold" />
|
||||
<!--<TextBlock Text="Sync API Endpoint (UIND)" FontSize="16" Foreground="{StaticResource PrimaryText}" FontWeight="SemiBold" />
|
||||
<TextBox Text="{Binding SyncApiEndpoint, UpdateSourceTrigger=PropertyChanged}"
|
||||
Style="{StaticResource ModernTextBoxStyle}" Margin="0,8,0,8" />
|
||||
<TextBlock Text="Endpoint used to sync scan records."
|
||||
FontSize="14"
|
||||
Foreground="{StaticResource MutedText}"
|
||||
Margin="0,0,0,20" />
|
||||
Margin="0,0,0,20" />-->
|
||||
<TextBlock Text="Sync API Endpoint (UIND)"
|
||||
FontSize="16"
|
||||
Foreground="{StaticResource PrimaryText}"
|
||||
FontWeight="SemiBold" />
|
||||
|
||||
<Grid Margin="0,8,0,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="16" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBox Grid.Column="0"
|
||||
Text="{Binding SyncApiEndpoint, UpdateSourceTrigger=PropertyChanged}"
|
||||
Style="{StaticResource ModernTextBoxStyle}" />
|
||||
|
||||
<!-- Post button right next to textbox -->
|
||||
<Button Grid.Column="2"
|
||||
Content="{Binding PostButtonText}"
|
||||
Command="{Binding PostDataNowCommand}"
|
||||
Style="{StaticResource PrimaryButtonStyle}"
|
||||
MinWidth="150"
|
||||
IsEnabled="{Binding CanPostNow}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Text="Endpoint used to sync scan records."
|
||||
FontSize="14"
|
||||
Foreground="{StaticResource MutedText}"
|
||||
Margin="0,0,0,20" />
|
||||
|
||||
|
||||
<!-- Message area -->
|
||||
<Border Margin="0,0,0,20" Padding="16" CornerRadius="8">
|
||||
|
|
@ -336,7 +366,7 @@
|
|||
Style="{StaticResource OutlineButtonStyle}"
|
||||
MinWidth="120"
|
||||
Margin="0,0,16,0" />
|
||||
<Button Content="Save Changes"
|
||||
<Button Content="Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
Style="{StaticResource PrimaryButtonStyle}"
|
||||
MinWidth="120" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue