|
|
@ -5,6 +5,14 @@ using Microsoft.JSInterop;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
using Blazorise.DataGrid;
|
|
|
|
|
|
|
|
using BlazorStrap;
|
|
|
|
|
|
|
|
using BlazorStrap.V5;
|
|
|
|
|
|
|
|
using Blazored.Modal;
|
|
|
|
|
|
|
|
using BlazorT.Modals;
|
|
|
|
|
|
|
|
using Sve.Blazor.Core.Services;
|
|
|
|
|
|
|
|
using Blazored.Modal.Services;
|
|
|
|
|
|
|
|
using BlazorT.Services;
|
|
|
|
|
|
|
|
using Blazorise;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BlazorT.Composants
|
|
|
|
namespace BlazorT.Composants
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -16,13 +24,12 @@ namespace BlazorT.Composants
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Actions = new ObservableCollection<InventoryAction>();
|
|
|
|
Actions = new ObservableCollection<InventoryAction>();
|
|
|
|
Actions.CollectionChanged += OnActionsCollectionChanged;
|
|
|
|
Actions.CollectionChanged += OnActionsCollectionChanged;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private DataGrid<Item> gridTableRef;
|
|
|
|
private BSDataTable<Item> _customFilterRef = new BSDataTable<Item>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
|
|
|
private ILogger<Program> _logger { set; get; }
|
|
|
|
|
|
|
|
|
|
|
|
private string searchValue;
|
|
|
|
private string searchValue;
|
|
|
|
public ObservableCollection<InventoryAction> Actions { get; set; }
|
|
|
|
public ObservableCollection<InventoryAction> Actions { get; set; }
|
|
|
@ -62,6 +69,19 @@ namespace BlazorT.Composants
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
|
internal IJSRuntime JavaScriptRuntime { get; set; }
|
|
|
|
internal IJSRuntime JavaScriptRuntime { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnInitialized()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
base.OnInitialized();
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnAfterRender(bool firstRender)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
base.OnAfterRender(firstRender);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CheckRecipe()
|
|
|
|
public void CheckRecipe()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RecipeResult = null;
|
|
|
|
RecipeResult = null;
|
|
|
@ -70,7 +90,7 @@ namespace BlazorT.Composants
|
|
|
|
var currentModel = string.Join("|", this.RecipeItems.Select(s => s != null ? s.Name : string.Empty));
|
|
|
|
var currentModel = string.Join("|", this.RecipeItems.Select(s => s != null ? s.Name : string.Empty));
|
|
|
|
|
|
|
|
|
|
|
|
this.Actions.Add(new InventoryAction { Action = $"Items : {currentModel}" });
|
|
|
|
this.Actions.Add(new InventoryAction { Action = $"Items : {currentModel}" });
|
|
|
|
|
|
|
|
_logger.LogInformation("Recipe checking.....");
|
|
|
|
foreach (var inventoryRecipe in Recipes)
|
|
|
|
foreach (var inventoryRecipe in Recipes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Get the recipe model
|
|
|
|
// Get the recipe model
|
|
|
@ -90,20 +110,66 @@ namespace BlazorT.Composants
|
|
|
|
base.OnParametersSet();
|
|
|
|
base.OnParametersSet();
|
|
|
|
items = Items;
|
|
|
|
items = Items;
|
|
|
|
this.RecipeItems = Enumerable.Repeat<Item>(null, NombreRecipes).ToList();
|
|
|
|
this.RecipeItems = Enumerable.Repeat<Item>(null, NombreRecipes).ToList();
|
|
|
|
|
|
|
|
this.onSearching("");
|
|
|
|
|
|
|
|
_logger.LogInformation("Parameters set: Items, RecipeItems");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onSearching(ChangeEventArgs e)
|
|
|
|
private void onSearching(string e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
searchValue = e.Value.ToString();
|
|
|
|
searchValue = e;
|
|
|
|
|
|
|
|
_customFilterRef.Page = 1;
|
|
|
|
Items = !string.IsNullOrWhiteSpace(searchValue) ? Items.Where(x => x.Name.Contains(searchValue, StringComparison.OrdinalIgnoreCase)).ToList() : items;
|
|
|
|
if (!string.IsNullOrEmpty(searchValue))
|
|
|
|
this.StateHasChanged();
|
|
|
|
{
|
|
|
|
|
|
|
|
Items = items.Where(q => q.Name.ToLower().Contains(searchValue.ToLower()) || q.DisplayName.ToLower().Contains(searchValue.ToLower())).ToList();
|
|
|
|
|
|
|
|
_logger.LogInformation($"Searching... {e}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Items = items.Take(20).ToList();
|
|
|
|
|
|
|
|
_logger.LogInformation("Fetching All ...");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
StateHasChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
private void OnActionsCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
JavaScriptRuntime.InvokeVoidAsync("Inventory.AddActions", e.NewItems);
|
|
|
|
JavaScriptRuntime.InvokeVoidAsync("Inventory.AddActions", e.NewItems);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<(IEnumerable<Item>, int)> FetchItems(DataRequest dataRequest)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var count = items.Count;
|
|
|
|
|
|
|
|
if (dataRequest.FilterColumnProperty != null && dataRequest.Filter != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var data = Items.Where(q =>
|
|
|
|
|
|
|
|
(q.Name.ToLower().Contains(dataRequest.Filter) && nameof(q.Name) == dataRequest.FilterColumn)
|
|
|
|
|
|
|
|
).ToList();
|
|
|
|
|
|
|
|
count = data.Count();
|
|
|
|
|
|
|
|
_logger.LogInformation($"Fetching for {dataRequest.FilterColumnProperty} - {dataRequest.Filter}");
|
|
|
|
|
|
|
|
return (data, count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dataRequest.SortColumnProperty != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (dataRequest.Descending)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_logger.LogInformation($"Column Sort : {dataRequest.SortColumnProperty} - Descending");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (Items.OrderByDescending(x => dataRequest.SortColumnProperty.GetValue(x)).Skip(dataRequest.Page * 20).Take(20).ToList(), count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"Column Sort : {dataRequest.SortColumnProperty} - Ascending");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (Items.OrderBy(x => dataRequest.SortColumnProperty.GetValue(x)).Skip(dataRequest.Page * 20).Take(20).ToList(), count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_logger.LogInformation("Fetching or Sort : Empty");
|
|
|
|
|
|
|
|
return (Items.Skip(dataRequest.Page * 20).Take(20).ToList(), count);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|