Skip to content

Commit

Permalink
Fix folder color in OU tree views
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsen9026 committed Dec 19, 2024
1 parent c9d2f2e commit 431a24f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion BLAZAM/BLAZAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>1.2.3</AssemblyVersion>
<Version>2024.12.19.0417</Version>
<Version>2024.12.19.2303</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
Expand Down
4 changes: 3 additions & 1 deletion BLAZAMGui/UI/Inputs/TreeViews/OUTreeView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<MudTreeView T="IDirectoryEntryAdapter"
ServerData="GetOUChildrenAsync"
Items="RootOU"
@ref=treeView
Dense="true"
SelectionMode="SelectionMode.SingleSelection"
Hover="true"
MaxHeight="400px"
Color="Color.Primary"
Expand All @@ -18,7 +20,7 @@
@bind-Activated=context.Selected
Text="@context.Value?.CanonicalName"
Icon="@Icons.Material.Filled.Folder"
IconColor="@(context.Selected==true?Color.Primary:Color.Default)"
IconColor=@(GetIconColor(context))
Class="minw-max w-100"
CanExpand=@(context.Value is IADOrganizationalUnit)
Context="treeContext"
Expand Down
36 changes: 16 additions & 20 deletions BLAZAMGui/UI/Inputs/TreeViews/OUTreeViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class OUTreeViewBase : AppComponentBase
protected ADOrganizationalUnit TopLevel;
private IADOrganizationalUnit? _startingSelectedNode;
private IDirectoryEntryAdapter? _selectedEntry;

protected MudTreeView<IDirectoryEntryAdapter>? treeView;
[Parameter]
public bool StartRootExpanded { get; set; } = true;

Expand Down Expand Up @@ -60,26 +60,31 @@ public IDirectoryEntryAdapter? SelectedEntry
if (value == _selectedEntry) return;
if (value != null)
{
var firstSet = true;
if (_selectedEntry != null)
firstSet = false;

var cache = _selectedEntry;

_selectedEntry = value;
if (cache == null && RootOU.Count > 0 && value == RootOU.First()) return;


InvokeAsync(() => { SelectedEntryChanged.InvokeAsync(value); });



//if (TopLevel == null)
// OnInitializedAsync();

if (RootOU.Count > 0)
OpenToSelected();

//if (RootOU.Count > 0 && firstSet)
// OpenToSelected();

}
}

}

protected Color GetIconColor(TreeItemData<IDirectoryEntryAdapter>context)
{
return context.Selected == true ? Color.Primary : Color.Default;
}
[Parameter]
public EventCallback<IDirectoryEntryAdapter> SelectedEntryChanged { get; set; }
/// <summary>
Expand Down Expand Up @@ -124,24 +129,14 @@ protected async Task InitializeTreeView()
{
await Task.Run(() =>
{

//ApplicationBaseOUs = Directory.OUs.FindSubOusByDN(null);


if (RootOU is null || RootOU.Count < 1)
{
TopLevel = new ADOrganizationalUnit();
TopLevel.Parse(directory: Directory, directoryEntry: Directory.GetDirectoryEntry());
_ = TopLevel.SubOUs;
var TopLevelList = new List<IDirectoryEntryAdapter>() { TopLevel };
// RootOU = new HashSet<IDirectoryEntryAdapter>() { TopLevel as IDirectoryEntryAdapter };
RootOU = TopLevelList.ToTreeItemData();
}
if (StartingSelectedOU == null)
{
//StartingSelectedOU = TopLevel;

}

OpenToSelected();
LoadingData = false;
Expand Down Expand Up @@ -186,14 +181,15 @@ protected void OpenToSelected()

while (openThis != null)
{

openThis.Children = GetChildren(openThis);
var child = openThis.Children.Where(
c => SelectedEntry.DN.Contains(c.Value.DN)
&& !SelectedEntry.DN.Equals(c.Value.DN)
).FirstOrDefault();
if (child != null)
{

child.Expanded = true;

openThis = child;
Expand Down

0 comments on commit 431a24f

Please sign in to comment.