|
|
@ -2,17 +2,21 @@
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
|
|
|
|
using Blazorise.Extensions;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
using Microsoft.JSInterop;
|
|
|
|
using Microsoft.JSInterop;
|
|
|
|
using myBlazorApp.Models;
|
|
|
|
using myBlazorApp.Models;
|
|
|
|
using myBlazorApp.Services;
|
|
|
|
using myBlazorApp.Services;
|
|
|
|
|
|
|
|
using Syncfusion.Blazor.Grids;
|
|
|
|
|
|
|
|
|
|
|
|
namespace myBlazorApp.Components
|
|
|
|
namespace myBlazorApp.Components
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public partial class MyInventory
|
|
|
|
public partial class MyInventory
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[Parameter]
|
|
|
|
[Parameter]
|
|
|
|
public List<InventoryListItem> ItemsInventory { get; set; }
|
|
|
|
public List<InventoryListItem> ItemsInventory { get; set; } = new List<InventoryListItem>();
|
|
|
|
|
|
|
|
|
|
|
|
public int index { get; set; } = 0;
|
|
|
|
public int index { get; set; } = 0;
|
|
|
|
|
|
|
|
|
|
|
@ -24,6 +28,36 @@ namespace myBlazorApp.Components
|
|
|
|
public int CurrentDragStackSize { get; set; }
|
|
|
|
public int CurrentDragStackSize { get; set; }
|
|
|
|
public InventoryItem CurrentInventoryItem {get; set;} = new InventoryItem();
|
|
|
|
public InventoryItem CurrentInventoryItem {get; set;} = new InventoryItem();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Item> items = new List<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Item> full = new List<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Item> choix = new List<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string SearchText = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int totalItem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int currentPage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int pageSize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Item> Filtered = new List<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Item> Sorted = new List<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
|
|
|
public IWebHostEnvironment WebHostEnvironment { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
|
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool isSorted = false;
|
|
|
|
|
|
|
|
|
|
|
|
public MyInventory()
|
|
|
|
public MyInventory()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Actions = new ObservableCollection<InventoryAction>();
|
|
|
|
Actions = new ObservableCollection<InventoryAction>();
|
|
|
@ -31,17 +65,9 @@ namespace myBlazorApp.Components
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
public IStringLocalizer<MyInventory> Localizer { get; set; }
|
|
|
|
public IStringLocalizer<MyInventory> Localizer { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
|
|
|
public IWebHostEnvironment WebHostEnvironment { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
|
|
|
public NavigationManager NavigationManager { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
internal IJSRuntime JavaScriptRuntime { get; set; }
|
|
|
|
internal IJSRuntime JavaScriptRuntime { get; set; }
|
|
|
@ -55,6 +81,108 @@ namespace myBlazorApp.Components
|
|
|
|
await DataService.UpdateInventory(infos);
|
|
|
|
await DataService.UpdateInventory(infos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e.CancellationToken.IsCancellationRequested)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
|
|
|
|
items = await DataService.List(e.Page, e.PageSize);
|
|
|
|
|
|
|
|
full = await DataService.List(e.Page, totalItem);
|
|
|
|
|
|
|
|
ItemsInventory = await DataService.GetInventoryItems();
|
|
|
|
|
|
|
|
currentPage = e.Page;
|
|
|
|
|
|
|
|
pageSize = e.PageSize;
|
|
|
|
|
|
|
|
if (isSorted == false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
choix = items;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
choix = SortList();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SearchText.IsNullOrEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
choix = items;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
choix = choseList();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Item> choseList()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (SearchText.IsNullOrEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
choix = items;
|
|
|
|
|
|
|
|
totalItem = full.Count();
|
|
|
|
|
|
|
|
NavigationManager.NavigateTo("inventory", false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Filtered.Count() < (currentPage - 1) * 10 + pageSize)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pageSize = Filtered.Count() - (currentPage - 1) * 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
choix = Filtered.GetRange((currentPage - 1) * 10, pageSize);
|
|
|
|
|
|
|
|
totalItem = Filtered.Count();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
|
|
|
NavigationManager.NavigateTo("inventory", false);
|
|
|
|
|
|
|
|
return choix;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void inputValue()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Filtered = full.Where(
|
|
|
|
|
|
|
|
itm => itm.DisplayName.ToLower().Contains(SearchText.ToLower())).ToList();
|
|
|
|
|
|
|
|
choseList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPress()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isSorted == true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
isSorted = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else isSorted = true;
|
|
|
|
|
|
|
|
SortList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Item> SortList()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isSorted == false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
choix = items;
|
|
|
|
|
|
|
|
NavigationManager.NavigateTo("inventory", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (Sorted.IsNullOrEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Sorted = full;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Sorted.Sort((x, y) => string.Compare(x.DisplayName, y.DisplayName));
|
|
|
|
|
|
|
|
if (Sorted.Count() < (currentPage - 1) * 10 + pageSize)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pageSize = Sorted.Count() - (currentPage - 1) * 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
choix = Sorted.GetRange((currentPage - 1) * 10, pageSize);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return choix;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|