Manuális lezárás indokkal
This commit is contained in:
@@ -117,6 +117,18 @@
|
||||
|
||||
<!-- Jobb oldali oszlop: Két gomb egymás mellett -->
|
||||
<HorizontalStackLayout Grid.Column="1" HorizontalOptions="End" Spacing="3">
|
||||
<Button Text="L"
|
||||
Margin="0,0,0,0"
|
||||
BackgroundColor="DarkOrange"
|
||||
HeightRequest="50"
|
||||
MaximumHeightRequest="50"
|
||||
WidthRequest="50"
|
||||
MaximumWidthRequest="50"
|
||||
CornerRadius="25"
|
||||
IsVisible="{Binding CheckStatus, Converter={StaticResource CloseConverter}}"
|
||||
Command="{Binding BindingContext.CloseCommand, Source={x:Reference CheckList}}"
|
||||
CommandParameter="{Binding .}">
|
||||
</Button>
|
||||
<Button Text=""
|
||||
Margin="0,0,0,0"
|
||||
ImageSource="arrow_down.svg"
|
||||
@@ -238,6 +250,7 @@
|
||||
<local:UnBlockedConverter x:Key="UnBlockedConverter" />
|
||||
<local:ContinueConverter x:Key="ContinueConverter" />
|
||||
<local:AcceptConverter x:Key="AcceptConverter" />
|
||||
<local:CloseConverter x:Key="CloseConverter" />
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
</ContentPage>
|
||||
@@ -9,6 +9,7 @@ using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.Common.Enums;
|
||||
using WorkFlowCheck.MAUI.Helper;
|
||||
using WorkFlowCheck.MAUI.Pages.NFC;
|
||||
using WorkFlowCheck.MAUI.Pages.System;
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Pages.CheckList;
|
||||
@@ -28,6 +29,7 @@ public partial class CheckListPage : ContentPage
|
||||
public ICommand BlockCommand { get; set; }
|
||||
public ICommand AcceptCommand { get; set; }
|
||||
public ICommand InfoCommand { get; set; }
|
||||
public ICommand CloseCommand { get; set; }
|
||||
public ICommand RefreshCommand { get; }
|
||||
|
||||
public bool IsLoading
|
||||
@@ -75,6 +77,7 @@ public partial class CheckListPage : ContentPage
|
||||
BlockCommand = new Command<CheckListHeaderDTO>(OnBlockItem);
|
||||
AcceptCommand = new Command<CheckListHeaderDTO>(OnAcceptItem);
|
||||
InfoCommand = new Command<CheckListHeaderDTO>(OnInfoItem);
|
||||
CloseCommand = new Command<CheckListHeaderDTO>(OnCloseItem);
|
||||
RefreshCommand = new Command(async () => await OnRefresh());
|
||||
|
||||
}
|
||||
@@ -285,6 +288,43 @@ public partial class CheckListPage : ContentPage
|
||||
}
|
||||
}
|
||||
}
|
||||
private async void OnCloseItem(CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
var popup = new InputPopup("Kérem adja meg a lezárás okát!");
|
||||
var (isConfirmed, userInput) = await popup.ShowAsync();
|
||||
|
||||
|
||||
if (isConfirmed && !string.IsNullOrEmpty(userInput))
|
||||
{
|
||||
var checkListHeaderCloseDTO = new CheckListHeaderCloseDTO()
|
||||
{
|
||||
Id = checkListHeaderDTO.Id,
|
||||
CloseReason = userInput,
|
||||
UserId = _userService.GetCurrentUser().Id
|
||||
};
|
||||
var success = await _checkListService.CloseCheckListHeader(checkListHeaderCloseDTO);
|
||||
if (success)
|
||||
{
|
||||
IsRefreshing = true;
|
||||
await LoadCheckList();
|
||||
IsRefreshing = false;
|
||||
await SystemHelper.ShowSnackBar("Lezárás sikeres!",
|
||||
SystemHelper.ColorToHex(Colors.Green),
|
||||
SystemHelper.ColorToHex(Colors.Green),
|
||||
SystemHelper.ColorToHex(Colors.White),
|
||||
5);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
await SystemHelper.ShowSnackBar("Lezárás SIKERTELEN!",
|
||||
SystemHelper.ColorToHex(Colors.Red),
|
||||
SystemHelper.ColorToHex(Colors.Red),
|
||||
SystemHelper.ColorToHex(Colors.Yellow),
|
||||
15);
|
||||
}
|
||||
}
|
||||
}
|
||||
private async void OnAcceptItem(CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
bool answer = await DisplayAlert("Megerõsítés", "Biztosan jóváhagyod a folyamatot?", "Igen", "Mégsem");
|
||||
@@ -378,6 +418,31 @@ public class BlockedConverter : IValueConverter
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class CloseConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var canEnableBlocked = false;
|
||||
foreach (var roleDTO in SystemHelper.SystemUserDTO.RoleDTO)
|
||||
{
|
||||
if (roleDTO.CanEnableBlocked)
|
||||
{
|
||||
canEnableBlocked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value is CheckStatus status && canEnableBlocked)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class UnBlockedConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
|
||||
xmlns:popups="clr-namespace:WorkFlowCheck.MAUI.Pages.System"
|
||||
x:Class="WorkFlowCheck.MAUI.Pages.System.InputPopup">
|
||||
|
||||
<toolkit:Popup.Resources>
|
||||
<Style TargetType="{x:Type popups:InputPopup}">
|
||||
<Setter Property="Size" Value="400,150" />
|
||||
<Setter Property="HorizontalOptions" Value="Center" />
|
||||
<Setter Property="VerticalOptions" Value="Start" />
|
||||
<Setter Property="CanBeDismissedByTappingOutsideOfPopup" Value="True" />
|
||||
</Style>
|
||||
</toolkit:Popup.Resources>
|
||||
<VerticalStackLayout Padding="20" Spacing="10">
|
||||
<Label x:Name="UserConfirmationLabel" />
|
||||
<Entry x:Name="UserInputEntry" />
|
||||
<HorizontalStackLayout HorizontalOptions="End" Spacing="10">
|
||||
<Button Text="Mégsem" Clicked="OnCancelClicked" />
|
||||
<Button Text="Megerősít" Clicked="OnOkClicked" />
|
||||
</HorizontalStackLayout>
|
||||
</VerticalStackLayout>
|
||||
|
||||
</toolkit:Popup>
|
||||
@@ -0,0 +1,42 @@
|
||||
using CommunityToolkit.Maui.Core;
|
||||
using CommunityToolkit.Maui.Views;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Pages.System;
|
||||
|
||||
public partial class InputPopup : Popup
|
||||
{
|
||||
private TaskCompletionSource<(bool IsConfirmed, string Result)> _taskCompletionSource;
|
||||
public InputPopup(string userConfirmationLabel)
|
||||
{
|
||||
InitializeComponent();
|
||||
_taskCompletionSource = new();
|
||||
UserConfirmationLabel.Text = userConfirmationLabel;
|
||||
this.Closed += OnPopupClosed;
|
||||
}
|
||||
public Task<(bool IsConfirmed, string Result)> ShowAsync()
|
||||
{
|
||||
Application.Current.MainPage.ShowPopup(this);
|
||||
return _taskCompletionSource.Task;
|
||||
}
|
||||
private void OnOkClicked(object sender, EventArgs e)
|
||||
{
|
||||
Close((true, UserInputEntry.Text));
|
||||
}
|
||||
|
||||
private void OnCancelClicked(object sender, EventArgs e)
|
||||
{
|
||||
Close((false, ""));
|
||||
}
|
||||
private void OnPopupClosed(object sender, PopupClosedEventArgs e)
|
||||
{
|
||||
if (e?.Result is ValueTuple<bool, string> value)
|
||||
{
|
||||
_taskCompletionSource.TrySetResult(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_taskCompletionSource.TrySetResult((false, null));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -239,6 +239,42 @@ namespace WorkFlowCheck.MAUI.Services
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> CloseCheckListHeader(CheckListHeaderCloseDTO checkListHeaderCloseDTO)
|
||||
{
|
||||
var retVal = false;
|
||||
try
|
||||
{
|
||||
var checkListHeader = await _dbContext.CheckListHeaders
|
||||
.Where(w => w.Id == checkListHeaderCloseDTO.Id)
|
||||
.FirstOrDefaultAsync();
|
||||
if (checkListHeader != null)
|
||||
{
|
||||
var userDTO = _userService.GetCurrentUser();
|
||||
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/CloseCheckListHeader";
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, checkListHeaderCloseDTO))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<ApiResponseDTO<bool>>(jsonString);
|
||||
if (response != null)
|
||||
{
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
checkListHeader.CheckStatus = CheckStatus.Closed;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<bool> AcceptCheckListHeader(CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
var retVal = false;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace WorkFlowCheck.MAUI.Services.Interfaces
|
||||
|
||||
Task<bool> UnBlockCheckListHeader(CheckListHeaderDTO checkListHeaderDTO);
|
||||
Task<bool> BlockCheckListHeader(CheckListHeaderDTO checkListHeaderDTO);
|
||||
Task<bool> CloseCheckListHeader(CheckListHeaderCloseDTO checkListHeaderCloseDTO);
|
||||
Task<bool> AcceptCheckListHeader(CheckListHeaderDTO checkListHeaderDTO);
|
||||
Task<CheckPointDTO> GetNextCheckpointNotSend(CheckListHeaderDTO checkListHeaderDTO);
|
||||
}
|
||||
|
||||
@@ -157,6 +157,9 @@
|
||||
<MauiXaml Update="Pages\System\DownloadAPKPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
<MauiXaml Update="Pages\System\InputPopup.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
<MauiXaml Update="Pages\System\SyncPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</MauiXaml>
|
||||
|
||||
Reference in New Issue
Block a user