"Action on list"
continuous-integration/drone/push Build is passing Details

master
Aurian JAULT 2 years ago
parent ecbafa58e8
commit 1f9d8fe450

@ -3,7 +3,7 @@
<h3>Inventory</h3> <h3>Inventory</h3>
<CascadingValue Value="@this"> <CascadingValue Value="@this">
<div class="css-grid"> <div class="css-grid">
@for(int i = 0; i<InventoryList.size;i++) @for(int i = 0; i<Models.InventoryList.size;i++)
{ {
@if (inventory.inventoryItems[i] != null) @if (inventory.inventoryItems[i] != null)
{ {

@ -7,7 +7,8 @@ namespace Blazor.Components
{ {
partial class Inventory partial class Inventory
{ {
public InventoryItem CurrentDragItem { get; set; } public Models.InventoryList inventory = new Models.InventoryList();
public Models.InventoryItem CurrentDragItem { get; set; }
public ObservableCollection<InventoryAction> Actions { get; set; } public ObservableCollection<InventoryAction> Actions { get; set; }
public Inventory() public Inventory()
@ -20,8 +21,6 @@ namespace Blazor.Components
return; return;
} }
[Parameter]
public InventoryList inventory { get; set; }
} }
} }

@ -4,13 +4,13 @@ namespace Blazor.Components
{ {
public class InventoryAction public class InventoryAction
{ {
public InventoryAction(String ac, int num,ItemInventory objet) { public InventoryAction(String ac, int num,Item objet) {
Action = ac; Action = ac;
Index = num; Index = num;
Item = objet; Item = objet;
} }
public string Action { get; set; } public string Action { get; set; }
public int Index { get; set; } public int Index { get; set; }
public ItemInventory Item { get; set; } public Item Item { get; set; }
} }
} }

@ -29,12 +29,34 @@ namespace Blazor.Components
[Inject] [Inject]
public IStringLocalizer<InventoryList> Localizer { get; set; } public IStringLocalizer<InventoryList> Localizer { get; set; }
[CascadingParameter]
public Inventory Parent { get; set; }
public void OnDragStart()
{
}
public void OnDrop()
{
Parent.CurrentDragItem = null;
return;
}
internal void OnDragEnter()
{
Parent.Actions.Add(new InventoryAction("Drag Enter", this.items[0].Id, items[0]));
}
internal void OnDragLeave()
{
Parent.Actions.Add(new InventoryAction("Drag Leave", this.items[0].Id, items[0]));
}
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
items = await DataService.getAll();
totalItem = await DataService.Count();
await base.OnInitializedAsync();
} }
} }
} }

@ -28,7 +28,7 @@ namespace Blazor.Components
Parent.CurrentDragItem = this.Items; Parent.CurrentDragItem = this.Items;
Parent.inventory.inventoryItems[this.Index] = null; Parent.inventory.inventoryItems[this.Index] = null;
this.NoDrop = false; this.NoDrop = false;
Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this)); Parent.Actions.Add(new InventoryAction("On drag start",this.Index,Items.item));
Parent.update(); Parent.update();
} }
@ -40,7 +40,7 @@ namespace Blazor.Components
this.Items = Parent.CurrentDragItem; this.Items = Parent.CurrentDragItem;
NoDrop = true; NoDrop = true;
Parent.CurrentDragItem = null; Parent.CurrentDragItem = null;
Parent.Actions.Add(new InventoryAction("On Drop",this.Index,this)); Parent.Actions.Add(new InventoryAction("On Drop",this.Index,Items.item));
return; return;
} }
if(Parent.CurrentDragItem == null) if(Parent.CurrentDragItem == null)
@ -52,7 +52,7 @@ namespace Blazor.Components
this.Items = Parent.CurrentDragItem; this.Items = Parent.CurrentDragItem;
this.NoDrop= true; this.NoDrop= true;
Parent.CurrentDragItem = null; Parent.CurrentDragItem = null;
Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this)); Parent.Actions.Add(new InventoryAction("On drag start",this.Index,Items.item));
return; return;
} }
else else
@ -61,7 +61,7 @@ namespace Blazor.Components
if (total >this.Items.item.StackSize) if (total >this.Items.item.StackSize)
{ {
this.Items.Stack = this.Items.item.StackSize; this.Items.Stack = this.Items.item.StackSize;
Parent.Actions.Add(new InventoryAction("On drag start",this.Index,this)); Parent.Actions.Add(new InventoryAction("On drag start",this.Index,Items.item));
return; return;
} }
else else
@ -73,12 +73,12 @@ namespace Blazor.Components
} }
internal void OnDragEnter() internal void OnDragEnter()
{ {
Parent.Actions.Add(new InventoryAction("Drag Enter",this.Index,this)); Parent.Actions.Add(new InventoryAction("Drag Enter",this.Index,Items.item));
} }
internal void OnDragLeave() internal void OnDragLeave()
{ {
Parent.Actions.Add(new InventoryAction("Drag Leave",this.Index,this)); Parent.Actions.Add(new InventoryAction("Drag Leave",this.Index,Items.item));
} }
} }
} }

@ -1,5 +1,5 @@
@page "/" @page "/"
@using Blazor.Components; @using Blazor.Components;
<div> <div>
<Inventory inventory="inventory"/> <Blazor.Components.Inventory inventory="inventory"/>
</div> </div>

@ -7,12 +7,6 @@ namespace Blazor.Pages
{ {
public partial class Index public partial class Index
{ {
/* TEST */
InventoryList inventory = new InventoryList();
[Inject] [Inject]
public IDataService DataService { get; set; } public IDataService DataService { get; set; }

@ -8,7 +8,9 @@
<div id="master"> <div id="master">
<div class="inventory"> <div class="inventory">
<span>Ici c'est l'inventaire</span> <span>
<Blazor.Components.Inventory/>
</span>
</div> </div>

Loading…
Cancel
Save