CheckListInfoPage implementálása

This commit is contained in:
2025-05-22 21:02:09 +02:00
parent 254ab86d03
commit 05259a09ee
7 changed files with 216 additions and 54 deletions
@@ -22,5 +22,7 @@ namespace WorkFlowCheck.Common.DTO
[DisplayName("Ellenőrzési pontok száma")] [DisplayName("Ellenőrzési pontok száma")]
public int CheckPointCount { get; set; } public int CheckPointCount { get; set; }
} }
} }
@@ -19,7 +19,7 @@ namespace WorkFlowCheck.MAUI.Helper
public static string DatabaseName = ""; public static string DatabaseName = "";
public static bool Syncronised = false; public static bool Syncronised = false;
public static UserDTO SystemUserDTO; public static UserDTO SystemUserDTO;
public static string ProgramVersion = "v1.1.023"; public static string ProgramVersion = "v1.1.024";
#if DEBUG #if DEBUG
public static string ApiBaseUrl = $"https://dev.wfcapi.nuvolar.hu/"; public static string ApiBaseUrl = $"https://dev.wfcapi.nuvolar.hu/";
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WorkFlowCheck.MAUI.Pages.CheckList.CheckListInfoPage"
Title="CheckListInfoPage">
<Shell.TitleView>
<Grid Padding="2" VerticalOptions="Center">
<Label x:Name="HeaderLabel" Text=""
FontSize="22"
FontAttributes="Bold"
VerticalOptions="Center"
HorizontalOptions="Start" />
<HorizontalStackLayout
VerticalOptions="Center"
HorizontalOptions="End"
Spacing="5">
<Frame CornerRadius="1"
Padding="5"
HasShadow="True"
VerticalOptions="Center"
HorizontalOptions="End">
<Label x:Name="DeviceId"
FontSize="10"
TextColor="Black"/>
</Frame>
<Frame CornerRadius="1"
Padding="5"
HasShadow="True"
VerticalOptions="Center"
HorizontalOptions="End">
<Label x:Name="UserInfo"
FontSize="10"
FontAttributes="Bold"
TextColor="Black"/>
</Frame>
</HorizontalStackLayout>
</Grid>
</Shell.TitleView>
<Grid RowDefinitions="*" Padding="30,30">
<Frame Grid.Row="0"
BorderColor="Gray"
Padding="5"
Margin="1"
CornerRadius="10"
HasShadow="True">
<StackLayout Grid.Column="1" Spacing="2">
<Label x:Name="row1" FontSize="20" FontAttributes="Bold" />
<Label x:Name="row2" Text="B" FontSize="20" />
<Label x:Name="row3" Text="C" FontSize="20" />
<Label x:Name="row4" Text="D" FontSize="20" />
<Label x:Name="row5" Text="D" FontSize="25" FontAttributes="Bold"/>
</StackLayout>
</Frame>
</Grid>
</ContentPage>
@@ -0,0 +1,71 @@
using Android.DeviceLock;
using Firebase.Auth;
using System.Globalization;
using System.Threading.Tasks;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Services.Interfaces;
namespace WorkFlowCheck.MAUI.Pages.CheckList;
public partial class CheckListInfoPage : ContentPage
{
private readonly ICheckListService _checkListService;
private readonly IUserService _userService;
private UserDTO _currentUser;
private CheckListHeaderDTO _checkListHeaderDTO;
private CheckListHeaderInfoDTO _checkListHeaderInfoDTO;
public CheckListInfoPage(CheckListHeaderDTO checkListHeaderDTO)
{
InitializeComponent();
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
_checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>();
_checkListHeaderDTO = checkListHeaderDTO;
}
private async Task SetInfo()
{
_currentUser = _userService.GetCurrentUser();
DeviceId.Text = _userService.DeviceId;
UserInfo.Text = $"{_currentUser?.LastName} {_currentUser?.FirstName}";
HeaderLabel.Text = _checkListHeaderDTO.DocumentNumber;
}
protected override async void OnAppearing()
{
base.OnAppearing();
BindingContext = this;
await SetInfo();
BuildCheckListHeaderInfo();
}
private async Task BuildCheckListHeaderInfo()
{
_checkListHeaderInfoDTO = new CheckListHeaderInfoDTO();
var result = _checkListHeaderDTO.CheckListRowDTO
.GroupBy(r => 1)
.Select(g => new
{
TotalRowCount = g.Count(),
EmptyAnswerCount = g.Count(r => string.IsNullOrEmpty(r.Answer)),
CheckPointCount = g.Select(r => r.CheckListTemplateRowDTO.CheckPointId).Distinct().Count()
})
.FirstOrDefault();
if (result != null)
{
_checkListHeaderInfoDTO.TotalRowCount = result.TotalRowCount;
_checkListHeaderInfoDTO.CheckPointCount = result.CheckPointCount;
_checkListHeaderInfoDTO.EmptyAnswerCount = result.EmptyAnswerCount;
if (_checkListHeaderInfoDTO.TotalRowCount > 0)
{
_checkListHeaderInfoDTO.ReadyPercent = ((double)(_checkListHeaderInfoDTO.TotalRowCount - _checkListHeaderInfoDTO.EmptyAnswerCount) / _checkListHeaderInfoDTO.TotalRowCount * 100)
.ToString("0.00", new CultureInfo("hu-HU")) + " %";
}
}
var checkPointDTO = await _checkListService.GetNextCheckpointNotSend(_checkListHeaderDTO);
row1.Text = $"Összes ellenõrizendõ lépés: {_checkListHeaderInfoDTO.TotalRowCount} db";
row2.Text = $"Összes még nem ellenõrzött lépés: {_checkListHeaderInfoDTO.EmptyAnswerCount} db";
row3.Text = $"Ellenõrzési pontok száma: {_checkListHeaderInfoDTO.CheckPointCount} db";
row4.Text = $"Készültség: {_checkListHeaderInfoDTO.ReadyPercent}";
row5.Text = $"Következõ ellenõrzési pont : {checkPointDTO.ShortName}";
}
}
@@ -82,13 +82,38 @@
<DataTemplate> <DataTemplate>
<Frame BorderColor="Gray" Padding="15" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke"> <Frame BorderColor="Gray" Padding="15" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
<Grid ColumnDefinitions="*,Auto"> <Grid ColumnDefinitions="*,Auto">
<!-- Bal oldali oszlop: Két Label egymás alatt --> <Grid ColumnSpacing="10">
<StackLayout Grid.Column="0" Spacing="2"> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Bal oldali gomb -->
<Button Grid.Column="0"
VerticalOptions="Center"
Text="i"
FontSize="17"
FontAttributes="Bold"
BackgroundColor="Purple"
HeightRequest="40"
WidthRequest="40"
CornerRadius="20"
BorderColor="Gray"
BorderWidth="1"
Command="{Binding BindingContext.InfoCommand, Source={x:Reference CheckList}}"
CommandParameter="{Binding .}" />
<!-- Jobb oldali szövegek -->
<StackLayout Grid.Column="1" Spacing="2">
<Label Text="{Binding DocumentNumber}" FontSize="14" FontAttributes="Bold" /> <Label Text="{Binding DocumentNumber}" FontSize="14" FontAttributes="Bold" />
<Label Text="{Binding DateExecution}" FontSize="12" /> <Label Text="{Binding DateExecution}" FontSize="12" />
<Label Text="{Binding CheckListTemplateHeaderDTO.ShortName}" FontSize="10" /> <Label Text="{Binding CheckListTemplateHeaderDTO.ShortName}" FontSize="10" />
<Label Text="{Binding StatusName}" FontSize="10" /> <Label Text="{Binding StatusName}" FontSize="10" />
</StackLayout> </StackLayout>
</Grid>
<!-- Jobb oldali oszlop: Két gomb egymás mellett --> <!-- Jobb oldali oszlop: Két gomb egymás mellett -->
<HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" Spacing="3"> <HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" Spacing="3">
@@ -27,6 +27,7 @@ public partial class CheckListPage : ContentPage
public ICommand UnblockCommand { get; set; } public ICommand UnblockCommand { get; set; }
public ICommand BlockCommand { get; set; } public ICommand BlockCommand { get; set; }
public ICommand AcceptCommand { get; set; } public ICommand AcceptCommand { get; set; }
public ICommand InfoCommand { get; set; }
public ICommand RefreshCommand { get; } public ICommand RefreshCommand { get; }
public bool IsLoading public bool IsLoading
@@ -73,6 +74,7 @@ public partial class CheckListPage : ContentPage
UnblockCommand = new Command<CheckListHeaderDTO>(OnUnblockItem); UnblockCommand = new Command<CheckListHeaderDTO>(OnUnblockItem);
BlockCommand = new Command<CheckListHeaderDTO>(OnBlockItem); BlockCommand = new Command<CheckListHeaderDTO>(OnBlockItem);
AcceptCommand = new Command<CheckListHeaderDTO>(OnAcceptItem); AcceptCommand = new Command<CheckListHeaderDTO>(OnAcceptItem);
InfoCommand = new Command<CheckListHeaderDTO>(OnInfoItem);
RefreshCommand = new Command(async () => await OnRefresh()); RefreshCommand = new Command(async () => await OnRefresh());
} }
@@ -311,6 +313,10 @@ public partial class CheckListPage : ContentPage
} }
} }
} }
private async void OnInfoItem(CheckListHeaderDTO checkListHeaderDTO)
{
await Navigation.PushAsync(new CheckListInfoPage(checkListHeaderDTO));
}
private async Task LoadCheckListTemplate() private async Task LoadCheckListTemplate()
{ {
IsLoading = true; IsLoading = true;
@@ -130,6 +130,9 @@
<MauiXaml Update="Pages\BaseStock\Locations\LocationsPage.xaml"> <MauiXaml Update="Pages\BaseStock\Locations\LocationsPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>
<MauiXaml Update="Pages\CheckList\CheckListInfoPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\CheckList\CheckListPage.xaml"> <MauiXaml Update="Pages\CheckList\CheckListPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</MauiXaml> </MauiXaml>