|
@@ -1,6 +1,95 @@
|
|
|
+using Avalonia.Controls;
|
|
|
+using Avalonia.Media;
|
|
|
+using Comal.Classes;
|
|
|
+using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
+using CommunityToolkit.Mvvm.Input;
|
|
|
+using InABox.Avalonia.Components;
|
|
|
+using InABox.Core;
|
|
|
+using System;
|
|
|
+using System.Collections;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
namespace PRS.Avalonia.Modules;
|
|
|
|
|
|
-public class InOutViewModel : ModuleViewModel
|
|
|
+public partial class InOutViewModel : ModuleViewModel
|
|
|
{
|
|
|
public override string Title => "In/Out";
|
|
|
+
|
|
|
+ [ObservableProperty]
|
|
|
+ private AvaloniaDataGridColumns _columns;
|
|
|
+
|
|
|
+ [ObservableProperty]
|
|
|
+ private IEnumerable? _itemsSource;
|
|
|
+
|
|
|
+ [ObservableProperty]
|
|
|
+ private DateTime _lastUpdated;
|
|
|
+
|
|
|
+ [ObservableProperty]
|
|
|
+ private InOutModel _model;
|
|
|
+
|
|
|
+ public InOutViewModel()
|
|
|
+ {
|
|
|
+ ProgressVisible = true;
|
|
|
+
|
|
|
+ Columns = new AvaloniaDataGridColumns().BeginUpdate();
|
|
|
+ if (!Security.IsAllowed<CanViewMobileInOutBoardDetails>())
|
|
|
+ {
|
|
|
+ Columns.Add(new AvaloniaDataGridImageColumn<InOutShell>()
|
|
|
+ {
|
|
|
+ Column = x => x.In,
|
|
|
+ Caption = "In?",
|
|
|
+ // Header = circle_gray
|
|
|
+ // Margin = 6
|
|
|
+ Width = new GridLength(30),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ Columns.Add(new AvaloniaDataGridTextColumn<InOutShell>
|
|
|
+ {
|
|
|
+ Column = x => x.Name,
|
|
|
+ Alignment = TextAlignment.Start,
|
|
|
+ Width = GridLength.Star
|
|
|
+ });
|
|
|
+ if (Security.IsAllowed<CanViewMobileInOutBoardDetails>())
|
|
|
+ {
|
|
|
+ Columns.Add(new AvaloniaDataGridTimeColumn<InOutShell> { Column = x => x.Start, Width = new(50) });
|
|
|
+ Columns.Add(new AvaloniaDataGridTimeColumn<InOutShell> { Column = x => x.Finish, Width = new(50) });
|
|
|
+ }
|
|
|
+
|
|
|
+ Columns.Add(new AvaloniaDataGridImageColumn<InOutShell>()
|
|
|
+ {
|
|
|
+ Column = x => x.Call,
|
|
|
+ Caption = "Call",
|
|
|
+ Width = new GridLength(30),
|
|
|
+ Tapped = CallEmployee
|
|
|
+ // Margin = 6
|
|
|
+ // Header = phone
|
|
|
+ });
|
|
|
+
|
|
|
+ Columns.EndUpdate();
|
|
|
+
|
|
|
+ Model = new InOutModel(DataAccess,
|
|
|
+ () => new Filters<Employee>()
|
|
|
+ .Add(LookupFactory.DefineFilter<Employee>())
|
|
|
+ .Add(new Filter<Employee>(x => x.ID).IsNotEqualTo(Repositories.Me.ID).And(x => x.ShowOnInOutBoard).IsEqualTo(true))
|
|
|
+ .Combine() ?? new Filter<Employee>().All());
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override async Task<TimeSpan> OnRefresh()
|
|
|
+ {
|
|
|
+ await Refresh();
|
|
|
+ return TimeSpan.Zero;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CallEmployee(IAvaloniaDataGridColumn column, object? arg2)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ [RelayCommand]
|
|
|
+ private async Task Refresh()
|
|
|
+ {
|
|
|
+ await Model.RefreshAsync(true);
|
|
|
+ ItemsSource = Model.Items;
|
|
|
+ LastUpdated = Model.LastUpdated;
|
|
|
+ ProgressVisible = false;
|
|
|
+ }
|
|
|
}
|