remrem 2 years ago
commit 8d0deba849

@ -43,7 +43,6 @@
<div class="col-12">
<div>Actions</div>
<div class="actions" id="actions">
</div>
</div>
</div>

@ -1,6 +1,7 @@
using Blazor.Models;
using Blazor.Pages;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System.Collections.ObjectModel;
namespace Blazor.Components
@ -11,6 +12,9 @@ namespace Blazor.Components
public Models.InventoryItem CurrentDragItem { get; set; }
public ObservableCollection<InventoryAction> Actions { get; set; }
[Inject]
internal IJSRuntime JavaScriptRuntime { get; set; }
public Inventory()
{
Actions = new ObservableCollection<InventoryAction>();

@ -4,3 +4,11 @@
display: grid;
width: 40%;
}
.actions {
border: 1px solid black;
height: 250px;
overflow: scroll;
}

@ -0,0 +1,16 @@
window.Inventory =
{
AddActions: function (data) {
data.forEach(element => {
var div = document.createElement('div');
div.innerHTML = 'Action: ' + element.action + ' - Index: ' + element.index;
if (element.item) {
div.innerHTML += ' - Item Name: ' + element.item.name;
}
document.getElementById('actions').appendChild(div);
});
}
}

@ -73,11 +73,13 @@ namespace Blazor.Components
}
internal void OnDragEnter()
{
if (this.Items == null) return;
Parent.Actions.Add(new InventoryAction("Drag Enter",this.Index,Items.item));
}
internal void OnDragLeave()
{
if (this.Items == null) return;
Parent.Actions.Add(new InventoryAction("Drag Leave",this.Index,Items.item));
}
}

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

@ -1,6 +1,5 @@
@page "/inventory"
@using Blazor.Components
@using Blazor.Models
<PageTitle>Counter</PageTitle>
@ -9,7 +8,7 @@
<div id="master">
<div class="inventory">
<span>
<Blazor.Components.Inventory/>
<Inventory/>
</span>
</div>
Loading…
Cancel
Save