ADD :MyInventory component

master
Lucie Bedouret 2 years ago
parent 6d1bbdff48
commit 0c5d1b169f

@ -0,0 +1,23 @@
<h3>My Inventory</h3>
<div class="inventory-items">
<InventoryItem Index="0" />
<InventoryItem Index="1" />
<InventoryItem Index="2" />
<InventoryItem Index="3" />
<InventoryItem Index="4" />
<InventoryItem Index="5" />
<InventoryItem Index="6" />
<InventoryItem Index="7" />
<InventoryItem Index="8" />
<InventoryItem Index="9" />
<InventoryItem Index="10" />
<InventoryItem Index="11" />
<InventoryItem Index="12" />
<InventoryItem Index="13" />
<InventoryItem Index="14" />
<InventoryItem Index="15" />
<InventoryItem Index="16" />
<InventoryItem Index="17" />
</div>

@ -0,0 +1,34 @@
using System;
using Microsoft.AspNetCore.Components;
using myBlazorApp.Models;
using myBlazorApp.Services;
namespace myBlazorApp.Components
{
public partial class MyInventory
{
private List<Item> itemsInventory = new List<Item>();
[Inject]
public IDataService DataService { get; set; }
[Inject]
public IWebHostEnvironment WebHostEnvironment { get; set; }
[Inject]
public NavigationManager NavigationManager { get; set; }
/*
protected override async Task OnAfterRenderAsync(bool firstRender)
{
base.OnAfterRenderAsync(firstRender);
if (!firstRender)
{
return;
}
itemsInventory = await DataService.List(0, await DataService.Count());
StateHasChanged();
}
*/
}
}

@ -0,0 +1,6 @@
.inventory-items {
grid-template-columns: repeat(6,minmax(0,1fr));
gap: 10px;
display: grid;
width: 40%;
}

@ -3,46 +3,14 @@
@using System.Globalization
@using myBlazorApp.Models;
<h3>Inventory</h3>
<div class="inventory-items">
<InventoryItem Index="0" Item=@itemsInventory.ElementAt(0)/>
<InventoryItem Index="1" />
<InventoryItem Index="2" />
<InventoryItem Index="3" />
<InventoryItem Index="4" />
<InventoryItem Index="5" />
<InventoryItem Index="6" />
<InventoryItem Index="7" />
<InventoryItem Index="8" />
<InventoryItem Index="9" />
<InventoryItem Index="10" />
<InventoryItem Index="11" />
<InventoryItem Index="12" />
<InventoryItem Index="13" />
<InventoryItem Index="14" />
<InventoryItem Index="15" />
<InventoryItem Index="16" />
<InventoryItem Index="17" />
</div>
<div class="css-grid">
@foreach (var item in itemsInventory)
{
<CraftingItem Item="item" NoDrop="true" />
}
<p>
<b>CurrentCulture</b>: @CultureInfo.CurrentCulture
</p>
<div class="inventory">
<MyInventory/>
</div>
<div id="ItemList">
<div>
<p>
List of items
</p>
<h3>List of Items</h3>
@*SearchBar*@
</div>

@ -13,7 +13,7 @@ namespace myBlazorApp.Pages
public partial class Inventory
{
private List<Item> itemsInventory = new List<Item>();
private List<Item> items = new List<Item>();
private int totalItem;
@ -29,18 +29,6 @@ namespace myBlazorApp.Pages
[CascadingParameter]
public IModalService Modal { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
base.OnAfterRenderAsync(firstRender);
if (!firstRender)
{
return;
}
itemsInventory= await DataService.List(0, await DataService.Count());
StateHasChanged();
}
private async Task OnReadData(DataGridReadDataEventArgs<Item> e)
{
if (e.CancellationToken.IsCancellationRequested)
@ -50,7 +38,7 @@ namespace myBlazorApp.Pages
if (!e.CancellationToken.IsCancellationRequested)
{
itemsInventory = await DataService.List(e.Page, e.PageSize);
items = await DataService.List(e.Page, e.PageSize);
totalItem = await DataService.Count();
}
}

Loading…
Cancel
Save