diff --git a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs index cbc973e..31d1a53 100644 --- a/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs +++ b/src/main/Port.Adapter/UI/ViewModels/TreeNeuronViewModel.cs @@ -29,7 +29,8 @@ public TreeNeuronViewModel( Neuron neuron, string avatarUrl, INeuronQueryService neuronQueryService, - IEnumerable mirrorConfigFiles + IEnumerable mirrorConfigFiles, + int rootIndex = 0 ) { this.Neuron = neuron; @@ -37,6 +38,7 @@ IEnumerable mirrorConfigFiles this.neuronQueryService = neuronQueryService; this.mirrorConfigFiles = mirrorConfigFiles; this.Children = new List(); + this.RootIndex = rootIndex; } public IList Children { get; set; } @@ -45,6 +47,8 @@ IEnumerable mirrorConfigFiles public ExpansionState ExpansionState { get; private set; } + public int RootIndex { get; set; } + public ExpansionType CurrentExpansionType => this.currentExpansionType; public async Task Toggle() @@ -69,7 +73,8 @@ public async Task Toggle() new Neuron(n), this.avatarUrl, this.neuronQueryService, - this.mirrorConfigFiles + this.mirrorConfigFiles, + this.RootIndex )) ); @@ -83,9 +88,7 @@ public void ConfigureExpansionTimer(Timer timer, ExpansionType type, double inte { if (timer == null) throw new ArgumentNullException(nameof(timer)); - - this.expansionTimer = timer; - + this.expansionTimer = timer; this.currentExpansionType = type; this.expansionTimer.Interval = interval; this.expansionTimer.Elapsed -= handler; 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..c8689ea 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) { - } else if (@child.ExpansionState == ExpansionState.Expanded) { - } @@ -165,15 +166,15 @@ {
    } @@ -272,6 +273,8 @@ protected override async Task OnParametersSetAsync() { + if (this.IsRoot) + this.UpdateChildrenRootIndex(); if ( this.selectedNeuron != null && string.IsNullOrEmpty(this.selectedNeuron.Neuron.ExternalReferenceUrl) && this.selectedNeuron.IsExpansionTimerEnabled() && @@ -479,4 +482,24 @@ return dict; } + + private void UpdateChildrenRootIndex() + { + for (int i = 0; i < this.Children.Count; i++) + { + this.Children[i].RootIndex = i; + } + } + + private string GetBackgroundColorStyle(TreeNeuronViewModel neuron) + { + var baseStyle = "list-style-type: none;"; + var colorStyle = (neuron.RootIndex % 2) switch + { + 0 => "background-color: #ffffff;", + 1 => "background-color: #f0f8ff;", + _ => string.Empty + }; + return $"{baseStyle} {colorStyle}"; + } }