Quellcode durchsuchen

Added EmployeeNotes and rearranged Timesheet panel.

Kenric Nugteren vor 7 Monaten
Ursprung
Commit
d9d3fde7cf

+ 28 - 0
prs.classes/Entities/Employee/EmployeeNote.cs

@@ -0,0 +1,28 @@
+using InABox.Core;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Comal.Classes
+{
+    public class EmployeeNote : Entity, IRemotable, IPersistent, ILicense<CoreLicense>
+    {
+        [EditorSequence(1)]
+        [EntityRelationship(DeleteAction.Cascade)]
+        public EmployeeLink Employee { get; set; }
+
+        [EditorSequence(2)]
+        public DateTime Date { get; set; }
+
+        [EditorSequence(3)]
+        [MemoEditor]
+        public string Note { get; set; } = "";
+
+        static EmployeeNote()
+        {
+            DefaultColumns.Add<EmployeeNote>(x => x.Employee.Code);
+            DefaultColumns.Add<EmployeeNote>(x => x.Date);
+            DefaultColumns.Add<EmployeeNote>(x => x.Note);
+        }
+    }
+}

+ 1 - 1
prs.classes/Entities/Equipment/EquipmentFuelType.cs

@@ -5,7 +5,7 @@ using System.Text;
 
 namespace Comal.Classes
 {
-    public class EquipmentFuelType : Entity, IRemotable, IPersistent
+    public class EquipmentFuelType : Entity, IRemotable, IPersistent, ILicense<EquipmentLicense>
     {
         [UniqueCodeEditor]
         public string Code { get; set; } = "";

+ 6 - 0
prs.classes/Settings/TimeSheetSettings.cs

@@ -11,6 +11,9 @@ namespace Comal.Classes
             EndDate = DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek).AddDays(1);
             StartDate = DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek).AddDays(7);
             FutureTimes = false;
+
+            ViewType = ScreenViewType.Register;
+            AnchorWidth = 500F;
         }
 
         public int View { get; set; }
@@ -18,5 +21,8 @@ namespace Comal.Classes
         public DateTime EndDate { get; set; }
         public bool FutureTimes { get; set; }
         public bool? ApprovedOnly { get; set; }
+
+        public ScreenViewType ViewType { get; set; }
+        public double AnchorWidth { get; set; }
     }
 }

+ 47 - 0
prs.desktop/Panels/Timesheets/TimesheetAssignmentGrid.cs

@@ -0,0 +1,47 @@
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace PRSDesktop.Panels.Timesheets;
+
+internal class TimesheetAssignmentGrid : DynamicDataGrid<Assignment>, ISpecificGrid
+{
+    public Guid EmployeeID { get; set; }
+
+    public DateTime Date { get; set; }
+
+    protected override bool CanCreateItems()
+    {
+        return base.CanCreateItems() && EmployeeID != Guid.Empty;
+    }
+
+    public override Assignment CreateItem()
+    {
+        var item = base.CreateItem();
+        item.EmployeeLink.ID = EmployeeID;
+        item.Date = Date;
+        return item;
+    }
+
+    protected override void Reload(Filters<Assignment> criteria, Columns<Assignment> columns, ref SortOrder<Assignment>? sort, CancellationToken token, Action<CoreTable?, Exception?> action)
+    {
+        if(EmployeeID == Guid.Empty)
+        {
+            criteria.Add(new Filter<Assignment>().None());
+        }
+        else
+        {
+            criteria.Add(new Filter<Assignment>(x => x.EmployeeLink.ID).IsEqualTo(EmployeeID));
+            criteria.Add(new Filter<Assignment>(x => x.Date).IsGreaterThanOrEqualTo(Date)
+                .And(x => x.Date).IsLessThan(Date.AddDays(1)));
+        }
+
+        base.Reload(criteria, columns, ref sort, token, action);
+    }
+}

+ 0 - 1
prs.desktop/Grids/TimesheetGrid.cs → prs.desktop/Panels/Timesheets/TimesheetGrid.cs

@@ -92,7 +92,6 @@ namespace PRSDesktop
             HiddenColumns.Add(x => x.EmployeeLink.ID);
             HiddenColumns.Add(x => x.LeaveRequestLink.ID);
             HiddenColumns.Add(x => x.JobLink.ID);
-            HiddenColumns.Add(x => x.JobLink.Deleted);
 
             HiddenColumns.Add(x => x.Approved);
             HiddenColumns.Add(x => x.PostedNote);

+ 47 - 0
prs.desktop/Panels/Timesheets/TimesheetNotesGrid.cs

@@ -0,0 +1,47 @@
+using Comal.Classes;
+using InABox.Core;
+using InABox.DynamicGrid;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace PRSDesktop.Panels.Timesheets;
+
+internal class TimesheetNotesGrid : DynamicDataGrid<EmployeeNote>, ISpecificGrid
+{
+    public Guid EmployeeID { get; set; }
+
+    public DateTime Date { get; set; }
+
+    protected override bool CanCreateItems()
+    {
+        return base.CanCreateItems() && EmployeeID != Guid.Empty;
+    }
+
+    public override EmployeeNote CreateItem()
+    {
+        var item = base.CreateItem();
+        item.Employee.ID = EmployeeID;
+        item.Date = Date;
+        return item;
+    }
+
+    protected override void Reload(Filters<EmployeeNote> criteria, Columns<EmployeeNote> columns, ref SortOrder<EmployeeNote>? sort, CancellationToken token, Action<CoreTable?, Exception?> action)
+    {
+        if(EmployeeID == Guid.Empty)
+        {
+            criteria.Add(new Filter<EmployeeNote>().None());
+        }
+        else
+        {
+            criteria.Add(new Filter<EmployeeNote>(x => x.Employee.ID).IsEqualTo(EmployeeID));
+            criteria.Add(new Filter<EmployeeNote>(x => x.Date).IsGreaterThanOrEqualTo(Date)
+                .And(x => x.Date).IsLessThan(Date.AddDays(1)));
+        }
+
+        base.Reload(criteria, columns, ref sort, token, action);
+    }
+}

+ 81 - 54
prs.desktop/Panels/Timesheets/TimesheetPanel.xaml

@@ -3,62 +3,89 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:local="clr-namespace:PRSDesktop"
+             xmlns:prs="clr-namespace:PRSDesktop"
+             xmlns:local="clr-namespace:PRSDesktop.Panels.Timesheets"
+             xmlns:dg="clr-namespace:InABox.DynamicGrid;assembly=InABox.Wpf"
+             xmlns:sf="http://schemas.syncfusion.com/wpf"
              mc:Ignorable="d"
              d:DesignHeight="450" d:DesignWidth="800">
-    <Grid>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="Auto" />
-            <RowDefinition Height="*" />
-        </Grid.RowDefinitions>
-        <Border Grid.Row="0" CornerRadius="5,5,0,0" Padding="5" Background="WhiteSmoke" BorderBrush="Gray"
-                BorderThickness="0.75">
+    <dg:DynamicSplitPanel x:Name="SplitPanel" AllowableViews="Master,Combined" MasterCaption="Timesheets" Anchor="Detail"
+                          DetailCaption="Details"
+                          OnChanged="SplitPanel_OnChanged">
+        <dg:DynamicSplitPanel.Header>
+            <Border BorderBrush="Gray" Background="WhiteSmoke" BorderThickness="0.75">
+                <Label Content="Timesheets" HorizontalContentAlignment="Center"/>
+            </Border>
+        </dg:DynamicSplitPanel.Header>
+        <dg:DynamicSplitPanel.Master>
             <Grid>
-                <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="Auto" />
-                    <ColumnDefinition Width="*" />
-                </Grid.ColumnDefinitions>
-                <Label Grid.Column="0" Content="Show" VerticalContentAlignment="Center" />
-                <ComboBox x:Name="View" Grid.Column="1" MinWidth="100" VerticalContentAlignment="Center"
-                          SelectedIndex="0" SelectionChanged="View_SelectionChanged">
-                    <ComboBoxItem Content="Today" />
-                    <ComboBoxItem Content="Yesterday" />
-                    <ComboBoxItem Content="This Week" />
-                    <ComboBoxItem Content="Last Week" />
-                    <ComboBoxItem Content="This Month" />
-                    <ComboBoxItem Content="Last Month" />
-                    <ComboBoxItem Content="This Year" />
-                    <ComboBoxItem Content="Last Year" />
-                    <ComboBoxItem Content="Custom" />
-                </ComboBox>
-                <Label x:Name="StartLabel" Grid.Column="2" Content="Starting" VerticalContentAlignment="Center" />
-                <DatePicker x:Name="StartPicker" Grid.Column="3" MinWidth="100" VerticalContentAlignment="Center"
-                            IsEnabled="False" SelectedDateChanged="SelectedDateChanged" />
-                <Label x:Name="EndLabel" Grid.Column="4" Content="Ending" VerticalContentAlignment="Center" />
-                <DatePicker x:Name="EndPicker" Grid.Column="5" MinWidth="100" VerticalContentAlignment="Center"
-                            SelectedDateChanged="SelectedDateChanged" />
-                <Label x:Name="FutureLabel" Grid.Column="6" Content="Include Future?" VerticalContentAlignment="Center" />
-                <CheckBox x:Name="FutureTimes" Grid.Column="7" VerticalContentAlignment="Center"
-                          Checked="FutureTimes_Checked" Unchecked="FutureTimes_Checked" IsThreeState="False" />
-                <Label x:Name="ApprovedLabel" Grid.Column="8" Content="Approved Only?"
-                       VerticalContentAlignment="Center" />
-                <CheckBox x:Name="ApprovedTimes" Grid.Column="9" VerticalContentAlignment="Center"
-                          Checked="ApprovedTimes_Checked" Unchecked="ApprovedTimes_Checked" IsThreeState="False" />
-                <Label Grid.Column="10" Content="Search" VerticalContentAlignment="Center" />
-                <TextBox x:Name="Search" Grid.Column="11" KeyUp="Search_KeyUp" />
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="Auto" />
+                    <RowDefinition Height="*" />
+                </Grid.RowDefinitions>
+                <Border Grid.Row="0" CornerRadius="5,5,0,0" Padding="5" Background="WhiteSmoke" BorderBrush="Gray"
+                        BorderThickness="0.75">
+                    <DockPanel>
+                        <Label Content="Show" VerticalContentAlignment="Center" />
+                        <ComboBox x:Name="View" MinWidth="100" VerticalContentAlignment="Center"
+                                  SelectedIndex="0" SelectionChanged="View_SelectionChanged">
+                            <ComboBoxItem Content="Today" />
+                            <ComboBoxItem Content="Yesterday" />
+                            <ComboBoxItem Content="This Week" />
+                            <ComboBoxItem Content="Last Week" />
+                            <ComboBoxItem Content="This Month" />
+                            <ComboBoxItem Content="Last Month" />
+                            <ComboBoxItem Content="This Year" />
+                            <ComboBoxItem Content="Last Year" />
+                            <ComboBoxItem Content="Custom" />
+                        </ComboBox>
+                        <Label x:Name="StartLabel" Content="Starting" VerticalContentAlignment="Center" />
+                        <DatePicker x:Name="StartPicker" MinWidth="100" VerticalContentAlignment="Center"
+                                    IsEnabled="False" SelectedDateChanged="SelectedDateChanged" />
+                        <Label x:Name="EndLabel" Content="Ending" VerticalContentAlignment="Center" />
+                        <DatePicker x:Name="EndPicker" MinWidth="100" VerticalContentAlignment="Center"
+                                    SelectedDateChanged="SelectedDateChanged" />
+                        <Label x:Name="FutureLabel" Content="Include Future?" VerticalContentAlignment="Center" />
+                        <CheckBox x:Name="FutureTimes" VerticalContentAlignment="Center"
+                                  Checked="FutureTimes_Checked" Unchecked="FutureTimes_Checked" IsThreeState="False" />
+                        <Label x:Name="ApprovedLabel" Content="Approved Only?"
+                               VerticalContentAlignment="Center" />
+                        <CheckBox x:Name="ApprovedTimes" VerticalContentAlignment="Center"
+                                  Checked="ApprovedTimes_Checked" Unchecked="ApprovedTimes_Checked" IsThreeState="False" />
+                        <Label Content="Search" VerticalContentAlignment="Center" />
+                        <TextBox x:Name="Search" KeyUp="Search_KeyUp" />
+                    </DockPanel>
+                </Border>
+                <prs:TimesheetGrid x:Name="TimeSheets" Grid.Row="1" Margin="0,2,0,0"
+                                   OnReconfigure="TimeSheets_OnReconfigure"
+                                   OnSelectItem="TimeSheets_OnSelectItem"/>
             </Grid>
-        </Border>
-        <local:TimesheetGrid x:Name="TimeSheets" Grid.Row="1" Margin="0,2,0,0"
-                             OnReconfigure="TimeSheets_OnReconfigure"/>
-    </Grid>
+        </dg:DynamicSplitPanel.Master>
+        <dg:DynamicSplitPanel.DetailHeader>
+            <Border BorderBrush="Gray" Background="WhiteSmoke" BorderThickness="0.75">
+                <Label Content="Details" HorizontalContentAlignment="Center"/>
+            </Border>
+        </dg:DynamicSplitPanel.DetailHeader>
+        <dg:DynamicSplitPanel.Detail>
+            <Grid>
+                <Grid.RowDefinitions>
+                    <RowDefinition Height="*"/>
+                    <RowDefinition Height="Auto"/>
+                    <RowDefinition Height="*"/>
+                </Grid.RowDefinitions>
+                <local:TimesheetNotesGrid x:Name="Notes"
+                                          Grid.Row="0"/>
+                <sf:SfGridSplitter 
+                    Grid.Row="1" 
+                    Height="4"
+                    HorizontalAlignment="Stretch"
+                    Background="Transparent"
+                    ResizeBehavior="PreviousAndNext"
+                    Template="{StaticResource HorizontalSplitter}"
+                    PreviewStyle="{StaticResource HorizontalSplitterPreview}"/>
+                <local:TimesheetAssignmentGrid x:Name="Assignments"
+                                               Grid.Row="2"/>
+            </Grid>
+        </dg:DynamicSplitPanel.Detail>
+    </dg:DynamicSplitPanel>
 </UserControl>

+ 229 - 190
prs.desktop/Panels/Timesheets/TimesheetPanel.xaml.cs

@@ -11,243 +11,282 @@ using InABox.Configuration;
 using InABox.Core;
 using InABox.DynamicGrid;
 using InABox.Wpf;
+using PRS.Shared;
 
-namespace PRSDesktop
+namespace PRSDesktop;
+
+
+public class TimesheetGlobalSettings : BaseObject, IGlobalConfigurationSettings
+{
+    public int PageSize { get; set; } = 5000;
+}
+
+/// <summary>
+///     Interaction logic for TimesheetPanel.xaml
+/// </summary>
+public partial class TimesheetPanel : UserControl, IPanel<TimeSheet>
 {
+    private TimeSheetSettings _settings = new();
+    private TimesheetGlobalSettings _globalSettings = new();
     
-    public class TimesheetGlobalSettings : BaseObject, IGlobalConfigurationSettings
+    public TimesheetPanel()
     {
-        public int PageSize { get; set; } = 5000;
+        Task[] setup = new Task[]
+        {
+            Task.Run(() => _settings = new UserConfiguration<TimeSheetSettings>().Load()),
+            Task.Run(() => _globalSettings = new GlobalConfiguration<TimesheetGlobalSettings>().Load())
+        };
+        InitializeComponent();
+        Task.WaitAll(setup);
     }
-    
-    /// <summary>
-    ///     Interaction logic for TimesheetPanel.xaml
-    /// </summary>
-    public partial class TimesheetPanel : UserControl, IPanel<TimeSheet>
+
+    public event DataModelUpdateEvent? OnUpdateDataModel;
+
+    public bool IsReady { get; set; }
+
+    public void Setup()
+    {
+        LoadSettings();
+        TimeSheets.Reconfigure();
+        TimeSheets.Refresh(true, false);
+        Notes.Refresh(true, true);
+        Assignments.Refresh(true, true);
+    }
+
+    private void TimeSheets_OnReconfigure(DynamicGridOptions options)
+    {
+        options.PageSize = _globalSettings.PageSize;
+    }
+
+    public Dictionary<string, object[]> Selected()
     {
-        private TimeSheetSettings _settings = new();
-        private TimesheetGlobalSettings _globalSettings = new();
+        return new Dictionary<string, object[]> { { typeof(TimeSheet).EntityName(), TimeSheets.SelectedRows } };
+    }
+
+    public void Shutdown(CancelEventArgs? cancel)
+    {
+    }
+
+    public void CreateToolbarButtons(IPanelHost host)
+    {
+        HumanResourcesSetupActions.EmployeeActivities(host);
+        HumanResourcesSetupActions.EmployeeRosters(host);
+        host.CreateSetupSeparator();
+        HumanResourcesSetupActions.EmployeeOvertimeRules(host);
+        HumanResourcesSetupActions.EmployeeOvertime(host);
+        HumanResourcesSetupActions.EmployeeStandardLeave(host);
         
-        public TimesheetPanel()
-        {
-            Task[] setup = new Task[]
+        host.CreateSetupSeparator();
+        host.CreateSetupAction(new PanelAction() { Caption = "Timesheets Settings", Image = PRSDesktop.Resources.product, OnExecute =
+            (obj) =>
             {
-                Task.Run(() => _settings = new UserConfiguration<TimeSheetSettings>().Load()),
-                Task.Run(() => _globalSettings = new GlobalConfiguration<TimesheetGlobalSettings>().Load())
-            };
-            InitializeComponent();
-            Task.WaitAll(setup);
-        }
+                var grid = new DynamicItemsListGrid<TimesheetGlobalSettings>();
+                if (grid.EditItems(new TimesheetGlobalSettings[] { _globalSettings }))
+                {
+                    new GlobalConfiguration<TimesheetGlobalSettings>().Save(_globalSettings);
+                    TimeSheets.Reconfigure();
+                    Refresh();
+                }   
+                
+            }
+        });
 
-        public event DataModelUpdateEvent? OnUpdateDataModel;
+        host.CreatePanelAction(new PanelAction() { Caption = "Process Leave", Image = PRSDesktop.Resources.leave, OnExecute = ProcessLeave });
 
-        public bool IsReady { get; set; }
+        PostUtils.CreateToolbarButtons(host,
+            () => (DataModel(Selection.Selected) as IDataModel<TimeSheet>)!,
+            () => TimeSheets.Refresh(false, true),
+            true);
+    }
 
-        public void Setup()
-        {
-            LoadSettings();
-            TimeSheets.Reconfigure();
-            TimeSheets.Refresh(true, false);
-        }
+    private void ProcessLeave(PanelAction obj)
+    {
+        var processor = new TimeSheetLeaveProcessor(StartPicker.SelectedDate.Value, EndPicker.SelectedDate.Value);
+        if (processor.ShowDialog() == true)
+            TimeSheets.Refresh(false, true);
+    }
 
-        private void TimeSheets_OnReconfigure(DynamicGridOptions options)
-        {
-            options.PageSize = _globalSettings.PageSize;
-        }
+    public string SectionName => "Timesheets";
 
-        public Dictionary<string, object[]> Selected()
-        {
-            return new Dictionary<string, object[]> { { typeof(TimeSheet).EntityName(), TimeSheets.SelectedRows } };
-        }
+    public DataModel DataModel(Selection selection)
+    {
+        var ids = TimeSheets.ExtractValues(x => x.ID, selection).ToArray();
+        return new BaseDataModel<TimeSheet>(new Filter<TimeSheet>(x => x.ID).InList(ids.ToArray()));
+    }
 
-        public void Shutdown(CancelEventArgs? cancel)
+    private void TimeSheets_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
+    {
+        if(e.Rows is null || e.Rows.Length != 1)
         {
-        }
+            Notes.EmployeeID = Guid.Empty;
+            Assignments.EmployeeID = Guid.Empty;
 
-        public void CreateToolbarButtons(IPanelHost host)
-        {
-            HumanResourcesSetupActions.EmployeeActivities(host);
-            HumanResourcesSetupActions.EmployeeRosters(host);
-            host.CreateSetupSeparator();
-            HumanResourcesSetupActions.EmployeeOvertimeRules(host);
-            HumanResourcesSetupActions.EmployeeOvertime(host);
-            HumanResourcesSetupActions.EmployeeStandardLeave(host);
-            
-            host.CreateSetupSeparator();
-            host.CreateSetupAction(new PanelAction() { Caption = "Timesheets Settings", Image = PRSDesktop.Resources.product, OnExecute =
-                (obj) =>
-                {
-                    var grid = new DynamicItemsListGrid<TimesheetGlobalSettings>();
-                    if (grid.EditItems(new TimesheetGlobalSettings[] { _globalSettings }))
-                    {
-                        new GlobalConfiguration<TimesheetGlobalSettings>().Save(_globalSettings);
-                        TimeSheets.Reconfigure();
-                        Refresh();
-                    }   
-                    
-                }
-            });
-
-            host.CreatePanelAction(new PanelAction() { Caption = "Process Leave", Image = PRSDesktop.Resources.leave, OnExecute = ProcessLeave });
-
-            PostUtils.CreateToolbarButtons(host,
-                () => (DataModel(Selection.Selected) as IDataModel<TimeSheet>)!,
-                () => TimeSheets.Refresh(false, true),
-                true);
+            Notes.Refresh(false, true);
+            Assignments.Refresh(false, true);
         }
-
-        private void ProcessLeave(PanelAction obj)
+        else
         {
-            var processor = new TimeSheetLeaveProcessor(StartPicker.SelectedDate.Value, EndPicker.SelectedDate.Value);
-            if (processor.ShowDialog() == true)
-                TimeSheets.Refresh(false, true);
+            var item = e.Rows[0].ToObject<TimeSheet>();
+            Notes.EmployeeID = item.EmployeeLink.ID;
+            Notes.Date = item.Date.Date;
+            Assignments.EmployeeID = item.EmployeeLink.ID;
+            Assignments.Date = item.Date.Date;
+
+            Notes.Refresh(false, true);
+            Assignments.Refresh(false, true);
         }
+    }
 
-        public string SectionName => "Timesheets";
+    public void Refresh()
+    {
+        TimeSheets.StartDate = StartPicker.SelectedDate.Value;
 
-        public DataModel DataModel(Selection selection)
-        {
-            var ids = TimeSheets.ExtractValues(x => x.ID, selection).ToArray();
-            return new BaseDataModel<TimeSheet>(new Filter<TimeSheet>(x => x.ID).InList(ids.ToArray()));
-        }
+        if (FutureTimes.IsChecked == true)
+            TimeSheets.EndDate = EndPicker.SelectedDate.Value;
+        else
+            TimeSheets.EndDate = EndPicker.SelectedDate.Value > DateTime.Today ? DateTime.Today : EndPicker.SelectedDate.Value;
 
-        public void Refresh()
-        {
-            TimeSheets.StartDate = StartPicker.SelectedDate.Value;
+        TimeSheets.Search = Search.Text;
 
-            if (FutureTimes.IsChecked == true)
-                TimeSheets.EndDate = EndPicker.SelectedDate.Value;
-            else
-                TimeSheets.EndDate = EndPicker.SelectedDate.Value > DateTime.Today ? DateTime.Today : EndPicker.SelectedDate.Value;
+        TimeSheets.ApprovedOnly = ApprovedTimes.IsChecked == true;
 
-            TimeSheets.Search = Search.Text;
+        TimeSheets.Refresh(false, true);
+        Notes.Refresh(false, true);
+        Assignments.Refresh(false, true);
+    }
 
-            TimeSheets.ApprovedOnly = ApprovedTimes.IsChecked == true;
+    public void Heartbeat(TimeSpan time)
+    {
+    }
 
-            TimeSheets.Refresh(false, true);
-        }
+    private void LoadSettings()
+    {
+        _settings = new UserConfiguration<TimeSheetSettings>().Load();
+        StartPicker.SelectedDate = _settings.StartDate;
+        EndPicker.SelectedDate = _settings.EndDate;
+        View.SelectedIndex = _settings.View;
+        UpdateStartFinishDates();
+        FutureTimes.IsChecked = _settings.FutureTimes;
+        ApprovedTimes.IsChecked = _settings.ApprovedOnly;
+
+        SplitPanel.AnchorWidth = _settings.AnchorWidth;
+        SplitPanel.View = _settings.ViewType.ToSplitPanelView();
+    }
 
-        public void Heartbeat(TimeSpan time)
+    private void SaveSettings()
+    {
+        if (IsReady)
         {
+            _settings.View = View.SelectedIndex;
+            _settings.StartDate = StartPicker.SelectedDate.HasValue ? StartPicker.SelectedDate.Value : DateTime.Today;
+            _settings.EndDate = EndPicker.SelectedDate.HasValue ? EndPicker.SelectedDate.Value : DateTime.Today;
+            _settings.FutureTimes = FutureTimes.IsChecked == true;
+            _settings.ApprovedOnly = ApprovedTimes.IsChecked == true;
+
+            _settings.AnchorWidth = SplitPanel.AnchorWidth;
+            _settings.ViewType = SplitPanel.View.ToScreenViewType();
+
+            new UserConfiguration<TimeSheetSettings>().Save(_settings);
         }
+    }
+    private void UpdateStartEndPicker(DateTime start, DateTime end)
+    {
+        if (StartPicker == null || EndPicker == null)
+            return;
+
+        StartPicker.IsEnabled = false;
+        EndPicker.IsEnabled = false;
+        StartPicker.SelectedDate = start;
+        EndPicker.SelectedDate = end;
+    }
 
-        private void LoadSettings()
+    private void View_SelectionChanged(object sender, SelectionChangedEventArgs e)
+    {
+        UpdateStartFinishDates();
+    }
+
+    private void UpdateStartFinishDates()
+    {
+        if (View.SelectedIndex == 0)
         {
-            _settings = new UserConfiguration<TimeSheetSettings>().Load();
-            StartPicker.SelectedDate = _settings.StartDate;
-            EndPicker.SelectedDate = _settings.EndDate;
-            View.SelectedIndex = _settings.View;
-            UpdateStartFinishDates();
-            FutureTimes.IsChecked = _settings.FutureTimes;
-            ApprovedTimes.IsChecked = _settings.ApprovedOnly;
+            UpdateStartEndPicker(DateTime.Today, DateTime.Today);
         }
-
-        private void SaveSettings()
+        else if (View.SelectedIndex == 1)
         {
-            if (IsReady)
-            {
-                _settings.View = View.SelectedIndex;
-                _settings.StartDate = StartPicker.SelectedDate.HasValue ? StartPicker.SelectedDate.Value : DateTime.Today;
-                _settings.EndDate = EndPicker.SelectedDate.HasValue ? EndPicker.SelectedDate.Value : DateTime.Today;
-                _settings.FutureTimes = FutureTimes.IsChecked == true;
-                _settings.ApprovedOnly = ApprovedTimes.IsChecked == true;
-                new UserConfiguration<TimeSheetSettings>().Save(_settings);
-            }
+            UpdateStartEndPicker(DateTime.Today.AddDays(0 - 1), DateTime.Today.AddDays(0 - 1));
         }
-        private void UpdateStartEndPicker(DateTime start, DateTime end)
+        else if (View.SelectedIndex == 2)
         {
-            if (StartPicker == null || EndPicker == null)
-                return;
-
-            StartPicker.IsEnabled = false;
-            EndPicker.IsEnabled = false;
-            StartPicker.SelectedDate = start;
-            EndPicker.SelectedDate = end;
+            UpdateStartEndPicker(DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek).AddDays(1),
+                DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek).AddDays(7));
         }
-
-        private void View_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        else if (View.SelectedIndex == 3)
         {
-            UpdateStartFinishDates();
+            UpdateStartEndPicker(DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek).AddDays(0 - 6),
+                DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek));
         }
-
-        private void UpdateStartFinishDates()
+        else if (View.SelectedIndex == 4)
         {
-            if (View.SelectedIndex == 0)
-            {
-                UpdateStartEndPicker(DateTime.Today, DateTime.Today);
-            }
-            else if (View.SelectedIndex == 1)
-            {
-                UpdateStartEndPicker(DateTime.Today.AddDays(0 - 1), DateTime.Today.AddDays(0 - 1));
-            }
-            else if (View.SelectedIndex == 2)
-            {
-                UpdateStartEndPicker(DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek).AddDays(1),
-                    DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek).AddDays(7));
-            }
-            else if (View.SelectedIndex == 3)
-            {
-                UpdateStartEndPicker(DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek).AddDays(0 - 6),
-                    DateTime.Today.AddDays(0 - (double)DateTime.Today.DayOfWeek));
-            }
-            else if (View.SelectedIndex == 4)
-            {
-                UpdateStartEndPicker(new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1),
-                    new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(1).AddDays(0 - 1));
-            }
-            else if (View.SelectedIndex == 5)
-            {
-                UpdateStartEndPicker(new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(0 - 1),
-                    new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddDays(0 - 1));
-            }
-            else if (View.SelectedIndex == 6)
-            {
-                UpdateStartEndPicker(new DateTime(DateTime.Today.Year, 1, 1), new DateTime(DateTime.Today.Year, 1, 1).AddYears(1).AddDays(0 - 1));
-            }
-            else if (View.SelectedIndex == 7)
-            {
-                UpdateStartEndPicker(new DateTime(DateTime.Today.Year, 1, 1).AddYears(0 - 1), new DateTime(DateTime.Today.Year, 1, 1).AddDays(0 - 1));
-            }
-            else
-            {
-                StartPicker.IsEnabled = true;
-                EndPicker.IsEnabled = true;
-            }
-
-            if (!IsReady)
-                return;
-            SaveSettings();
-            Refresh();
+            UpdateStartEndPicker(new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1),
+                new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(1).AddDays(0 - 1));
         }
-
-        private void SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+        else if (View.SelectedIndex == 5)
         {
-            if (!StartPicker.IsEnabled || !EndPicker.IsEnabled || !IsReady)
-                return;
-            SaveSettings();
-            Refresh();
+            UpdateStartEndPicker(new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(0 - 1),
+                new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddDays(0 - 1));
         }
-
-        private void Search_KeyUp(object sender, KeyEventArgs e)
+        else if (View.SelectedIndex == 6)
         {
-            if (e.Key == Key.Enter || e.Key == Key.Return)
-                Refresh();
+            UpdateStartEndPicker(new DateTime(DateTime.Today.Year, 1, 1), new DateTime(DateTime.Today.Year, 1, 1).AddYears(1).AddDays(0 - 1));
         }
-
-        private void FutureTimes_Checked(object sender, RoutedEventArgs e)
+        else if (View.SelectedIndex == 7)
         {
-            if (!IsReady)
-                return;
-            SaveSettings();
-            Refresh();
+            UpdateStartEndPicker(new DateTime(DateTime.Today.Year, 1, 1).AddYears(0 - 1), new DateTime(DateTime.Today.Year, 1, 1).AddDays(0 - 1));
         }
-
-        private void ApprovedTimes_Checked(object sender, RoutedEventArgs e)
+        else
         {
-            if (!IsReady)
-                return;
-            SaveSettings();
-            Refresh();
+            StartPicker.IsEnabled = true;
+            EndPicker.IsEnabled = true;
         }
+
+        if (!IsReady)
+            return;
+        SaveSettings();
+        Refresh();
+    }
+
+    private void SelectedDateChanged(object sender, SelectionChangedEventArgs e)
+    {
+        if (!StartPicker.IsEnabled || !EndPicker.IsEnabled || !IsReady)
+            return;
+        SaveSettings();
+        Refresh();
+    }
+
+    private void Search_KeyUp(object sender, KeyEventArgs e)
+    {
+        if (e.Key == Key.Enter || e.Key == Key.Return)
+            Refresh();
+    }
+
+    private void FutureTimes_Checked(object sender, RoutedEventArgs e)
+    {
+        if (!IsReady)
+            return;
+        SaveSettings();
+        Refresh();
+    }
+
+    private void ApprovedTimes_Checked(object sender, RoutedEventArgs e)
+    {
+        if (!IsReady)
+            return;
+        SaveSettings();
+        Refresh();
+    }
+
+    private void SplitPanel_OnChanged(object sender, DynamicSplitPanelSettings e)
+    {
+        SaveSettings();
     }
 }

+ 34 - 0
prs.shared/Utilities/WpfUtilities.cs

@@ -0,0 +1,34 @@
+using Comal.Classes;
+using InABox.DynamicGrid;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PRS.Shared;
+
+public static class WpfUtilities
+{
+    public static DynamicSplitPanelView ToSplitPanelView(this ScreenViewType viewType)
+    {
+        return viewType switch
+        {
+            ScreenViewType.Register => DynamicSplitPanelView.Master,
+            ScreenViewType.Details => DynamicSplitPanelView.Detail,
+            ScreenViewType.Combined => DynamicSplitPanelView.Combined,
+            _ => DynamicSplitPanelView.Master
+        };
+    }
+
+    public static ScreenViewType ToScreenViewType(this DynamicSplitPanelView view)
+    {
+        return view switch
+        {
+            DynamicSplitPanelView.Master => ScreenViewType.Register,
+            DynamicSplitPanelView.Detail => ScreenViewType.Details,
+            DynamicSplitPanelView.Combined => ScreenViewType.Combined,
+            _ => ScreenViewType.Register
+        };
+    }
+}