|
|
@ -6,16 +6,22 @@ using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using BlazorApp.Services;
|
|
|
|
using BlazorApp.Services;
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BlazorApp.Components
|
|
|
|
namespace BlazorApp.Components
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public partial class InventoryComp
|
|
|
|
public partial class InventoryComp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
|
|
|
public int InventorySize { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public Item CurrentDragItem { get; set; }
|
|
|
|
public Item CurrentDragItem { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public int CurrentDragIndex { get; set; }
|
|
|
|
public int CurrentDragIndex { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int CurrentDragNbItem { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
|
|
|
|
|
|
|
@ -37,6 +43,8 @@ namespace BlazorApp.Components
|
|
|
|
|
|
|
|
|
|
|
|
private int CurrentPage { get; set; }
|
|
|
|
private int CurrentPage { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string Recherche { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public InventoryComp()
|
|
|
|
public InventoryComp()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -44,9 +52,17 @@ namespace BlazorApp.Components
|
|
|
|
|
|
|
|
|
|
|
|
Actions.CollectionChanged += OnActionsCollectionChanged;
|
|
|
|
Actions.CollectionChanged += OnActionsCollectionChanged;
|
|
|
|
|
|
|
|
|
|
|
|
this.InventoryItems = new List<Item>(new Item[18]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.InventoryItems = new List<Item>(new Item[InventorySize]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems);
|
|
|
|
JavaScriptRuntime.InvokeVoidAsync("Crafting.AddActions", e.NewItems);
|
|
|
@ -58,17 +74,23 @@ namespace BlazorApp.Components
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested && !IsSorted)
|
|
|
|
|
|
|
|
|
|
|
|
CurrentPage = e.Page;
|
|
|
|
|
|
|
|
PageSize = e.PageSize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested && !IsSorted && string.IsNullOrWhiteSpace(Recherche))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Items = await DataService.List(e.Page, e.PageSize);
|
|
|
|
Items = await DataService.List(e.Page, e.PageSize);
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
CurrentPage = e.Page;
|
|
|
|
|
|
|
|
PageSize = e.PageSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!string.IsNullOrWhiteSpace(Recherche))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
(Items, totalItem) = await DataService.SearchList(CurrentPage, PageSize, Recherche);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CurrentPage = e.Page;
|
|
|
|
|
|
|
|
PageSize = e.PageSize;
|
|
|
|
|
|
|
|
Items = await DataService.SortedList(CurrentPage, PageSize);
|
|
|
|
Items = await DataService.SortedList(CurrentPage, PageSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -82,8 +104,26 @@ namespace BlazorApp.Components
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void refresh()
|
|
|
|
private async void OnInput(Microsoft.AspNetCore.Components.ChangeEventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Recherche = (string)args.Value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(Recherche))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!IsSorted)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Items = await DataService.List(CurrentPage, PageSize);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Items = await DataService.SortedList(CurrentPage, PageSize);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
(Items, totalItem) = await DataService.SearchList(CurrentPage, PageSize, Recherche);
|
|
|
|
|
|
|
|
}
|
|
|
|
StateHasChanged();
|
|
|
|
StateHasChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|