|
|
@ -1,7 +1,11 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
using Blazored.Modal;
|
|
|
|
using Blazored.Modal;
|
|
|
|
using Blazored.Modal.Services;
|
|
|
|
using Blazored.Modal.Services;
|
|
|
|
|
|
|
|
using Blazorise;
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
|
|
|
|
using Blazorise.Extensions;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
using myBlazorApp.Components;
|
|
|
|
using myBlazorApp.Components;
|
|
|
@ -9,27 +13,32 @@ using myBlazorApp.Factories;
|
|
|
|
using myBlazorApp.Modals;
|
|
|
|
using myBlazorApp.Modals;
|
|
|
|
using myBlazorApp.Models;
|
|
|
|
using myBlazorApp.Models;
|
|
|
|
using myBlazorApp.Services;
|
|
|
|
using myBlazorApp.Services;
|
|
|
|
|
|
|
|
using IModalService = Blazored.Modal.Services.IModalService;
|
|
|
|
|
|
|
|
|
|
|
|
namespace myBlazorApp.Pages
|
|
|
|
namespace myBlazorApp.Pages
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public partial class Inventory
|
|
|
|
public partial class Inventory
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public List<InventoryListItem> itemsInv = new List<InventoryListItem>();
|
|
|
|
public List<InventoryListItem> itemsInv = new List<InventoryListItem>();
|
|
|
|
|
|
|
|
|
|
|
|
private List<Item> items = new List<Item>();
|
|
|
|
private List<Item> items = new List<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
/*[Parameter]
|
|
|
|
private List<Item> full = new List<Item>();
|
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ItemModel itemModel = new()
|
|
|
|
private List<Item> choix = new List<Item>();
|
|
|
|
{
|
|
|
|
|
|
|
|
EnchantCategories = new List<string>(),
|
|
|
|
public string SearchText = "";
|
|
|
|
RepairWith = new List<string>()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int totalItem;
|
|
|
|
private int totalItem;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int currentPage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int pageSize;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Item> Filtered = new List<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Item> Sorted = new List<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
public IDataService DataService { get; set; }
|
|
|
|
|
|
|
|
|
|
|
@ -42,8 +51,12 @@ namespace myBlazorApp.Pages
|
|
|
|
[CascadingParameter]
|
|
|
|
[CascadingParameter]
|
|
|
|
public IModalService Modal { get; set; }
|
|
|
|
public IModalService Modal { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool isSorted = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
|
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (e.CancellationToken.IsCancellationRequested)
|
|
|
|
if (e.CancellationToken.IsCancellationRequested)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -51,29 +64,90 @@ namespace myBlazorApp.Pages
|
|
|
|
|
|
|
|
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
if (!e.CancellationToken.IsCancellationRequested)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
items = await DataService.List(e.Page, e.PageSize);
|
|
|
|
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
totalItem = await DataService.Count();
|
|
|
|
|
|
|
|
items = await DataService.List(e.Page, e.PageSize);
|
|
|
|
|
|
|
|
full = await DataService.List(e.Page, totalItem);
|
|
|
|
itemsInv = await DataService.GetInventoryItems();
|
|
|
|
itemsInv = 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 async void OnDelete(int id)
|
|
|
|
private List<Item> choseList()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var parameters = new ModalParameters();
|
|
|
|
if (SearchText.IsNullOrEmpty())
|
|
|
|
parameters.Add(nameof(Item.Id), id);
|
|
|
|
{
|
|
|
|
|
|
|
|
choix = items;
|
|
|
|
|
|
|
|
totalItem = items.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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var modal = Modal.Show<DeleteConfirmation>("Delete Confirmation", parameters);
|
|
|
|
private void inputValue()
|
|
|
|
var result = await modal.Result;
|
|
|
|
{
|
|
|
|
|
|
|
|
Filtered = full.Where(
|
|
|
|
|
|
|
|
itm => itm.DisplayName.ToLower().Contains(SearchText.ToLower())).ToList();
|
|
|
|
|
|
|
|
choseList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (result.Cancelled)
|
|
|
|
private void OnPress()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isSorted == true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
isSorted = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else isSorted = true;
|
|
|
|
|
|
|
|
SortList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await DataService.Delete(id);
|
|
|
|
private List<Item> SortList()
|
|
|
|
|
|
|
|
{
|
|
|
|
// Reload the page
|
|
|
|
if (isSorted == false)
|
|
|
|
NavigationManager.NavigateTo("list", true);
|
|
|
|
{
|
|
|
|
|
|
|
|
choix = items;
|
|
|
|
|
|
|
|
NavigationManager.NavigateTo("inventory", true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(Sorted.IsNullOrEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Sorted = full;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Sorted.Sort((x, y) => string.Compare(x.DisplayName, y.DisplayName));
|
|
|
|
|
|
|
|
choix = Sorted.GetRange((currentPage - 1) * 10, pageSize);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return choix;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|