From 6e754626cb2592bd9160bb78193f3fe79e230f79 Mon Sep 17 00:00:00 2001 From: remrem Date: Fri, 16 Dec 2022 09:26:28 +0100 Subject: [PATCH] component InventoryListImage works + reAdd OnInitializedAsync --- Blazor/Blazor/Components/InventoryList.razor | 2 +- .../Blazor/Components/InventoryList.razor.cs | 8 ++++-- .../Components/InventoryListImage.razor.cs | 28 ------------------- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/Blazor/Blazor/Components/InventoryList.razor b/Blazor/Blazor/Components/InventoryList.razor index 88a67f6..6e5ca1f 100644 --- a/Blazor/Blazor/Components/InventoryList.razor +++ b/Blazor/Blazor/Components/InventoryList.razor @@ -11,7 +11,7 @@ - + diff --git a/Blazor/Blazor/Components/InventoryList.razor.cs b/Blazor/Blazor/Components/InventoryList.razor.cs index af2548c..2660e9c 100644 --- a/Blazor/Blazor/Components/InventoryList.razor.cs +++ b/Blazor/Blazor/Components/InventoryList.razor.cs @@ -55,8 +55,10 @@ namespace Blazor.Components } protected override async Task OnInitializedAsync() - { - - } + { + items = await DataService.getAll(); + totalItem = await DataService.Count(); + await base.OnInitializedAsync(); + } } } \ No newline at end of file diff --git a/Blazor/Blazor/Components/InventoryListImage.razor.cs b/Blazor/Blazor/Components/InventoryListImage.razor.cs index 6290b71..96a2427 100644 --- a/Blazor/Blazor/Components/InventoryListImage.razor.cs +++ b/Blazor/Blazor/Components/InventoryListImage.razor.cs @@ -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 }); } } }