Fix posizione
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
@using System.Globalization
|
||||
@using System.Text.RegularExpressions
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using Java.Util.Jar
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@@ -123,9 +124,18 @@
|
||||
{
|
||||
foreach (var item in AttachedList!.Select((p, index) => new { p, index }))
|
||||
{
|
||||
<MudChip T="string" Color="Color.Default" OnClose="() => OnRemoveAttached(item.index)">
|
||||
@item.p.Name
|
||||
</MudChip>
|
||||
@if (item.p.Type == AttachedDTO.TypeAttached.Position)
|
||||
{
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.LocationOn" Color="Color.Success" OnClose="() => OnRemoveAttached(item.index)">
|
||||
@item.p.Description
|
||||
</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudChip T="string" Color="Color.Default" OnClose="() => OnRemoveAttached(item.index)">
|
||||
@item.p.Name
|
||||
</MudChip>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,11 +193,23 @@
|
||||
</MessageContent>
|
||||
<YesButton>
|
||||
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Error"
|
||||
StartIcon="@Icons.Material.Rounded.Check">
|
||||
StartIcon="@Icons.Material.Rounded.DeleteForever">
|
||||
Cancella
|
||||
</MudButton>
|
||||
</YesButton>
|
||||
</MudMessageBox>
|
||||
|
||||
<MudMessageBox @ref="AddNamePosition" Class="c-messageBox" Title="Nome della posizione" CancelText="Annulla">
|
||||
<MessageContent>
|
||||
<MudTextField @bind-Value="NamePosition" Variant="Variant.Outlined" />
|
||||
</MessageContent>
|
||||
<YesButton>
|
||||
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Rounded.Check">
|
||||
Salva
|
||||
</MudButton>
|
||||
</YesButton>
|
||||
</MudMessageBox>
|
||||
|
||||
<MudMessageBox @ref="ConfirmMemo" Class="c-messageBox" Title="Attenzione!" CancelText="Annulla">
|
||||
<MessageContent>
|
||||
@@ -195,7 +217,7 @@
|
||||
</MessageContent>
|
||||
<YesButton>
|
||||
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Primary"
|
||||
StartIcon="@Icons.Material.Rounded.DeleteForever">
|
||||
StartIcon="@Icons.Material.Rounded.Check">
|
||||
Crea
|
||||
</MudButton>
|
||||
</YesButton>
|
||||
@@ -241,9 +263,12 @@
|
||||
//MessageBox
|
||||
private MudMessageBox ConfirmDelete { get; set; }
|
||||
private MudMessageBox ConfirmMemo { get; set; }
|
||||
private MudMessageBox AddNamePosition { get; set; }
|
||||
|
||||
//Attached
|
||||
private List<AttachedDTO>? AttachedList { get; set; }
|
||||
private string? NamePosition { get; set; }
|
||||
private bool CanAddPosition { get; set; } = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -479,12 +504,25 @@
|
||||
|
||||
private async Task OpenAddAttached()
|
||||
{
|
||||
var result = await ModalHelpers.OpenAddAttached(Dialog);
|
||||
var result = await ModalHelpers.OpenAddAttached(Dialog, CanAddPosition);
|
||||
|
||||
if (result is { Canceled: false, Data: not null } && result.Data.GetType() == typeof(AttachedDTO))
|
||||
{
|
||||
var attached = (AttachedDTO)result.Data;
|
||||
|
||||
if (attached.Type == AttachedDTO.TypeAttached.Position)
|
||||
{
|
||||
CanAddPosition = false;
|
||||
|
||||
var resultNamePosition = await AddNamePosition.ShowAsync();
|
||||
|
||||
if (resultNamePosition is true)
|
||||
attached.Description = NamePosition;
|
||||
attached.Name = NamePosition!;
|
||||
}
|
||||
|
||||
AttachedList ??= [];
|
||||
AttachedList.Add((AttachedDTO)result.Data);
|
||||
AttachedList.Add(attached);
|
||||
|
||||
LabelSave = "Aggiorna";
|
||||
}
|
||||
@@ -495,6 +533,11 @@
|
||||
if (AttachedList is null || index < 0 || index >= AttachedList.Count)
|
||||
return;
|
||||
|
||||
var attached = AttachedList[index];
|
||||
|
||||
if (attached.Type == AttachedDTO.TypeAttached.Position)
|
||||
CanAddPosition = true;
|
||||
|
||||
AttachedList.RemoveAt(index);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user