component InventoryListImage works + reAdd OnInitializedAsync
continuous-integration/drone/push Build is passing Details

master
remrem 2 years ago
parent 8d0deba849
commit 6e754626cb

@ -11,7 +11,7 @@
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="#" Width="15%"/>
<DataGridColumn TItem="Item" Field="@nameof(Item.Id)" Caption="Image" Filterable="false">
<DisplayTemplate>
<InventoryListImage Item="Item" NoDrop="true"/>
<InventoryListImage Item="context" />
</DisplayTemplate>
</DataGridColumn>
<DataGridColumn TItem="Item" Field="@nameof(Item.DisplayName)" Caption="Display name">

@ -56,7 +56,9 @@ namespace Blazor.Components
protected override async Task OnInitializedAsync()
{
items = await DataService.getAll();
totalItem = await DataService.Count();
await base.OnInitializedAsync();
}
}
}

@ -5,56 +5,28 @@ namespace Blazor.Components
{
public partial class InventoryListImage
{
[Parameter]
public int Index { get; set; }
[Parameter]
public Item Item { get; set; }
[Parameter]
public bool NoDrop { get; set; }
[CascadingParameter]
public Crafting Parent { get; set; }
internal void OnDragEnter()
{
if (NoDrop)
{
return;
}
Parent.Actions.Add(new CraftingAction { Action = "Drag Enter", Item = this.Item, Index = this.Index });
}
internal void OnDragLeave()
{
if (NoDrop)
{
return;
}
Parent.Actions.Add(new CraftingAction { Action = "Drag Leave", Item = this.Item, Index = this.Index });
}
internal void OnDrop()
{
if (NoDrop)
{
return;
}
this.Item = Parent.CurrentDragItem;
Parent.RecipeItems[this.Index] = this.Item;
Parent.Actions.Add(new CraftingAction { Action = "Drop", Item = this.Item, Index = this.Index });
}
private void OnDragStart()
{
Parent.CurrentDragItem = this.Item;
Parent.Actions.Add(new CraftingAction { Action = "Drag Start", Item = this.Item, Index = this.Index });
}
}
}

Loading…
Cancel
Save