Skip to content

Commit

Permalink
Visual separators between relation groups. Relates to #244.
Browse files Browse the repository at this point in the history
  • Loading branch information
impworks committed Dec 5, 2023
1 parent 0af5795 commit f5834e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
@model IEnumerable<Bonsai.Areas.Front.ViewModels.Page.InfoBlock.RelationCategoryVM>
@using Bonsai.Code.Utils.Helpers
@model IEnumerable<Bonsai.Areas.Front.ViewModels.Page.InfoBlock.RelationCategoryVM>

@foreach (var cat in Model)
{
<h6>@cat.Title</h6>
foreach (var group in cat.Groups)
foreach (var (group, idx) in cat.Groups.WithIndex())
{
@if (idx != 0)
{
<hr />
}
<div class="relation-group">
@foreach (var rel in group.Relations)
{
Expand Down
8 changes: 8 additions & 0 deletions src/Bonsai/Code/Utils/Helpers/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@ await foreach(var elem in source)

return result;
}

/// <summary>
/// Adds an index to the sequence.
/// </summary>
public static IEnumerable<(T, int)> WithIndex<T>(this IEnumerable<T> source)
{
return source.Select((x, id) => (x, id));
}
}
}

0 comments on commit f5834e8

Please sign in to comment.