Extracted some pages to their own assembly and finished the artifact display page code
This commit is contained in:
@@ -5,9 +5,17 @@
|
||||
@* Loop through and display each item as a chip *@
|
||||
@foreach (var item in Items)
|
||||
{
|
||||
<MudChip Color="Color.Primary" OnClose="() => RemoveItem(item)" T="T">
|
||||
@DisplayFunc(item)
|
||||
</MudChip>
|
||||
@if (DeleteEnabled)
|
||||
{
|
||||
<MudChip Color="Color.Primary" OnClose="() => RemoveItem(item)" T="T">
|
||||
@DisplayFunc(item)
|
||||
</MudChip>
|
||||
} else
|
||||
{
|
||||
<MudChip Color="Color.Primary" T="T">
|
||||
@DisplayFunc(item)
|
||||
</MudChip>
|
||||
}
|
||||
}
|
||||
|
||||
@* Render the input control provided by the consumer *@
|
||||
@@ -22,6 +30,9 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public bool DeleteEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The list of items to display and manage.
|
||||
/// </summary>
|
||||
@@ -51,8 +62,6 @@
|
||||
[Parameter]
|
||||
public Func<T, string> DisplayFunc { get; set; } = item => item?.ToString() ?? string.Empty;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A public method that the consumer's input control can call to add a new item.
|
||||
/// </summary>
|
||||
|
||||
@@ -230,4 +230,19 @@
|
||||
|
||||
private void ClearDragClass()
|
||||
=> _dragClass = DefaultDragClass;
|
||||
|
||||
public void RemoveFile(string filename)
|
||||
{
|
||||
var existingFile = ExistingFiles.Where(f => f.OriginalName == filename).FirstOrDefault();
|
||||
if (existingFile is not null)
|
||||
{
|
||||
ExistingFiles.Remove(existingFile);
|
||||
}
|
||||
|
||||
var file = Files.Where(f => f.Name == filename).FirstOrDefault();
|
||||
if (file is not null)
|
||||
{
|
||||
Files.Remove(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user