diff --git a/BlazorApp/BlazorApp/Components/InventoryComp.razor b/BlazorApp/BlazorApp/Components/InventoryComp.razor
index 31d5a00..0db002e 100644
--- a/BlazorApp/BlazorApp/Components/InventoryComp.razor
+++ b/BlazorApp/BlazorApp/Components/InventoryComp.razor
@@ -56,14 +56,7 @@
- @if (!string.IsNullOrWhiteSpace(context.ImageBase64))
- {
-
- }
- else
- {
-
- }
+
diff --git a/BlazorApp/BlazorApp/Components/InventoryComp.razor.cs b/BlazorApp/BlazorApp/Components/InventoryComp.razor.cs
index 52aa4e4..3356290 100644
--- a/BlazorApp/BlazorApp/Components/InventoryComp.razor.cs
+++ b/BlazorApp/BlazorApp/Components/InventoryComp.razor.cs
@@ -24,17 +24,34 @@ namespace BlazorApp.Components
public List- InventoryItems { get; set; }
+ public ObservableCollection Actions { get; set; }
+
+ [Inject]
+ internal IJSRuntime JavaScriptRuntime { get; set; }
+
private int totalItem;
+<<<<<<< HEAD
public bool IsSorted { get; set; }
+=======
+ private int PageSize { get; set; }
+ private int CurrentPage { get; set; }
+
+ private bool IsSorted { get; set; }
+
+>>>>>>> ffa1fa821cc019ca5b6c2b58235c7474e8f62dd1
public InventoryComp()
{
- this.InventoryItems = new List
- { };
- for (int i = 0; i < 18; i++)
- {
- this.InventoryItems.Append(null);
+ Actions = new ObservableCollection();
+ Actions.CollectionChanged += OnActionsCollectionChanged;
+
+ this.InventoryItems = new List
- (new Item[18]);
}
+
+ private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
+ {
+ JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems);
}
private async Task OnReadData(DataGridReadDataEventArgs
- e)
@@ -44,6 +61,7 @@ namespace BlazorApp.Components
return;
}
+<<<<<<< HEAD
if (!e.CancellationToken.IsCancellationRequested && IsSorted ==false)
{
Items = await DataService.List(e.Page, e.PageSize);
@@ -54,10 +72,26 @@ namespace BlazorApp.Components
Items = await DataService.SortedList(e.Page, e.PageSize);
}
+=======
+ if (!e.CancellationToken.IsCancellationRequested && !IsSorted)
+ {
+ Items = await DataService.List(e.Page, e.PageSize);
+ totalItem = await DataService.Count();
+ CurrentPage = e.Page;
+ PageSize = e.PageSize;
+ }
+ else
+ {
+ CurrentPage = e.Page;
+ PageSize = e.PageSize;
+ Items = await DataService.SortedList(CurrentPage, PageSize);
+ }
+>>>>>>> ffa1fa821cc019ca5b6c2b58235c7474e8f62dd1
}
private async Task SortByName()
{
+<<<<<<< HEAD
if (IsSorted)
{
IsSorted = false;
@@ -65,6 +99,12 @@ namespace BlazorApp.Components
else
{
IsSorted = true;
+=======
+ if (!IsSorted)
+ {
+ IsSorted = true;
+ Items = await DataService.SortedList(CurrentPage, PageSize);
+>>>>>>> ffa1fa821cc019ca5b6c2b58235c7474e8f62dd1
}
}
diff --git a/BlazorApp/BlazorApp/Components/InventoryItem.razor b/BlazorApp/BlazorApp/Components/InventoryItem.razor
index 298b7eb..7c66705 100644
--- a/BlazorApp/BlazorApp/Components/InventoryItem.razor
+++ b/BlazorApp/BlazorApp/Components/InventoryItem.razor
@@ -5,10 +5,25 @@
@ondrop="@OnDrop"
@ondragenter="@OnDragEnter"
@ondragleave="@OnDragLeave"
- @ondragend="@OnDragEnd" >
+ @ondragend="@OnDragEnd">
@if (Item != null)
{
- @Item.DisplayName
+ if (NoDrop)
+ {
+ @if (!string.IsNullOrWhiteSpace(Item.ImageBase64))
+ {
+
+ }
+ else
+ {
+
+ }
+ }
+ else
+ {
+ @Item.DisplayName
+ }
+
}
\ No newline at end of file
diff --git a/BlazorApp/BlazorApp/Components/InventoryItem.razor.cs b/BlazorApp/BlazorApp/Components/InventoryItem.razor.cs
index 6af5477..9ccfd8e 100644
--- a/BlazorApp/BlazorApp/Components/InventoryItem.razor.cs
+++ b/BlazorApp/BlazorApp/Components/InventoryItem.razor.cs
@@ -52,6 +52,8 @@ namespace BlazorApp.Components
Parent.CurrentDragItem = tmp;
Parent.CurrentDragIndex = this.Index;
}
+ Parent.Actions.Add(new CraftingAction { Action = "On Drop", Item = this.Item, Index = this.Index });
+
}
private void OnDragStart()
@@ -72,6 +74,8 @@ namespace BlazorApp.Components
}
}
+ Parent.Actions.Add(new CraftingAction { Action = "Drag Start", Item = this.Item, Index = this.Index });
+
}
internal void OnDragEnd()
@@ -85,6 +89,9 @@ namespace BlazorApp.Components
Parent.InventoryItems[this.Index] = this.Item;
this.Item = Parent.CurrentDragItem;
}
+
+ Parent.Actions.Add(new CraftingAction { Action = "Drag End", Item = this.Item, Index = this.Index });
+
Parent.CurrentDragIndex = -1;
Parent.CurrentDragItem = null;
diff --git a/BlazorApp/BlazorApp/Services/DataApiService.cs b/BlazorApp/BlazorApp/Services/DataApiService.cs
index 407996c..7f6545a 100644
--- a/BlazorApp/BlazorApp/Services/DataApiService.cs
+++ b/BlazorApp/BlazorApp/Services/DataApiService.cs
@@ -59,7 +59,13 @@ namespace BlazorApp.Services
public async Task> SortedList(int currentPage, int pageSize)
{
+<<<<<<< HEAD
return await _http.GetFromJsonAsync>($"https://localhost:7234/api/Crafting/?currentPage={currentPage}&pageSize={pageSize}");
+=======
+ List- it = await _http.GetFromJsonAsync
>($"https://localhost:7234/api/Crafting/all/");
+ it = it.OrderBy(i => i.DisplayName).ToList();
+ return it.GetRange((currentPage - 1) * 10, pageSize);
+>>>>>>> ffa1fa821cc019ca5b6c2b58235c7474e8f62dd1
}