From 9319fe76c56b79e0933c09280fe32658c2f176c7 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 5 Apr 2024 19:01:39 +0200 Subject: Cleanup, work on index2, some tooling updates --- .../MainTabComponents/MainTabSpaceItem.razor | 37 ++++++++- .../MainTabComponents/MainTabSpaceItem.razor.css | 6 +- .../Index2Components/RoomsIndex2MainTab.razor | 90 ++++++++++++---------- 3 files changed, 89 insertions(+), 44 deletions(-) (limited to 'MatrixUtils.Web/Pages/Rooms') diff --git a/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor b/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor index 4216824..7a3b27b 100644 --- a/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor +++ b/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor @@ -1,17 +1,34 @@ @using MatrixUtils.Abstractions -
+
+ @if (IsSpaceOpened()) { + + } + else { + + } + @Space.RoomName + + @if (IsSpaceOpened()) { + meow + }
@code { [Parameter] public RoomInfo Space { get; set; } + + [Parameter] + public RoomInfo SelectedSpace { get; set; } + + [Parameter] + public EventCallback SelectedSpaceChanged { get; set; } [Parameter] public List OpenedSpaces { get; set; } - + protected override Task OnInitializedAsync() { Space.PropertyChanged += (sender, args) => { StateHasChanged(); }; return base.OnInitializedAsync(); @@ -20,8 +37,20 @@ public void ToggleSpace() { if (OpenedSpaces.Contains(Space)) { OpenedSpaces.Remove(Space); - } else { + } + else { OpenedSpaces.Add(Space); } } -} \ No newline at end of file + + public void SelectSpace() { + SelectedSpace = Space; + SelectedSpaceChanged.InvokeAsync(Space); + } + + public bool IsSpaceOpened() { + return OpenedSpaces.Contains(Space); + } + +} + diff --git a/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor.css b/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor.css index c174567..a88975b 100644 --- a/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor.css +++ b/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor.css @@ -5,11 +5,15 @@ text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; - width: calc(100% - 38px); + width: calc(100% - 64px); } .spaceListItem { display: block; width: 100%; height: 50px; +} + +.spaceListItem > img { + display: inline-block; } \ No newline at end of file diff --git a/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor b/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor index 2b7c5ac..b163a52 100644 --- a/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor +++ b/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor @@ -31,11 +31,17 @@
Uncategorised rooms @foreach (var space in GetTopLevelSpaces()) { - @RecursingSpaceChildren(space) + @* @RecursingSpaceChildren(space) *@ + }

Placeholder for rooms list...

+ @if (SelectedSpace != null) { + foreach (var room in GetSpaceChildRooms(SelectedSpace)) { +

@room.RoomName

+ } + }
@@ -116,48 +122,54 @@ var childSpaces = children.Where(x => x.RoomType == "m.space").ToList(); return childSpaces; } + + private List GetSpaceChildRooms(RoomInfo space) { + var children = GetSpaceChildren(space); + var childRooms = children.Where(x => x.RoomType != "m.space").ToList(); + return childRooms; + } private RoomInfo? SelectedSpace { get; set; } private List OpenedSpaces { get; set; } = new List(); - private RenderFragment RecursingSpaceChildren(RoomInfo space, List? parents = null, int depth = 0) { - parents ??= []; - var totalSw = Stopwatch.StartNew(); - var children = GetSpaceChildSpaces(space); - - var randomColor = RandomNumberGenerator.GetBytes(3).Append((byte)0x33).ToArray().AsHexString().Replace(" ", ""); - var isExpanded = OpenedSpaces.Contains(space); - - // Console.WriteLine($"RecursingSpaceChildren::FetchData - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - - // var renderSw = Stopwatch.StartNew(); - var rf = new RenderFragment(builder => { - builder.OpenElement(0, "div"); - //space list entry render fragment - // builder.AddContent(1, SpaceListEntry(space)); - builder.OpenComponent(1); - builder.AddAttribute(2, "Space", space); - builder.AddAttribute(2, "OpenedSpaces", OpenedSpaces); - builder.CloseComponent(); - builder.CloseElement(); - //space children render fragment - if (isExpanded) { - builder.OpenElement(2, "div"); - builder.AddAttribute(3, "style", "padding-left: 10px;"); - foreach (var child in children) { - builder.AddContent(4, RecursingSpaceChildren(child, parents.Append(space).ToList(), depth + 1)); - } - - builder.CloseElement(); - } - }); - - // Console.WriteLine($"RecursingSpaceChildren::Render - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {renderSw.Elapsed}"); - if (totalSw.ElapsedMilliseconds > 20) - Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - return rf; - } + // private RenderFragment RecursingSpaceChildren(RoomInfo space, List? parents = null, int depth = 0) { + // parents ??= []; + // var totalSw = Stopwatch.StartNew(); + // var children = GetSpaceChildSpaces(space); + // + // var randomColor = RandomNumberGenerator.GetBytes(3).Append((byte)0x33).ToArray().AsHexString().Replace(" ", ""); + // var isExpanded = OpenedSpaces.Contains(space); + // + // // Console.WriteLine($"RecursingSpaceChildren::FetchData - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // + // // var renderSw = Stopwatch.StartNew(); + // var rf = new RenderFragment(builder => { + // builder.OpenElement(0, "div"); + // //space list entry render fragment + // // builder.AddContent(1, SpaceListEntry(space)); + // builder.OpenComponent(1); + // builder.AddAttribute(2, "Space", space); + // builder.AddAttribute(2, "OpenedSpaces", OpenedSpaces); + // builder.CloseComponent(); + // builder.CloseElement(); + // //space children render fragment + // if (isExpanded) { + // builder.OpenElement(2, "div"); + // builder.AddAttribute(3, "style", "padding-left: 10px;"); + // foreach (var child in children) { + // builder.AddContent(4, RecursingSpaceChildren(child, parents.Append(space).ToList(), depth + 1)); + // } + // + // builder.CloseElement(); + // } + // }); + // + // // Console.WriteLine($"RecursingSpaceChildren::Render - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {renderSw.Elapsed}"); + // if (totalSw.ElapsedMilliseconds > 20) + // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // return rf; + // } // private RenderFragment SpaceListEntry(RoomInfo space) { // return builder => { -- cgit 1.4.1