Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added UI changes #143

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/AasxServer.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32002.261
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxServerCore", "AasxServerCore\AasxServerCore.csproj", "{7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}"
EndProject
Expand Down
179 changes: 101 additions & 78 deletions src/AasxServerBlazor/Pages/Tree.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,99 +10,122 @@ https://github.com/mwinkler/Blazor.Components/blob/master/LICENSE
@using static TreePage

<div class="uic-tree @(Visible ? "" : "uic-tree--hidden")">
@foreach (var node in Nodes ?? Enumerable.Empty<TNode>())
{
var nodeExpanded = ExpandedNodes.Contains(node);
var nodeSelected = node.Equals(SelectedNode);
var hasChilds = HasChildNodes(node);
// @("nodeExpanded " + nodeExpanded + " nodeSelected " + nodeSelected + " hasChilds " + hasChilds)

<div>
@if (hasChilds)
{
string iconId = "";
if (AasxServer.Program.htmlId)
iconId = HtmlId(node as Item) + "._icon";
<span class="uic-tree__icon" @onclick="@(() => OnToggleNode(node, !nodeExpanded))" id="@iconId">
<i class="@(nodeExpanded ? Style.CollapseNodeIconClass : Style.ExpandNodeIconClass)"></i>
</span>
}

<div class="uic-tree__title">
@{
string titleId = "";
if (AasxServer.Program.htmlId)
titleId = HtmlId(node as Item) + "._title";
<span class="@Style.NodeTitleClass @(nodeSelected ? Style.NodeTitleSelectedClass : "")" @onclick="@(() => OnSelectNode(node))" id="@titleId">
@TitleTemplate(node) @{ /* @(" " + node.GetHashCode() + " ") */ }
</span>
}
</div>

@if (hasChilds)
{
if (nodeExpanded)
{
<Tree Nodes="ChildSelector(node)"
TitleTemplate="TitleTemplate"
ChildSelector="ChildSelector"
ExpandedNodes="ExpandedNodes"
ExpandedNodesChanged="ExpandedNodesChanged"
SelectedNode="SelectedNode"
SelectedNodeChanged="SelectedNodeChanged"
Visible="nodeExpanded"
HasChildNodes="HasChildNodes"
HtmlId="HtmlId" />
}
}

</div>
}
@foreach (var node in Nodes ?? Enumerable.Empty<TNode>())
{
var nodeExpanded = ExpandedNodes.Contains(node);
var nodeSelected = node.Equals(SelectedNode);
var hasChilds = HasChildNodes(node);
var isAas = (node as Item).Tag is AdministrationShell;
var isSubmodel = (node as Item).Tag is Submodel;
var color = "";

if (isAas)
{
color = "#88A6D2";
}
else if (isSubmodel)
{
color = "#CBD8EB";
}
else
{
color = "#F4F4F5";
}
// @("nodeExpanded " + nodeExpanded + " nodeSelected " + nodeSelected + " hasChilds " + hasChilds)
@if (hasChilds)
{

string iconId = "";
if (AasxServer.Program.htmlId)
iconId = HtmlId(node as Item) + "._icon";
<div style="position: absolute; ">
<span class="uic-tree__icon pr-2" @onclick="@(() => OnToggleNode(node, !nodeExpanded))" id="@iconId">
<i class="@(nodeExpanded ? Style.CollapseNodeIconClass : Style.ExpandNodeIconClass)"></i>
</span>
</div>

}
<div class="flex space-x-4 flex-col mb-1 pr-4 ml-4 cursor-pointer @(nodeSelected ? "border-2 border-[#D42044]" : "") bg-[@(color)]" @onclick="@(() => OnSelectNode(node))">
<div class="flex flex-row">


<div>
@{
string titleId = "";
if (AasxServer.Program.htmlId)
titleId = HtmlId(node as Item) + "._title";
<span class="@Style.NodeTitleClass" id="@titleId">
@TitleTemplate(node) @{
/* @(" " + node.GetHashCode() + " ") */
}
</span>
}
</div>
</div>
</div>
@if (hasChilds)
{
if (nodeExpanded)
{
<Tree Nodes="ChildSelector(node)"
TitleTemplate="TitleTemplate"
ChildSelector="ChildSelector"
ExpandedNodes="ExpandedNodes"
ExpandedNodesChanged="ExpandedNodesChanged"
SelectedNode="SelectedNode"
SelectedNodeChanged="SelectedNodeChanged"
Visible="nodeExpanded"
HasChildNodes="HasChildNodes"
HtmlId="HtmlId" />
}
}

}

</div>

@code {

[Parameter] public IEnumerable<TNode> Nodes { get; set; }
[Parameter] public IEnumerable<TNode> Nodes { get; set; }

[Parameter] public RenderFragment<TNode> TitleTemplate { get; set; }
[Parameter] public RenderFragment<TNode> TitleTemplate { get; set; }

[Parameter] public TNode SelectedNode { get; set; }
[Parameter] public EventCallback<TNode> SelectedNodeChanged { get; set; }
[Parameter] public TNode SelectedNode { get; set; }
[Parameter] public EventCallback<TNode> SelectedNodeChanged { get; set; }

[Parameter] public Func<TNode, IEnumerable<TNode>> ChildSelector { get; set; }
[Parameter] public Func<TNode, IEnumerable<TNode>> ChildSelector { get; set; }

[Parameter] public IList<TNode> ExpandedNodes { get; set; } = new List<TNode>();
[Parameter] public EventCallback<IList<TNode>> ExpandedNodesChanged { get; set; }
[Parameter] public IList<TNode> ExpandedNodes { get; set; } = new List<TNode>();
[Parameter] public EventCallback<IList<TNode>> ExpandedNodesChanged { get; set; }

[Parameter] public TreeStyle Style { get; set; } = TreeStyle.Bootstrap;
[Parameter] public TreeStyle Style { get; set; } = TreeStyle.Bootstrap;

[Parameter] public bool Visible { get; set; } = true;
[Parameter] public bool Visible { get; set; } = true;

[Parameter] public Func<TNode, bool> HasChildNodes { get; set; } = node => true;
[Parameter] public Func<TNode, bool> HasChildNodes { get; set; } = node => true;

[Parameter] public Func<Item, string> HtmlId { get; set; } = node => "";
[Parameter] public Func<Item, string> HtmlId { get; set; } = node => "";

private void OnToggleNode(TNode node, bool expand)
{
var expanded = ExpandedNodes.Contains(node);
private void OnToggleNode(TNode node, bool expand)
{
var expanded = ExpandedNodes.Contains(node);

if (expanded && !expand)
{
ExpandedNodes.Remove(node);
ExpandedNodesChanged.InvokeAsync(ExpandedNodes);
}
else if (!expanded && expand)
{
ExpandedNodes.Add(node);
ExpandedNodesChanged.InvokeAsync(ExpandedNodes);
}
}
if (expanded && !expand)
{
ExpandedNodes.Remove(node);
ExpandedNodesChanged.InvokeAsync(ExpandedNodes);
}
else if (!expanded && expand)
{
ExpandedNodes.Add(node);
ExpandedNodesChanged.InvokeAsync(ExpandedNodes);
}
}

private void OnSelectNode(TNode node)
{
SelectedNode = node;
SelectedNodeChanged.InvokeAsync(node);
}
private void OnSelectNode(TNode node)
{
SelectedNode = node;
SelectedNodeChanged.InvokeAsync(node);
}

}
Loading