DragnDrop + Löschfunktion
This commit is contained in:
@@ -63,7 +63,7 @@
|
||||
<MudTabs Elevation="2" Rounded="true" ApplyEffectsToContainer="true" PanelClass="pa-6" Color="Color.Primary">
|
||||
|
||||
<MudTabPanel Icon="@Icons.Material.Filled.ViewWeek" Text="Wochenansicht">
|
||||
<MudDropContainer T="DropItem" Items="_items" ItemsSelector="@((item, dropzone) => item.Status == dropzone)" ItemDropped="ItemUpdated" Class="d-flex flex-column flex-grow-1">
|
||||
<MudDropContainer @ref="_dropContainer" T="DropItem" Items="_items" ItemsSelector="@((item, dropzone) => item.Status == dropzone)" ItemDropped="ItemUpdated" Class="d-flex flex-column flex-grow-1">
|
||||
<ChildContent>
|
||||
<div class="d-flex justify-space-between align-center mb-6">
|
||||
<MudButtonGroup Color="Color.Default" Variant="Variant.Outlined">
|
||||
@@ -101,11 +101,19 @@
|
||||
</div>
|
||||
</ChildContent>
|
||||
<ItemRenderer>
|
||||
<MudPaper Elevation="2" Class="pa-3 rounded-lg border-l-4" Style="@($"border-left: 6px solid {context.Color}; cursor: grab; width: 160px;")">
|
||||
<MudPaper Elevation="2" Class="pa-3 rounded-lg border-l-4" Style="@($"border-left: 6px solid {context.Color}; cursor: grab; width: 160px; position: relative;")">
|
||||
<div class="d-flex flex-column">
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary" Style="font-size: 0.7rem">@context.Project</MudText>
|
||||
<MudText Typo="Typo.body2"><b>@context.Task</b></MudText>
|
||||
<div class="d-flex align-center justify-space-between mt-2">
|
||||
<div class="d-flex justify-space-between align-start">
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary" Style="font-size: 0.7rem">@context.Project</MudText>
|
||||
@if (context.Status != "Backlog")
|
||||
{
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error"
|
||||
Style="position: absolute; top: 0px; right: 0px; padding: 4px;"
|
||||
OnClick="() => DeleteItem(context)" />
|
||||
}
|
||||
</div>
|
||||
<MudText Typo="Typo.body2" Class="mt-1"><b>@context.Task</b></MudText>
|
||||
<div class="d-flex align-center justify-space-between mt-1">
|
||||
<MudNumericField @bind-Value="context.Hours" Variant="Variant.Text" Margin="Margin.Dense" Style="width: 50px;" T="double" />
|
||||
<MudIcon Icon="@Icons.Material.Filled.DragIndicator" Size="Size.Small" Color="Color.Error" />
|
||||
</div>
|
||||
@@ -145,6 +153,7 @@
|
||||
<MudFab Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add" Style="position: fixed; bottom: 24px; right: 24px;" OnClick="OpenBookingDialog" />
|
||||
|
||||
@code {
|
||||
private MudDropContainer<DropItem> _dropContainer;
|
||||
private string _searchString = "";
|
||||
private List<DayInfo> _weekDays = new();
|
||||
private List<DropItem> _items = new();
|
||||
@@ -165,9 +174,9 @@
|
||||
// Dummy Daten für das DataGrid
|
||||
private List<BookingPlaceholder> _dummyBookings = new()
|
||||
{
|
||||
new(DateTime.Now, "00000001 - Gleitzeit", "Projektarbeit", 8.0),
|
||||
new(DateTime.Now.AddDays(-1), "00000001 - Gleitzeit", "Meeting", 4.5),
|
||||
new(DateTime.Now.AddDays(-2), "00000010 - Allg. Besprechung", "Jour Fixe", 1.0),
|
||||
new(DateTime.Now, "00000001 - Gleitzeit", "Projektarbeit", 0.0),
|
||||
new(DateTime.Now.AddDays(-1), "00000001 - Gleitzeit", "Meeting", 0.0),
|
||||
new(DateTime.Now.AddDays(-2), "00000010 - Allg. Besprechung", "Jour Fixe", 0.0),
|
||||
};
|
||||
|
||||
protected override void OnInitialized()
|
||||
@@ -181,19 +190,17 @@
|
||||
}
|
||||
|
||||
// Stapel an Vorlagen im Backlog
|
||||
_items.Add(new DropItem { Project = "00001", Task = "Gleitzeit", Hours = 8, Color = "#7e6fff", Status = "Backlog" });
|
||||
_items.Add(new DropItem { Project = "00010", Task = "Meeting", Hours = 1, Color = "#3dcb6c", Status = "Backlog" });
|
||||
_items.Add(new DropItem { Project = "00500", Task = "Entwicklung", Hours = 4, Color = "#ffb545", Status = "Backlog" });
|
||||
_items.Add(new DropItem { Project = "00001", Task = "Gleitzeit", Hours = 0, Color = "#7e6fff", Status = "Backlog" });
|
||||
_items.Add(new DropItem { Project = "00010", Task = "Meeting", Hours = 0, Color = "#3dcb6c", Status = "Backlog" });
|
||||
_items.Add(new DropItem { Project = "00500", Task = "Entwicklung", Hours = 0, Color = "#ffb545", Status = "Backlog" });
|
||||
|
||||
// Initialer Datenbestand für die Ansicht
|
||||
_items.Add(new DropItem { Project = "00001", Task = "Gleitzeit", Hours = 4, Color = "#7e6fff", Status = "Montag" });
|
||||
}
|
||||
|
||||
private void ItemUpdated(MudItemDropInfo<DropItem> dropInfo)
|
||||
{
|
||||
if (dropInfo.DropzoneIdentifier != "Backlog" && dropInfo.Item.Status == "Backlog")
|
||||
{
|
||||
// Erstelle eine echte Kopie vom Template
|
||||
// Erstelle eine echte Kopie vom Template und füge sie sofort hinzu
|
||||
var newItem = new DropItem
|
||||
{
|
||||
Project = dropInfo.Item.Project,
|
||||
@@ -210,6 +217,18 @@
|
||||
// Einfaches Verschieben zwischen den Tagen
|
||||
dropInfo.Item.Status = dropInfo.DropzoneIdentifier;
|
||||
}
|
||||
|
||||
_dropContainer.Refresh();
|
||||
}
|
||||
|
||||
private void DeleteItem(DropItem item)
|
||||
{
|
||||
if (item.Status != "Backlog")
|
||||
{
|
||||
_items.Remove(item);
|
||||
Snackbar.Add($"{item.Task} gelöscht", Severity.Warning);
|
||||
_dropContainer.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Func<BookingPlaceholder, bool> _quickFilter => x =>
|
||||
|
||||
Reference in New Issue
Block a user