mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-13 06:01:37 +00:00
Improvement of the ReviewAttachmentsDialog: add delete function and check for existence of the file
This commit is contained in:
parent
a3deec9e5c
commit
ca141e3ebd
@ -7,10 +7,35 @@
|
||||
<DialogContent>
|
||||
@foreach (var filePath in this.DocumentPaths)
|
||||
{
|
||||
<MudMenuItem
|
||||
Icon="@Icons.Material.Filled.AttachFile"
|
||||
Label="@Path.GetFileName(filePath)">
|
||||
</MudMenuItem>
|
||||
@if (File.Exists(filePath))
|
||||
{
|
||||
<MudStack Row Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="mb-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.AttachFile" Class="mr-2"/>
|
||||
|
||||
<MudText Class="flex-grow-1 overflow-hidden text-ellipsis" Style="white-space: nowrap;">
|
||||
@Path.GetFileName(filePath)
|
||||
</MudText>
|
||||
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
||||
Color="Color.Error"
|
||||
Class="ml-2"
|
||||
OnClick="@(() => DeleteAttachment(filePath))"/>
|
||||
</MudStack>
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudStack Row Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Class="mb-2">
|
||||
<MudText Class="flex-grow-1 overflow-hidden text-ellipsis" Style="white-space: nowrap;">
|
||||
<s>@Path.GetFileName(filePath)</s>
|
||||
</MudText>
|
||||
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
||||
Color="Color.Error"
|
||||
Class="ml-2"
|
||||
OnClick="@(() => DeleteAttachment(filePath))"/>
|
||||
</MudStack>
|
||||
}
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
||||
@ -33,4 +33,12 @@ public partial class ReviewAttachmentsDialog : MSGComponentBase
|
||||
|
||||
return dialogResult.Data as HashSet<string> ?? documentPaths;
|
||||
}
|
||||
|
||||
private void DeleteAttachment(string filePath)
|
||||
{
|
||||
if (this.DocumentPaths.Remove(filePath))
|
||||
{
|
||||
this.StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user