await Hover(child)" @onmouseout="async () => await UnHover(child)" class="col-auto p-1"
+ id="@child.Neuron.Id" style="@(this.GetStyleByCreationAuthor(child.Neuron.Validation.IsCurrentUserCreationAuthor) +
((int) tagUrlType > (int) UrlType.Unrecognized ? "; max-width: calc(100% - 90px)" : string.Empty))"
- userCreated="@(child.Neuron.Validation.IsCurrentUserCreationAuthor.ToString().ToLower())">
+ userCreated="@(child.Neuron.Validation.IsCurrentUserCreationAuthor.ToString().ToLower())">
@if (child.Neuron.Validation.RestrictionReasons.Count() > 0)
{
await Hover(child)" @onmouseout="async () => await UnHover(child)" class="col-auto p-1"
- id="@child.Neuron.Id" style="@(this.GetStyleByCreationAuthor(child.Neuron.Validation.IsCurrentUserCreationAuthor) +
+ id="@child.Neuron.Id" style="@(this.GetStyleByCreationAuthor(child.Neuron.Validation.IsCurrentUserCreationAuthor) +
((int) tagUrlType > (int) UrlType.Unrecognized ? "; max-width: calc(100% - 90px)" : string.Empty))"
userCreated="@(child.Neuron.Validation.IsCurrentUserCreationAuthor.ToString().ToLower())">
@if (child.Neuron.Validation.RestrictionReasons.Count() > 0)
@@ -139,9 +139,9 @@
@if (!this.ShouldRightJustifyBasedOnRoot(child))
{
@if (
- !string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) ||
- (child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl))
- )
+ !string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) ||
+ (child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl))
+ )
{
}
@@ -158,8 +158,8 @@
Hover(TreeNeuronViewModel child)
+ private async Task Hover(TreeNeuronViewModel child,bool Recursive = false,string Id ="")
{
try
{
if(this.Children.Contains(child))
{
// Highlight the current node
- await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
-
+
// Propagate hover to parent (existing functionality)
- await OnHover.InvokeAsync(child);
-
+ if (!Recursive)
+ {
+ await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
+
+ //await OnHover.InvokeAsync(child);
+ }
+
// Propagate hover to children if expanded
if(child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
{
foreach(var childNode in child.Children)
{
// Highlight each child node
+ if (childNode.Neuron.Id == Id)
+ continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
-
+
// Recursively highlight children of children if they're expanded
if(childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
{
// Find the child TreeView component and call its Hover method
- await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
+ //await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
+ await Hover(childNode, true,childNode.Neuron.Id);
+ // foreach(var childNode2 in childNode.Children)
+ // await JSRuntime.InvokeVoidAsync("hover", "g", childNode2.Neuron.Id, true, "highlightChildNode");
}
}
}
+
}
else
{
- child = this.Children.FirstOrDefault(x => x.Children.Contains(child));
- await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
- await OnHover.InvokeAsync(child);
+ //child = this.Children.FirstOrDefault(x => x.Children.Contains(child));
+ if (!Recursive)
+ {
+ await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
+ //await OnHover.InvokeAsync(child);
+ }
+ if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
+ {
+ foreach (var childNode in child.Children)
+ {
+ // Highlight each child node 61dbc74f-ba49-4c79-9854-d4fcc3e070ad
+ if (childNode.Neuron.Id == Id)
+ continue;
+ await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
+
+ // Recursively highlight children of children if they're expanded
+ if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
+ {
+ // Find the child TreeView component and call its Hover method
+ //await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
+ await Hover(childNode, true,childNode.Neuron.Id);
+ // foreach (var childNode2 in childNode.Children)
+ // await JSRuntime.InvokeVoidAsync("hover", "g", childNode2.Neuron.Id, true, "highlightChildNode");
+ }
+ }
+ }
}
return "";
}
@@ -369,17 +402,18 @@
}
}
- private async Task UnHover(TreeNeuronViewModel child)
+ private async Task UnHover(TreeNeuronViewModel child, bool Recursive = false, string Id = "")
{
try
{
if (this.Children.Contains(child))
{
// Remove highlight from current node
- await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, false, "highlightNode");
-
- // Propagate unhover to parent (existing functionality)
- await OnUnHover.InvokeAsync(child);
+ if (!Recursive)
+ {
+ await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, false, "highlightNode");
+ //await OnUnHover.InvokeAsync(child);
+ }
// Propagate unhover to children if expanded
if(child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
@@ -387,22 +421,42 @@
foreach(var childNode in child.Children)
{
// Remove highlight from each child node
+ if (childNode.Neuron.Id == Id)
+ continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
// Recursively remove highlight from children of children if they're expanded
if(childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
{
- // Find the child TreeView component and call its UnHover method
- await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
+ await UnHover(childNode, true, childNode.Neuron.Id);
}
}
}
}
else
{
- child = this.Children.FirstOrDefault(x => x.Children.Contains(child));
- await JSRuntime.InvokeVoidAsync("hover", "div", child.Neuron.Id, false, "highlightNode");
- await OnUnHover.InvokeAsync(child);
+ if (!Recursive)
+ {
+ await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, false, "highlightNode");
+ //await OnUnHover.InvokeAsync(child);
+ }
+
+ if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
+ {
+ foreach (var childNode in child.Children)
+ {
+ // Remove highlight from each child node
+ if (childNode.Neuron.Id == Id)
+ continue;
+ await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
+
+ // Recursively remove highlight from children of children if they're expanded
+ if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
+ {
+ await UnHover(childNode, true, childNode.Neuron.Id);
+ }
+ }
+ }
}
return "";
}
From 6fae269f6ce5a9bbeed77ee19701b8717d9dd753 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Fri, 11 Apr 2025 15:30:37 +0200
Subject: [PATCH 24/51] Finish #6 ticket
---
.../UI/Views/Blazor.Common/TreeView.razor | 60 ++++++++++---------
1 file changed, 32 insertions(+), 28 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 743991f..2c48833 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -338,7 +338,7 @@
{
await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
- //await OnHover.InvokeAsync(child);
+ await OnHover.InvokeAsync(child);
}
// Propagate hover to children if expanded
@@ -366,32 +366,35 @@
}
else
{
- //child = this.Children.FirstOrDefault(x => x.Children.Contains(child));
+ var newChild = this.Children.FirstOrDefault(x => x.Children.Contains(child));
if (!Recursive)
{
- await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
- //await OnHover.InvokeAsync(child);
+ await JSRuntime.InvokeVoidAsync("hover", "g", newChild.Neuron.Id, true, "highlightNode");
+ await OnHover.InvokeAsync(newChild);
}
- if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
+ else
{
- foreach (var childNode in child.Children)
+ if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
{
- // Highlight each child node 61dbc74f-ba49-4c79-9854-d4fcc3e070ad
- if (childNode.Neuron.Id == Id)
- continue;
- await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
-
- // Recursively highlight children of children if they're expanded
- if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
+ foreach (var childNode in child.Children)
{
- // Find the child TreeView component and call its Hover method
- //await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
- await Hover(childNode, true,childNode.Neuron.Id);
- // foreach (var childNode2 in childNode.Children)
- // await JSRuntime.InvokeVoidAsync("hover", "g", childNode2.Neuron.Id, true, "highlightChildNode");
+ // Highlight each child node 61dbc74f-ba49-4c79-9854-d4fcc3e070ad
+ if (childNode.Neuron.Id == Id)
+ continue;
+ await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
+
+ // Recursively highlight children of children if they're expanded
+ if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
+ {
+ // Find the child TreeView component and call its Hover method
+ //await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
+ await Hover(childNode, true, childNode.Neuron.Id);
+ // foreach (var childNode2 in childNode.Children)
+ // await JSRuntime.InvokeVoidAsync("hover", "g", childNode2.Neuron.Id, true, "highlightChildNode");
+ }
}
}
- }
+ }
}
return "";
}
@@ -408,24 +411,24 @@
{
if (this.Children.Contains(child))
{
- // Remove highlight from current node
+ //Remove highlight from current node
if (!Recursive)
{
await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, false, "highlightNode");
- //await OnUnHover.InvokeAsync(child);
+ await OnUnHover.InvokeAsync(child);
}
- // Propagate unhover to children if expanded
+ //Propagate unhover to children if expanded
if(child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
{
foreach(var childNode in child.Children)
{
- // Remove highlight from each child node
+ //Remove highlight from each child node
if (childNode.Neuron.Id == Id)
continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
- // Recursively remove highlight from children of children if they're expanded
+ //Recursively remove highlight from children of children if they're expanded
if(childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
{
await UnHover(childNode, true, childNode.Neuron.Id);
@@ -435,22 +438,23 @@
}
else
{
+ var newChild = this.Children.FirstOrDefault(x => x.Children.Contains(child));
if (!Recursive)
{
- await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, false, "highlightNode");
- //await OnUnHover.InvokeAsync(child);
+ await JSRuntime.InvokeVoidAsync("hover", "g", newChild.Neuron.Id, false, "highlightNode");
+ await OnUnHover.InvokeAsync(newChild);
}
if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
{
foreach (var childNode in child.Children)
{
- // Remove highlight from each child node
+ //Remove highlight from each child node
if (childNode.Neuron.Id == Id)
continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
- // Recursively remove highlight from children of children if they're expanded
+ //Recursively remove highlight from children of children if they're expanded
if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
{
await UnHover(childNode, true, childNode.Neuron.Id);
From 712f9cd0d5f77dcf29a8cfe497e24df174427cc8 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Sat, 12 Apr 2025 14:31:40 +0200
Subject: [PATCH 25/51] Fix Post issue
---
.../UI/Views/Blazor.Common/TreeView.razor | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 2c48833..a2f6884 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -338,7 +338,7 @@
{
await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
- await OnHover.InvokeAsync(child);
+ //await OnHover.InvokeAsync(child);
}
// Propagate hover to children if expanded
@@ -347,7 +347,7 @@
foreach(var childNode in child.Children)
{
// Highlight each child node
- if (childNode.Neuron.Id == Id)
+ if (childNode.Neuron.Id == Id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic)
continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
@@ -370,7 +370,7 @@
if (!Recursive)
{
await JSRuntime.InvokeVoidAsync("hover", "g", newChild.Neuron.Id, true, "highlightNode");
- await OnHover.InvokeAsync(newChild);
+ //await OnHover.InvokeAsync(newChild);
}
else
{
@@ -379,7 +379,7 @@
foreach (var childNode in child.Children)
{
// Highlight each child node 61dbc74f-ba49-4c79-9854-d4fcc3e070ad
- if (childNode.Neuron.Id == Id)
+ if (childNode.Neuron.Id == Id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic)
continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
@@ -415,13 +415,13 @@
if (!Recursive)
{
await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, false, "highlightNode");
- await OnUnHover.InvokeAsync(child);
+ //await OnUnHover.InvokeAsync(child);
}
//Propagate unhover to children if expanded
if(child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
{
- foreach(var childNode in child.Children)
+ foreach(var childNode in child.Children )
{
//Remove highlight from each child node
if (childNode.Neuron.Id == Id)
@@ -442,7 +442,7 @@
if (!Recursive)
{
await JSRuntime.InvokeVoidAsync("hover", "g", newChild.Neuron.Id, false, "highlightNode");
- await OnUnHover.InvokeAsync(newChild);
+ //await OnUnHover.InvokeAsync(newChild);
}
if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
From 733706ffc0745abe7c82a05fdf55d7899b1e702b Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Mon, 14 Apr 2025 17:48:58 +0200
Subject: [PATCH 26/51] Implement Elmer's comments
---
.../UI/Views/Blazor.Common/TreeView.razor | 53 ++++++++-----------
.../UI/Views/Blazor.Common/wwwroot/style.css | 2 +-
2 files changed, 22 insertions(+), 33 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index a2f6884..0190893 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -37,10 +37,7 @@
- @if (
- !string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) ||
- (child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl))
- )
+ @if (!string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) ||(child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl)))
{
}
@@ -90,7 +87,7 @@
}
}
-
await Hover(child)" @onmouseout="async () => await UnHover(child)" class="col-auto p-1"
+
await Hover(child)" @onmouseout="async () => await Unhover(child)" class="col-auto p-1"
id="@child.Neuron.Id" style="@(this.GetStyleByCreationAuthor(child.Neuron.Validation.IsCurrentUserCreationAuthor) +
((int) tagUrlType > (int) UrlType.Unrecognized ? "; max-width: calc(100% - 90px)" : string.Empty))"
userCreated="@(child.Neuron.Validation.IsCurrentUserCreationAuthor.ToString().ToLower())">
@@ -138,10 +135,7 @@
@if (!this.ShouldRightJustifyBasedOnRoot(child))
{
- @if (
- !string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) ||
- (child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl))
- )
+ @if (!string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) ||(child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl)))
{
}
@@ -159,7 +153,7 @@
OnHover { get; set; }
[Parameter]
- public EventCallback OnUnHover { get; set; }
+ public EventCallback OnUnhover { get; set; }
private RenderDirectionValue renderDirection;
[Parameter]
@@ -337,8 +331,6 @@
if (!Recursive)
{
await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
-
- //await OnHover.InvokeAsync(child);
}
// Propagate hover to children if expanded
@@ -347,7 +339,7 @@
foreach(var childNode in child.Children)
{
// Highlight each child node
- if (childNode.Neuron.Id == Id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic)
+ if (HoverCore(childNode,Id))
continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
@@ -355,10 +347,7 @@
if(childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
{
// Find the child TreeView component and call its Hover method
- //await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
await Hover(childNode, true,childNode.Neuron.Id);
- // foreach(var childNode2 in childNode.Children)
- // await JSRuntime.InvokeVoidAsync("hover", "g", childNode2.Neuron.Id, true, "highlightChildNode");
}
}
}
@@ -370,7 +359,6 @@
if (!Recursive)
{
await JSRuntime.InvokeVoidAsync("hover", "g", newChild.Neuron.Id, true, "highlightNode");
- //await OnHover.InvokeAsync(newChild);
}
else
{
@@ -379,7 +367,7 @@
foreach (var childNode in child.Children)
{
// Highlight each child node 61dbc74f-ba49-4c79-9854-d4fcc3e070ad
- if (childNode.Neuron.Id == Id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic)
+ if (HoverCore(childNode,Id))
continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
@@ -387,10 +375,7 @@
if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
{
// Find the child TreeView component and call its Hover method
- //await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
await Hover(childNode, true, childNode.Neuron.Id);
- // foreach (var childNode2 in childNode.Children)
- // await JSRuntime.InvokeVoidAsync("hover", "g", childNode2.Neuron.Id, true, "highlightChildNode");
}
}
}
@@ -405,7 +390,7 @@
}
}
- private async Task UnHover(TreeNeuronViewModel child, bool Recursive = false, string Id = "")
+ private async Task Unhover(TreeNeuronViewModel child, bool Recursive = false, string Id = "")
{
try
{
@@ -415,10 +400,10 @@
if (!Recursive)
{
await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, false, "highlightNode");
- //await OnUnHover.InvokeAsync(child);
+ //await OnUnhover.InvokeAsync(child);
}
-
- //Propagate unhover to children if expanded
+
+ //Propagate Unhover to children if expanded
if(child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
{
foreach(var childNode in child.Children )
@@ -427,11 +412,11 @@
if (childNode.Neuron.Id == Id)
continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
-
+
//Recursively remove highlight from children of children if they're expanded
if(childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
{
- await UnHover(childNode, true, childNode.Neuron.Id);
+ await Unhover(childNode, true, childNode.Neuron.Id);
}
}
}
@@ -442,9 +427,9 @@
if (!Recursive)
{
await JSRuntime.InvokeVoidAsync("hover", "g", newChild.Neuron.Id, false, "highlightNode");
- //await OnUnHover.InvokeAsync(newChild);
+ //await OnUnhover.InvokeAsync(newChild);
}
-
+
if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
{
foreach (var childNode in child.Children)
@@ -453,11 +438,11 @@
if (childNode.Neuron.Id == Id)
continue;
await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
-
+
//Recursively remove highlight from children of children if they're expanded
if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
{
- await UnHover(childNode, true, childNode.Neuron.Id);
+ await Unhover(childNode, true, childNode.Neuron.Id);
}
}
}
@@ -471,6 +456,10 @@
}
}
+ private bool HoverCore(TreeNeuronViewModel childNode,string Id)
+ {
+ return childNode.Neuron.Id == Id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic;
+ }
private UrlType GetUrlType(string url)
{
UrlType result = UrlType.Invalid;
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/wwwroot/style.css b/src/main/Port.Adapter/UI/Views/Blazor.Common/wwwroot/style.css
index 34c0862..1917572 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/wwwroot/style.css
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/wwwroot/style.css
@@ -6,7 +6,7 @@
/* blazor.common - treeview */
.blue {
- fill: #0781fc !important;
+ fill: #1E90FF !important;
}
.lightblue {
From fe8fa97abfaab5a7bdfd9c350b77d74894798ec8 Mon Sep 17 00:00:00 2001
From: Abdulrahman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Wed, 16 Apr 2025 10:51:35 +0200
Subject: [PATCH 27/51] Append Clean Code for hover and unhover feature
---
.../UI/Views/Blazor.Common/TreeView.razor | 169 ++++++------------
1 file changed, 51 insertions(+), 118 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 0190893..f0aeb61 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -319,147 +319,80 @@
"";
}
- private async Task Hover(TreeNeuronViewModel child,bool Recursive = false,string Id ="")
+ private async Task Hover(TreeNeuronViewModel child, bool recursive = false, string id = "")
{
try
{
- if(this.Children.Contains(child))
- {
- // Highlight the current node
-
- // Propagate hover to parent (existing functionality)
- if (!Recursive)
- {
- await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, true, "highlightNode");
- }
-
- // Propagate hover to children if expanded
- if(child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
- {
- foreach(var childNode in child.Children)
- {
- // Highlight each child node
- if (HoverCore(childNode,Id))
- continue;
- await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
-
- // Recursively highlight children of children if they're expanded
- if(childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
- {
- // Find the child TreeView component and call its Hover method
- await Hover(childNode, true,childNode.Neuron.Id);
- }
- }
- }
-
- }
- else
- {
- var newChild = this.Children.FirstOrDefault(x => x.Children.Contains(child));
- if (!Recursive)
- {
- await JSRuntime.InvokeVoidAsync("hover", "g", newChild.Neuron.Id, true, "highlightNode");
- }
- else
- {
- if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
- {
- foreach (var childNode in child.Children)
- {
- // Highlight each child node 61dbc74f-ba49-4c79-9854-d4fcc3e070ad
- if (HoverCore(childNode,Id))
- continue;
- await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, true, "highlightChildNode");
-
- // Recursively highlight children of children if they're expanded
- if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
- {
- // Find the child TreeView component and call its Hover method
- await Hover(childNode, true, childNode.Neuron.Id);
- }
- }
- }
- }
- }
- return "";
+ return await ProcessHoverOrUnhover(child, recursive, id, true);
}
- catch(Exception ex)
+ catch (Exception ex)
{
- var x = ex.Message;
- return x;
+ return ex.Message;
}
}
- private async Task Unhover(TreeNeuronViewModel child, bool Recursive = false, string Id = "")
+ private async Task Unhover(TreeNeuronViewModel child, bool recursive = false, string id = "")
{
try
{
- if (this.Children.Contains(child))
- {
- //Remove highlight from current node
- if (!Recursive)
- {
- await JSRuntime.InvokeVoidAsync("hover", "g", child.Neuron.Id, false, "highlightNode");
- //await OnUnhover.InvokeAsync(child);
- }
+ return await ProcessHoverOrUnhover(child, recursive, id, false);
+ }
+ catch (Exception ex)
+ {
+ return ex.Message;
+ }
+ }
- //Propagate Unhover to children if expanded
- if(child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
- {
- foreach(var childNode in child.Children )
- {
- //Remove highlight from each child node
- if (childNode.Neuron.Id == Id)
- continue;
- await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
-
- //Recursively remove highlight from children of children if they're expanded
- if(childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
- {
- await Unhover(childNode, true, childNode.Neuron.Id);
- }
- }
- }
+ private async Task ProcessHoverOrUnhover(TreeNeuronViewModel child, bool recursive, string id, bool isHover)
+ {
+ if (!this.Children.Contains(child))
+ {
+ var newChild = this.Children.FirstOrDefault(x => x.Children.Contains(child));
+ if (newChild != null)
+ {
+ child = newChild;
}
- else
+ }
+
+ await HandleNodeHighlight(child, recursive, id, isHover);
+
+ return "";
+ }
+
+ private async Task HandleNodeHighlight(TreeNeuronViewModel node, bool recursive, string id, bool isHover)
+ {
+ // Highlight or unhighlight the current node
+ if (!recursive)
+ {
+ await JSRuntime.InvokeVoidAsync("hover", "g", node.Neuron.Id, isHover, "highlightNode");
+ }
+
+ // Process children if the node is expanded and has children
+ if (node.ExpansionState == ExpansionState.Expanded && node.Children?.Any() == true)
+ {
+ foreach (var childNode in node.Children)
{
- var newChild = this.Children.FirstOrDefault(x => x.Children.Contains(child));
- if (!Recursive)
- {
- await JSRuntime.InvokeVoidAsync("hover", "g", newChild.Neuron.Id, false, "highlightNode");
- //await OnUnhover.InvokeAsync(newChild);
- }
+ // Skip processing if the child node matches the given ID
+ if (childNode.Neuron.Id == id || HoverCore(childNode, id))
+ continue;
+
+ // Highlight or unhighlight the child node
+ await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, isHover, "highlightChildNode");
- if (child.ExpansionState == ExpansionState.Expanded && child.Children != null && child.Children.Any())
+ // Recursively process children of the child node if expanded
+ if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children?.Any() == true)
{
- foreach (var childNode in child.Children)
- {
- //Remove highlight from each child node
- if (childNode.Neuron.Id == Id)
- continue;
- await JSRuntime.InvokeVoidAsync("hover", "g", childNode.Neuron.Id, false, "highlightChildNode");
-
- //Recursively remove highlight from children of children if they're expanded
- if (childNode.ExpansionState == ExpansionState.Expanded && childNode.Children != null && childNode.Children.Any())
- {
- await Unhover(childNode, true, childNode.Neuron.Id);
- }
- }
+ await HandleNodeHighlight(childNode, true, id, isHover);
}
}
- return "";
- }
- catch (Exception ex)
- {
- var x = ex.Message;
- return x;
}
}
- private bool HoverCore(TreeNeuronViewModel childNode,string Id)
+ private bool HoverCore(TreeNeuronViewModel childNode, string id)
{
- return childNode.Neuron.Id == Id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic;
+ return childNode.Neuron.Id == id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic;
}
+
private UrlType GetUrlType(string url)
{
UrlType result = UrlType.Invalid;
From 2e4b39a6784596e167b1ea51903a04518166f1e1 Mon Sep 17 00:00:00 2001
From: Abdulrahman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Wed, 16 Apr 2025 17:32:57 +0200
Subject: [PATCH 28/51] Implement Elmer's new comments
---
.../UI/Views/Blazor.Common/TreeView.razor | 26 +++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index f0aeb61..be59263 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -37,7 +37,7 @@
- @if (!string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) ||(child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl)))
+ @if (!string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) || (child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl)))
{
}
@@ -88,9 +88,9 @@
}
await Hover(child)" @onmouseout="async () => await Unhover(child)" class="col-auto p-1"
- id="@child.Neuron.Id" style="@(this.GetStyleByCreationAuthor(child.Neuron.Validation.IsCurrentUserCreationAuthor) +
+ id="@child.Neuron.Id" style="@(this.GetStyleByCreationAuthor(child.Neuron.Validation.IsCurrentUserCreationAuthor) +
((int) tagUrlType > (int) UrlType.Unrecognized ? "; max-width: calc(100% - 90px)" : string.Empty))"
- userCreated="@(child.Neuron.Validation.IsCurrentUserCreationAuthor.ToString().ToLower())">
+ userCreated="@(child.Neuron.Validation.IsCurrentUserCreationAuthor.ToString().ToLower())">
@if (child.Neuron.Validation.RestrictionReasons.Count() > 0)
{
@@ -135,7 +135,7 @@
@if (!this.ShouldRightJustifyBasedOnRoot(child))
{
- @if (!string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) ||(child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl)))
+ @if (!string.IsNullOrWhiteSpace(child.Neuron.ExternalReferenceUrl) || (child.Neuron.Terminal != null && !string.IsNullOrWhiteSpace(child.Neuron.Terminal.ExternalReferenceUrl)))
{
}
@@ -151,15 +151,15 @@
{
}
From 3f97726891e2b7f25898ba0ace88b97712649d08 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Fri, 25 Apr 2025 14:58:46 +0300
Subject: [PATCH 29/51] Implement Elmer's notes
---
.../UI/Views/Blazor.Common/TreeView.razor | 26 +++++++------------
.../UI/Views/Blazor.Common/wwwroot/style.css | 2 +-
2 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index be59263..cca7dd2 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -319,31 +319,30 @@
"";
}
- private async Task
Hover(TreeNeuronViewModel child, bool recursive = false, string id = "")
+ private async Task Hover(TreeNeuronViewModel child, bool recursive = false, string id = "")
{
try
{
- return await ProcessHoverOrUnhover(child, recursive, id, true);
+ await HoverCore(child, recursive, id, true);
}
- catch (Exception ex)
+ catch (Exception)
{
- return ex.Message;
+
}
}
- private async Task Unhover(TreeNeuronViewModel child, bool recursive = false, string id = "")
+ private async Task Unhover(TreeNeuronViewModel child, bool recursive = false, string id = "")
{
try
{
- return await ProcessHoverOrUnhover(child, recursive, id, false);
+ await HoverCore(child, recursive, id, false);
}
- catch (Exception ex)
+ catch (Exception)
{
- return ex.Message;
}
}
- private async Task ProcessHoverOrUnhover(TreeNeuronViewModel child, bool recursive, string id, bool isHover)
+ private async Task HoverCore(TreeNeuronViewModel child, bool recursive, string id, bool isHover)
{
if (!this.Children.Contains(child))
{
@@ -355,8 +354,6 @@
}
await HandleNodeHighlight(child, recursive, id, isHover);
-
- return "";
}
private async Task HandleNodeHighlight(TreeNeuronViewModel node, bool recursive, string id, bool isHover)
@@ -373,7 +370,7 @@
foreach (var childNode in node.Children)
{
// Skip processing if the child node matches the given ID
- if (childNode.Neuron.Id == id || HoverCore(childNode, id))
+ if (childNode.Neuron.Id == id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic)
continue;
// Highlight or unhighlight the child node
@@ -388,11 +385,6 @@
}
}
- private bool HoverCore(TreeNeuronViewModel childNode, string id)
- {
- return childNode.Neuron.Id == id || childNode.Neuron.Type == Library.Common.RelativeType.Presynaptic;
- }
-
private UrlType GetUrlType(string url)
{
UrlType result = UrlType.Invalid;
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/wwwroot/style.css b/src/main/Port.Adapter/UI/Views/Blazor.Common/wwwroot/style.css
index 1917572..146e50f 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/wwwroot/style.css
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/wwwroot/style.css
@@ -10,7 +10,7 @@
}
.lightblue {
- fill: #22b0e9!important;
+ fill: #6ed1f2 !important;
}
/* blazor.common */
From fa8e171f54c902d4a1e48ce2aac66210786e37e4 Mon Sep 17 00:00:00 2001
From: Abdulrahman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Sun, 27 Apr 2025 14:50:25 +0300
Subject: [PATCH 30/51] Remove unused try catch
---
.../UI/Views/Blazor.Common/TreeView.razor | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index cca7dd2..ad3c469 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -321,25 +321,12 @@
private async Task Hover(TreeNeuronViewModel child, bool recursive = false, string id = "")
{
- try
- {
- await HoverCore(child, recursive, id, true);
- }
- catch (Exception)
- {
-
- }
+ await HoverCore(child, recursive, id, true);
}
private async Task Unhover(TreeNeuronViewModel child, bool recursive = false, string id = "")
{
- try
- {
- await HoverCore(child, recursive, id, false);
- }
- catch (Exception)
- {
- }
+ await HoverCore(child, recursive, id, false);
}
private async Task HoverCore(TreeNeuronViewModel child, bool recursive, string id, bool isHover)
From f1e2f276a0e72d1c7654a4c34010e31cdb342af3 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Fri, 9 May 2025 16:06:17 +0300
Subject: [PATCH 31/51] Fix expand issue
---
.../Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs | 8 ++++++++
.../Port.Adapter/UI/Views/Blazor.Common/TreeView.razor | 3 ++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index 16a7197..c2cad44 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -56,6 +56,14 @@ public async Task Toggle()
}
}
+ public bool IsChild(string id)
+ {
+ var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id));
+ if(result)
+ return result;
+ return result;
+ }
+
public void ConfigureExpandTimer(double interval, ElapsedEventHandler handler)
{
this.expandPostsynapticsUntilExternalReferencesTimer.Interval = interval;
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index ad3c469..e80edee 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -290,7 +290,8 @@
{
foreach (var child in this.Children)
{
- if (child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ if (this.SelectedNeuron.IsChild(child.Neuron.Id) &&
+ child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
{
await InvokeAsync(() => child.Toggle());
From ee57fe98708163e6f8e8ce958726395072c1ef6d Mon Sep 17 00:00:00 2001
From: Abdulrahman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Sun, 11 May 2025 02:54:38 +0300
Subject: [PATCH 32/51] Revert "Fix expand issue"
This reverts commit f1e2f276a0e72d1c7654a4c34010e31cdb342af3.
---
.../Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs | 8 --------
.../Port.Adapter/UI/Views/Blazor.Common/TreeView.razor | 3 +--
2 files changed, 1 insertion(+), 10 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index c2cad44..16a7197 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -56,14 +56,6 @@ public async Task Toggle()
}
}
- public bool IsChild(string id)
- {
- var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id));
- if(result)
- return result;
- return result;
- }
-
public void ConfigureExpandTimer(double interval, ElapsedEventHandler handler)
{
this.expandPostsynapticsUntilExternalReferencesTimer.Interval = interval;
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index e80edee..ad3c469 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -290,8 +290,7 @@
{
foreach (var child in this.Children)
{
- if (this.SelectedNeuron.IsChild(child.Neuron.Id) &&
- child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ if (child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
{
await InvokeAsync(() => child.Toggle());
From fbc6e98247a5f5bec8ffa76af2c61361838015ac Mon Sep 17 00:00:00 2001
From: Abdulrahman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Sun, 11 May 2025 02:58:13 +0300
Subject: [PATCH 33/51] Fix expand issue
---
src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs | 6 ++++++
src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index 16a7197..aeb1665 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -83,5 +83,11 @@ public bool IsExpandTimerEnabled()
{
return this.expandPostsynapticsUntilExternalReferencesTimer.Enabled;
}
+
+ public bool IsChild(string id)
+ {
+ var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id));
+ return result;
+ }
}
}
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index ad3c469..b2a0564 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -290,7 +290,8 @@
{
foreach (var child in this.Children)
{
- if (child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ if (this.SelectedNeuron.IsChild(child.Neuron.Id) &&
+ child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
{
await InvokeAsync(() => child.Toggle());
From 21397faef54f0d0c115846fcb990df261814ca0b Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Tue, 27 May 2025 00:19:08 +0300
Subject: [PATCH 34/51] implement Expand Until Farthest Presynaptic
---
.../UI/ViewModels/TreeNeuronViewModel.cs | 41 +++++++++-
.../UI/Views/Blazor.Common/TreeView.razor | 74 ++++++++++++++-----
2 files changed, 94 insertions(+), 21 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index c2cad44..ffe38c5 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -14,6 +14,7 @@ public class TreeNeuronViewModel
private string avatarUrl;
private INeuronQueryService neuronQueryService;
private Timer expandPostsynapticsUntilExternalReferencesTimer;
+ private Timer expandUntilFarthestPresynapticTimer;
public TreeNeuronViewModel(Neuron neuron, string avatarUrl, INeuronQueryService neuronQueryService)
{
@@ -22,6 +23,7 @@ public TreeNeuronViewModel(Neuron neuron, string avatarUrl, INeuronQueryService
this.neuronQueryService = neuronQueryService;
this.Children = new List();
this.expandPostsynapticsUntilExternalReferencesTimer = new Timer();
+ this.expandUntilFarthestPresynapticTimer = new Timer();
}
public IList Children { get; set; }
@@ -41,7 +43,8 @@ public async Task Toggle()
{
NeuronQuery.TryParse(result.QueryString, out NeuronQuery query);
- var childrenQuery = new NeuronQuery() {
+ var childrenQuery = new NeuronQuery()
+ {
PageSize = Constants.TreeNodeChildrenQueryPageSize,
RelativeValues = query != null ? query.RelativeValues : null
};
@@ -91,5 +94,41 @@ public bool IsExpandTimerEnabled()
{
return this.expandPostsynapticsUntilExternalReferencesTimer.Enabled;
}
+
+ public void ConfigureExpandUntilFarthestPresynapticTimer(double interval, ElapsedEventHandler handler)
+ {
+ this.expandUntilFarthestPresynapticTimer.Interval = interval;
+ this.expandUntilFarthestPresynapticTimer.Elapsed -= handler;
+ this.expandUntilFarthestPresynapticTimer.Elapsed += handler;
+ }
+
+ public void StartExpandUntilFarthestPresynapticTimer()
+ {
+ this.expandUntilFarthestPresynapticTimer.Start();
+ }
+
+ public void StopExpandUntilFarthestPresynapticTimer()
+ {
+ this.expandUntilFarthestPresynapticTimer.Stop();
+ }
+
+ public void RestartExpandUntilFarthestPresynapticTimer()
+ {
+ this.expandUntilFarthestPresynapticTimer.Enabled = false;
+ this.StartExpandUntilFarthestPresynapticTimer();
+ }
+
+ public bool IsExpandUntilFarthestPresynapticTimerEnabled()
+ {
+ return this.expandUntilFarthestPresynapticTimer.Enabled;
+ }
+
+ public bool IsPresynapticChild(string id)
+ {
+ var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Presynaptic) || x.IsPresynapticChild(id));
+ if (result)
+ return result;
+ return result;
+ }
}
}
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index e80edee..9b23655 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -260,41 +260,75 @@
{
if (
this.selectedNeuron != null && string.IsNullOrEmpty(this.selectedNeuron.Neuron.ExternalReferenceUrl) &&
- this.selectedNeuron.IsExpandTimerEnabled() &&
(
this.selectedNeuron.ExpansionState == ExpansionState.Collapsed ||
!this.Children.Any(c => c.ExpansionState == ExpansionState.Expanded)
)
)
{
- this.selectedNeuron.RestartExpandTimer();
-
- // if children contains selected neuron
- if (
- this.Children.Any(
- x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
- x.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
- )
- )
+ if (this.selectedNeuron.IsExpandTimerEnabled())
{
+ this.selectedNeuron.RestartExpandTimer();
+
+ // if children contains selected neuron
if (
- this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
+ this.Children.Any(
+ x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
+ x.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
+ )
)
{
- await InvokeAsync(() => this.SelectedNeuron.Toggle());
+ if (
+ this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
+ )
+ {
+ await InvokeAsync(() => this.SelectedNeuron.Toggle());
+ }
+ }
+ else
+ {
+ foreach (var child in this.Children)
+ {
+ if (this.SelectedNeuron.IsChild(child.Neuron.Id) &&
+ child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
+ {
+ await InvokeAsync(() => child.Toggle());
+ }
+ }
}
}
- else
+ else if (this.selectedNeuron.IsExpandUntilFarthestPresynapticTimerEnabled())
{
- foreach (var child in this.Children)
+ this.selectedNeuron.RestartExpandUntilFarthestPresynapticTimer();
+ if (
+ this.Children.Any(
+ x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
+ x.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
+ )
+ )
+ {
+ if (
+ this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
+ )
+ {
+ await InvokeAsync(() => this.SelectedNeuron.Toggle());
+ }
+ }
+ else
{
- if (this.SelectedNeuron.IsChild(child.Neuron.Id) &&
- child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
+ foreach (var child in this.Children)
{
- await InvokeAsync(() => child.Toggle());
+ if (this.SelectedNeuron.IsPresynapticChild(child.Neuron.Id) &&
+ child.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
+ {
+ await InvokeAsync(() => child.Toggle());
+ }
}
}
}
From 184dc8219a0d7d6b747228ec700211d70c84028e Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Tue, 27 May 2025 10:25:57 +0300
Subject: [PATCH 35/51] Update TreeNeuronViewModel
---
.../UI/ViewModels/TreeNeuronViewModel.cs | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index cc6cb8b..42175e7 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -59,6 +59,15 @@ public async Task Toggle()
}
}
+
+ public bool IsChild(string id)
+ {
+ var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id));
+ if (result)
+ return result;
+ return result;
+ }
+
public void ConfigureExpandTimer(double interval, ElapsedEventHandler handler)
{
this.expandPostsynapticsUntilExternalReferencesTimer.Interval = interval;
@@ -118,11 +127,6 @@ public bool IsExpandUntilFarthestPresynapticTimerEnabled()
public bool IsPresynapticChild(string id)
{
var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Presynaptic) || x.IsPresynapticChild(id));
- if (result)
- return result;
- public bool IsChild(string id)
- {
- var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id));
return result;
}
}
From ff3dccf7c5c1e236badf4ef47d6d8ac439ecc8e5 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Wed, 28 May 2025 21:31:56 +0300
Subject: [PATCH 36/51] Inhance Code Reusabilty
---
.../UI/ViewModels/TreeNeuronViewModel.cs | 82 ++++-------
.../UI/Views/Blazor.Common/TreeView.razor | 130 ++++++++++--------
2 files changed, 102 insertions(+), 110 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index 42175e7..f1375d4 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -9,12 +9,19 @@
namespace ei8.Cortex.Diary.Port.Adapter.UI.ViewModels
{
+ public enum ExpansionType
+ {
+ None,
+ PostsynapticUntilExternalReferences,
+ FarthestPresynaptic
+ }
+
public class TreeNeuronViewModel
{
private string avatarUrl;
private INeuronQueryService neuronQueryService;
- private Timer expandPostsynapticsUntilExternalReferencesTimer;
- private Timer expandUntilFarthestPresynapticTimer;
+ private Timer expansionTimer;
+ private ExpansionType currentExpansionType = ExpansionType.None;
public TreeNeuronViewModel(Neuron neuron, string avatarUrl, INeuronQueryService neuronQueryService)
{
@@ -22,8 +29,7 @@ public TreeNeuronViewModel(Neuron neuron, string avatarUrl, INeuronQueryService
this.avatarUrl = avatarUrl;
this.neuronQueryService = neuronQueryService;
this.Children = new List();
- this.expandPostsynapticsUntilExternalReferencesTimer = new Timer();
- this.expandUntilFarthestPresynapticTimer = new Timer();
+ this.expansionTimer = new Timer();
}
public IList Children { get; set; }
@@ -32,6 +38,8 @@ public TreeNeuronViewModel(Neuron neuron, string avatarUrl, INeuronQueryService
public ExpansionState ExpansionState { get; private set; }
+ public ExpansionType CurrentExpansionType => this.currentExpansionType;
+
public async Task Toggle()
{
this.ExpansionState = this.ExpansionState == ExpansionState.Collapsed ? ExpansionState.Expanding : ExpansionState.Collapsed;
@@ -41,7 +49,6 @@ public async Task Toggle()
var children = new List();
if (Library.Client.QueryUrl.TryParse(this.avatarUrl, out QueryUrl result))
{
-
NeuronQuery.TryParse(result.QueryString, out NeuronQuery query);
var childrenQuery = new NeuronQuery()
{
@@ -59,69 +66,40 @@ public async Task Toggle()
}
}
-
- public bool IsChild(string id)
- {
- var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id));
- if (result)
- return result;
- return result;
- }
-
- public void ConfigureExpandTimer(double interval, ElapsedEventHandler handler)
+ public void ConfigureExpansionTimer(ExpansionType type, double interval, ElapsedEventHandler handler)
{
- this.expandPostsynapticsUntilExternalReferencesTimer.Interval = interval;
- this.expandPostsynapticsUntilExternalReferencesTimer.Elapsed -= handler;
- this.expandPostsynapticsUntilExternalReferencesTimer.Elapsed += handler;
+ this.currentExpansionType = type;
+ this.expansionTimer.Interval = interval;
+ this.expansionTimer.Elapsed -= handler;
+ this.expansionTimer.Elapsed += handler;
}
- public void StartExpandTimer()
+ public void StartExpansionTimer()
{
- this.expandPostsynapticsUntilExternalReferencesTimer.Start();
+ this.expansionTimer.Start();
}
- public void StopExpandTimer()
+ public void StopExpansionTimer()
{
- this.expandPostsynapticsUntilExternalReferencesTimer.Stop();
+ this.expansionTimer.Stop();
+ this.currentExpansionType = ExpansionType.None;
}
- public void RestartExpandTimer()
+ public void RestartExpansionTimer()
{
- this.expandPostsynapticsUntilExternalReferencesTimer.Enabled = false;
- this.StartExpandTimer();
+ this.expansionTimer.Enabled = false;
+ this.StartExpansionTimer();
}
- public bool IsExpandTimerEnabled()
+ public bool IsExpansionTimerEnabled()
{
- return this.expandPostsynapticsUntilExternalReferencesTimer.Enabled;
+ return this.expansionTimer.Enabled;
}
- public void ConfigureExpandUntilFarthestPresynapticTimer(double interval, ElapsedEventHandler handler)
- {
- this.expandUntilFarthestPresynapticTimer.Interval = interval;
- this.expandUntilFarthestPresynapticTimer.Elapsed -= handler;
- this.expandUntilFarthestPresynapticTimer.Elapsed += handler;
- }
-
- public void StartExpandUntilFarthestPresynapticTimer()
- {
- this.expandUntilFarthestPresynapticTimer.Start();
- }
-
- public void StopExpandUntilFarthestPresynapticTimer()
- {
- this.expandUntilFarthestPresynapticTimer.Stop();
- }
-
- public void RestartExpandUntilFarthestPresynapticTimer()
- {
- this.expandUntilFarthestPresynapticTimer.Enabled = false;
- this.StartExpandUntilFarthestPresynapticTimer();
- }
-
- public bool IsExpandUntilFarthestPresynapticTimerEnabled()
+ public bool IsChild(string id)
{
- return this.expandUntilFarthestPresynapticTimer.Enabled;
+ var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id));
+ return result;
}
public bool IsPresynapticChild(string id)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 9b23655..6e3f374 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -266,75 +266,89 @@
)
)
{
- if (this.selectedNeuron.IsExpandTimerEnabled())
+ if (this.selectedNeuron.IsExpansionTimerEnabled())
{
- this.selectedNeuron.RestartExpandTimer();
-
- // if children contains selected neuron
- if (
- this.Children.Any(
- x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
- x.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
- )
- )
- {
- if (
- this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
- )
- {
- await InvokeAsync(() => this.SelectedNeuron.Toggle());
- }
- }
- else
+ this.selectedNeuron.RestartExpansionTimer();
+
+ switch (this.selectedNeuron.CurrentExpansionType)
{
- foreach (var child in this.Children)
- {
- if (this.SelectedNeuron.IsChild(child.Neuron.Id) &&
- child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
- {
- await InvokeAsync(() => child.Toggle());
- }
- }
+ case ExpansionType.PostsynapticUntilExternalReferences:
+ await HandlePostsynapticExpansion();
+ break;
+ case ExpansionType.FarthestPresynaptic:
+ await HandlePresynapticExpansion();
+ break;
}
}
- else if (this.selectedNeuron.IsExpandUntilFarthestPresynapticTimerEnabled())
+ }
+
+ await base.OnParametersSetAsync();
+ }
+
+ private async Task HandlePostsynapticExpansion()
+ {
+ // if children contains selected neuron
+ if (
+ this.Children.Any(
+ x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
+ x.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
+ )
+ )
+ {
+ if (
+ this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
+ )
+ {
+ await InvokeAsync(() => this.SelectedNeuron.Toggle());
+ }
+ }
+ else
+ {
+ foreach (var child in this.Children)
{
- this.selectedNeuron.RestartExpandUntilFarthestPresynapticTimer();
- if (
- this.Children.Any(
- x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
- x.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
- string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
- )
- )
+ if (this.SelectedNeuron.IsChild(child.Neuron.Id) &&
+ child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
+ string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
{
- if (
- this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
- string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
- )
- {
- await InvokeAsync(() => this.SelectedNeuron.Toggle());
- }
+ await InvokeAsync(() => child.Toggle());
}
- else
+ }
+ }
+ }
+
+ private async Task HandlePresynapticExpansion()
+ {
+ // if children contains selected neuron
+ if (
+ this.Children.Any(
+ x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
+ x.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
+ )
+ )
+ {
+ if (
+ this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
+ )
+ {
+ await InvokeAsync(() => this.SelectedNeuron.Toggle());
+ }
+ }
+ else
+ {
+ foreach (var child in this.Children)
+ {
+ if (this.SelectedNeuron.IsPresynapticChild(child.Neuron.Id) &&
+ child.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
{
- foreach (var child in this.Children)
- {
- if (this.SelectedNeuron.IsPresynapticChild(child.Neuron.Id) &&
- child.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
- string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
- {
- await InvokeAsync(() => child.Toggle());
- }
- }
+ await InvokeAsync(() => child.Toggle());
}
}
}
-
- await base.OnParametersSetAsync();
}
private bool ShouldRightJustify(TreeNeuronViewModel child)
From 82333e257127c59c64b43fae94ed1e543864ba25 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Thu, 29 May 2025 02:23:05 +0300
Subject: [PATCH 37/51] Implement Elmer's comments
---
.../UI/ViewModels/TreeNeuronViewModel.cs | 4 +-
.../UI/Views/Blazor.Common/TreeView.razor | 65 +++++--------------
2 files changed, 17 insertions(+), 52 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index f1375d4..005a89e 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -96,9 +96,9 @@ public bool IsExpansionTimerEnabled()
return this.expansionTimer.Enabled;
}
- public bool IsChild(string id)
+ public bool IsChild(string id,RelativeType type)
{
- var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id));
+ var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id,type));
return result;
}
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 6e3f374..693c92c 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -260,77 +260,42 @@
{
if (
this.selectedNeuron != null && string.IsNullOrEmpty(this.selectedNeuron.Neuron.ExternalReferenceUrl) &&
+ this.selectedNeuron.IsExpansionTimerEnabled() &&
(
this.selectedNeuron.ExpansionState == ExpansionState.Collapsed ||
!this.Children.Any(c => c.ExpansionState == ExpansionState.Expanded)
)
)
{
- if (this.selectedNeuron.IsExpansionTimerEnabled())
- {
- this.selectedNeuron.RestartExpansionTimer();
+ this.selectedNeuron.RestartExpansionTimer();
- switch (this.selectedNeuron.CurrentExpansionType)
- {
- case ExpansionType.PostsynapticUntilExternalReferences:
- await HandlePostsynapticExpansion();
- break;
- case ExpansionType.FarthestPresynaptic:
- await HandlePresynapticExpansion();
- break;
- }
+ switch (this.selectedNeuron.CurrentExpansionType)
+ {
+ case ExpansionType.PostsynapticUntilExternalReferences:
+ await HandleExpansion(Library.Common.RelativeType.Presynaptic,Library.Common.RelativeType.Postsynaptic);
+ break;
+ case ExpansionType.FarthestPresynaptic:
+ await HandleExpansion(Library.Common.RelativeType.Postsynaptic, Library.Common.RelativeType.Presynaptic);
+ break;
}
}
await base.OnParametersSetAsync();
}
- private async Task HandlePostsynapticExpansion()
- {
- // if children contains selected neuron
- if (
- this.Children.Any(
- x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
- x.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
- )
- )
- {
- if (
- this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
- )
- {
- await InvokeAsync(() => this.SelectedNeuron.Toggle());
- }
- }
- else
- {
- foreach (var child in this.Children)
- {
- if (this.SelectedNeuron.IsChild(child.Neuron.Id) &&
- child.Neuron.Type != Library.Common.RelativeType.Presynaptic &&
- string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
- {
- await InvokeAsync(() => child.Toggle());
- }
- }
- }
- }
-
- private async Task HandlePresynapticExpansion()
+ private async Task HandleExpansion(Library.Common.RelativeType type, Library.Common.RelativeType childType)
{
// if children contains selected neuron
if (
this.Children.Any(
x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
- x.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ x.Neuron.Type != type &&
string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
)
)
{
if (
- this.SelectedNeuron.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ this.SelectedNeuron.Neuron.Type != type &&
string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
)
{
@@ -341,8 +306,8 @@
{
foreach (var child in this.Children)
{
- if (this.SelectedNeuron.IsPresynapticChild(child.Neuron.Id) &&
- child.Neuron.Type != Library.Common.RelativeType.Postsynaptic &&
+ if (this.SelectedNeuron.IsChild(child.Neuron.Id,childType) &&
+ child.Neuron.Type != type &&
string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
{
await InvokeAsync(() => child.Toggle());
From 13cc9eeddf6859a8f72171e6fd0da0aaff792679 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Thu, 29 May 2025 02:54:20 +0300
Subject: [PATCH 38/51] Implement Other Condition Expression
---
.../UI/ViewModels/TreeNeuronViewModel.cs | 10 ++------
.../UI/Views/Blazor.Common/TreeView.razor | 23 +++++++++++++------
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index 005a89e..fcea36c 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -96,15 +96,9 @@ public bool IsExpansionTimerEnabled()
return this.expansionTimer.Enabled;
}
- public bool IsChild(string id,RelativeType type)
+ public bool IsChild(string id, RelativeType type)
{
- var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Postsynaptic) || x.IsChild(id,type));
- return result;
- }
-
- public bool IsPresynapticChild(string id)
- {
- var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == RelativeType.Presynaptic) || x.IsPresynapticChild(id));
+ var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type ==type) || x.IsChild(id, type));
return result;
}
}
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 693c92c..57c4a0f 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -272,10 +272,16 @@
switch (this.selectedNeuron.CurrentExpansionType)
{
case ExpansionType.PostsynapticUntilExternalReferences:
- await HandleExpansion(Library.Common.RelativeType.Presynaptic,Library.Common.RelativeType.Postsynaptic);
+ await HandleExpansion(
+ Library.Common.RelativeType.Presynaptic,
+ Library.Common.RelativeType.Postsynaptic,
+ n => string.IsNullOrEmpty(n.ExternalReferenceUrl));
break;
case ExpansionType.FarthestPresynaptic:
- await HandleExpansion(Library.Common.RelativeType.Postsynaptic, Library.Common.RelativeType.Presynaptic);
+ await HandleExpansion(
+ Library.Common.RelativeType.Postsynaptic,
+ Library.Common.RelativeType.Presynaptic,
+ _ => true);
break;
}
}
@@ -283,20 +289,23 @@
await base.OnParametersSetAsync();
}
- private async Task HandleExpansion(Library.Common.RelativeType type, Library.Common.RelativeType childType)
+ private async Task HandleExpansion(
+ Library.Common.RelativeType type,
+ Library.Common.RelativeType childType,
+ Func otherCondition)
{
// if children contains selected neuron
if (
this.Children.Any(
x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
x.Neuron.Type != type &&
- string.IsNullOrEmpty(SelectedNeuron.Neuron.ExternalReferenceUrl)
+ otherCondition(x.Neuron)
)
)
{
if (
this.SelectedNeuron.Neuron.Type != type &&
- string.IsNullOrEmpty(this.SelectedNeuron.Neuron.ExternalReferenceUrl)
+ otherCondition(this.SelectedNeuron.Neuron)
)
{
await InvokeAsync(() => this.SelectedNeuron.Toggle());
@@ -306,9 +315,9 @@
{
foreach (var child in this.Children)
{
- if (this.SelectedNeuron.IsChild(child.Neuron.Id,childType) &&
+ if (this.SelectedNeuron.IsChild(child.Neuron.Id, childType) &&
child.Neuron.Type != type &&
- string.IsNullOrEmpty(child.Neuron.ExternalReferenceUrl))
+ otherCondition(child.Neuron))
{
await InvokeAsync(() => child.Toggle());
}
From 21868fe281875793c0d357fd565dfa2318e6fc37 Mon Sep 17 00:00:00 2001
From: Abdulrahman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Thu, 29 May 2025 13:16:52 +0300
Subject: [PATCH 39/51] Make Other Condition optional parameter
---
.../Port.Adapter/UI/Views/Blazor.Common/TreeView.razor | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 57c4a0f..734ed14 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -292,20 +292,20 @@
private async Task HandleExpansion(
Library.Common.RelativeType type,
Library.Common.RelativeType childType,
- Func otherCondition)
+ Func otherCondition = null)
{
// if children contains selected neuron
if (
this.Children.Any(
x => x.Neuron.Id == this.SelectedNeuron.Neuron.Id &&
x.Neuron.Type != type &&
- otherCondition(x.Neuron)
+ (otherCondition == null || otherCondition(x.Neuron))
)
)
{
if (
this.SelectedNeuron.Neuron.Type != type &&
- otherCondition(this.SelectedNeuron.Neuron)
+ (otherCondition == null || otherCondition(this.SelectedNeuron.Neuron))
)
{
await InvokeAsync(() => this.SelectedNeuron.Toggle());
@@ -317,7 +317,7 @@
{
if (this.SelectedNeuron.IsChild(child.Neuron.Id, childType) &&
child.Neuron.Type != type &&
- otherCondition(child.Neuron))
+ (otherCondition == null || otherCondition(child.Neuron)))
{
await InvokeAsync(() => child.Toggle());
}
From e81f44ae550868944bae5651a06b3074599f3c24 Mon Sep 17 00:00:00 2001
From: Abdulrahman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Thu, 29 May 2025 13:27:09 +0300
Subject: [PATCH 40/51] Remove unnecessary parameters
---
src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 734ed14..570dfae 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -280,8 +280,7 @@
case ExpansionType.FarthestPresynaptic:
await HandleExpansion(
Library.Common.RelativeType.Postsynaptic,
- Library.Common.RelativeType.Presynaptic,
- _ => true);
+ Library.Common.RelativeType.Presynaptic);
break;
}
}
From 5ebeecb1afe7648f0cbe72730d6728ca4a2e4d4e Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Thu, 5 Jun 2025 21:30:54 +0300
Subject: [PATCH 41/51] Implement Just one timer instead one implement timer
for each neuron
---
.../UI/ViewModels/TreeNeuronViewModel.cs | 41 ++++++++++++++-----
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index b37ceeb..ded821a 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -26,18 +26,22 @@ public class TreeNeuronViewModel
private readonly IEnumerable mirrorConfigFiles;
public TreeNeuronViewModel(
- Neuron neuron,
- string avatarUrl,
+ Neuron neuron,
+ string avatarUrl,
INeuronQueryService neuronQueryService,
IEnumerable mirrorConfigFiles
- )
+ )
{
this.Neuron = neuron;
this.avatarUrl = avatarUrl;
this.neuronQueryService = neuronQueryService;
this.mirrorConfigFiles = mirrorConfigFiles;
this.Children = new List();
- this.expansionTimer = new Timer();
+ }
+
+ public void SetExpansionTimer(Timer timer)
+ {
+ this.expansionTimer = timer;
}
public IList Children { get; set; }
@@ -67,11 +71,11 @@ public async Task Toggle()
.Items
.ToList().ForEach(n =>
children.Add(new TreeNeuronViewModel(
- new Neuron(n),
- this.avatarUrl,
- this.neuronQueryService,
+ new Neuron(n),
+ this.avatarUrl,
+ this.neuronQueryService,
this.mirrorConfigFiles
- ))
+ ))
);
this.Children = children.ToArray();
@@ -82,6 +86,9 @@ public async Task Toggle()
public void ConfigureExpansionTimer(ExpansionType type, double interval, ElapsedEventHandler handler)
{
+ if (this.expansionTimer == null)
+ throw new InvalidOperationException("Expansion timer not set. Call SetExpansionTimer first.");
+
this.currentExpansionType = type;
this.expansionTimer.Interval = interval;
this.expansionTimer.Elapsed -= handler;
@@ -93,38 +100,50 @@ public IEnumerable> GetMirrorKeys()
var result = this.mirrorConfigFiles
.Where(mco => mco.Mirrors.Any(m => m.Url == this.Neuron.ExternalReferenceUrl))
.Select(mco => Tuple.Create(
- mco.Mirrors.Single(mi => mi.Url == this.Neuron.ExternalReferenceUrl).Key,
+ mco.Mirrors.Single(mi => mi.Url == this.Neuron.ExternalReferenceUrl).Key,
mco.Path
));
return result;
}
-
+
public void StartExpansionTimer()
{
+ if (this.expansionTimer == null)
+ throw new InvalidOperationException("Expansion timer not set. Call SetExpansionTimer first.");
+
this.expansionTimer.Start();
}
public void StopExpansionTimer()
{
+ if (this.expansionTimer == null)
+ throw new InvalidOperationException("Expansion timer not set. Call SetExpansionTimer first.");
+
this.expansionTimer.Stop();
this.currentExpansionType = ExpansionType.None;
}
public void RestartExpansionTimer()
{
+ if (this.expansionTimer == null)
+ throw new InvalidOperationException("Expansion timer not set. Call SetExpansionTimer first.");
+
this.expansionTimer.Enabled = false;
this.StartExpansionTimer();
}
public bool IsExpansionTimerEnabled()
{
+ if (this.expansionTimer == null)
+ return false;
+
return this.expansionTimer.Enabled;
}
public bool IsChild(string id, RelativeType type)
{
- var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type ==type) || x.IsChild(id, type));
+ var result = this.Children.Any(x => (x.Neuron.Id == id && x.Neuron.Type == type) || x.IsChild(id, type));
return result;
}
From 604544c8a390de72ea3b40d8c2fc7042e1e81658 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Tue, 10 Jun 2025 18:48:40 +0300
Subject: [PATCH 42/51] Remove SetExpansionTimer
---
.../Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index ded821a..4c5c067 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -39,11 +39,6 @@ IEnumerable mirrorConfigFiles
this.Children = new List();
}
- public void SetExpansionTimer(Timer timer)
- {
- this.expansionTimer = timer;
- }
-
public IList Children { get; set; }
public Neuron Neuron { get; private set; }
@@ -84,8 +79,9 @@ public async Task Toggle()
}
}
- public void ConfigureExpansionTimer(ExpansionType type, double interval, ElapsedEventHandler handler)
+ public void ConfigureExpansionTimer(Timer timer, ExpansionType type, double interval, ElapsedEventHandler handler)
{
+ this.expansionTimer = timer;
if (this.expansionTimer == null)
throw new InvalidOperationException("Expansion timer not set. Call SetExpansionTimer first.");
From 906c64f4049393a0c70521d46ed1d21cf92b08bd Mon Sep 17 00:00:00 2001
From: Elmer Roderick Niem Bool <35117496+elmerbool@users.noreply.github.com>
Date: Wed, 11 Jun 2025 07:53:06 +1000
Subject: [PATCH 43/51] Update TreeNeuronViewModel.cs
---
src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index 4c5c067..cbc973e 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -81,9 +81,10 @@ public async Task Toggle()
public void ConfigureExpansionTimer(Timer timer, ExpansionType type, double interval, ElapsedEventHandler handler)
{
- this.expansionTimer = timer;
- if (this.expansionTimer == null)
- throw new InvalidOperationException("Expansion timer not set. Call SetExpansionTimer first.");
+ if (timer == null)
+ throw new ArgumentNullException(nameof(timer));
+
+ this.expansionTimer = timer;
this.currentExpansionType = type;
this.expansionTimer.Interval = interval;
From 1753f7a69ed8c76caa52821505c4eb96e7ff0ed4 Mon Sep 17 00:00:00 2001
From: Abdelrhman Ahmed <64210458+AbdulrahmanAhmeed@users.noreply.github.com>
Date: Thu, 12 Jun 2025 00:03:47 +0300
Subject: [PATCH 44/51] Implement ticket 19
---
.../UI/ViewModels/TreeNeuronViewModel.cs | 13 +++++++++++--
.../UI/Views/Blazor.Common/TreeView.razor | 19 ++++++++++++++++---
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
index 4c5c067..ba0d81d 100644
--- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
+++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs
@@ -16,6 +16,11 @@ public enum ExpansionType
PostsynapticUntilExternalReferences,
FarthestPresynaptic
}
+ public enum Color
+ {
+ White,
+ Blue
+ }
public class TreeNeuronViewModel
{
@@ -29,7 +34,8 @@ public TreeNeuronViewModel(
Neuron neuron,
string avatarUrl,
INeuronQueryService neuronQueryService,
- IEnumerable mirrorConfigFiles
+ IEnumerable mirrorConfigFiles,
+ Color color = Color.White
)
{
this.Neuron = neuron;
@@ -37,6 +43,7 @@ IEnumerable mirrorConfigFiles
this.neuronQueryService = neuronQueryService;
this.mirrorConfigFiles = mirrorConfigFiles;
this.Children = new List();
+ this.Color = color;
}
public IList Children { get; set; }
@@ -46,6 +53,7 @@ IEnumerable mirrorConfigFiles
public ExpansionState ExpansionState { get; private set; }
public ExpansionType CurrentExpansionType => this.currentExpansionType;
+ public Color Color;
public async Task Toggle()
{
@@ -69,7 +77,8 @@ public async Task Toggle()
new Neuron(n),
this.avatarUrl,
this.neuronQueryService,
- this.mirrorConfigFiles
+ this.mirrorConfigFiles,
+ this.Color
))
);
diff --git a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
index 90cdccb..501c156 100644
--- a/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
+++ b/src/main/Port.Adapter/UI/Views/Blazor.Common/TreeView.razor
@@ -1,6 +1,7 @@
@using Blazorise
@using Blazorise.Icons.FontAwesome
@using Microsoft.JSInterop
+@using Microsoft.AspNetCore.Components.Web
@using ei8.Cortex.Diary.Application.Neurons
@using ei8.Cortex.Diary.Port.Adapter.UI.ViewModels
@@ -11,7 +12,7 @@
@foreach (var child in this.Children)
{
string currentAuthor = (child.Neuron.Creation?.Author?.Tag + ((child.Neuron.Creation?.Author?.Id != child.Neuron.UnifiedLastModification?.Author?.Id) ? ", " + child.Neuron.UnifiedLastModification.Author.Tag : string.Empty));
-
+
@{var tagUrlType = this.GetUrlType(child.Neuron.Tag);}
@@ -44,13 +45,13 @@
}
@if (@child.ExpansionState == ExpansionState.Collapsed)
{
-