Skip to content

Commit

Permalink
collapsed fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
beto-rodriguez committed Jun 25, 2024
1 parent 21d9ef5 commit 111b8d4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Manuela/AppRouting/AppRoutes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class AppRoutes
.Where(x => x.Settings.IsMain);
public static IEnumerable<Route> SecondaryMenu => AllRoutes
.Where(x => !x.Settings.IsMain && !x.Settings.IsHidden);
public static IEnumerable<Route> CollapsedElements => AllRoutes
.Where(x => x.Settings.CollapsedRoutes is not null);

public static Route[] Build(Action<AppRoutes> builder)
{
Expand Down Expand Up @@ -65,7 +67,7 @@ public static Route[] Build(Action<AppRoutes> builder)
builder(cb);

var collapsableMenuItem = new Route(
typeof(object), typeof(object), "{collapsed}", null, false);
typeof(object), typeof(object), "{collapsed}", s => s.Main(icon, displayName), false);

collapsableMenuItem.Settings.CollapsedRoutes = cb._routes;
AllRoutes.Add(collapsableMenuItem);
Expand Down
29 changes: 27 additions & 2 deletions src/Manuela/AppRouting/CollapsedBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,40 @@ public class CollapsedBuilder
string routeName,
string displayName,
string icon,
List<string>? styleClass = null)
List<string>? styleClass = null,
bool isSingleton = false)
{
_routes.Add(new Route(viewType, viewModelType, routeName, s =>
{
s.DisplayName = displayName;
s.Icon = icon;
s.StyleClass = styleClass;
}));
}, isSingleton));

return this;
}

public CollapsedBuilder Add<TView>(
string routeName,
string displayName,
string icon,
AppView<TView> viewSettings,
List<string>? styleClass = null,
bool isSingleton = false)
{
return Add(
viewSettings.ViewType, null, routeName, displayName, icon, styleClass, isSingleton);
}

public CollapsedBuilder Add<TView, TViewModel>(
string routeName,
string displayName,
string icon,
AppView<TView, TViewModel> viewSettings,
List<string>? styleClass = null,
bool isSingleton = false)
{
return Add(
viewSettings.ViewType, viewSettings.ViewModelType, routeName, displayName, icon, styleClass, isSingleton);
}
}

0 comments on commit 111b8d4

Please sign in to comment.