Skip to content

Commit

Permalink
Fix TheTheme navbar (OrchardCMS#15231)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored and urbanit committed Mar 18, 2024
1 parent 8042f78 commit 23e9820
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 38 deletions.
8 changes: 8 additions & 0 deletions src/OrchardCore.Themes/TheTheme/Views/NavbarUserMenu.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@using OrchardCore.DisplayManagement
@using OrchardCore.DisplayManagement.ModelBinding
@using OrchardCore.Users.Models

@inject IDisplayManager<UserMenu> DisplayManager
@inject IUpdateModelAccessor UpdateModelAccessor

@await DisplayAsync(await DisplayManager.BuildDisplayAsync<UserMenu>(UpdateModelAccessor.ModelUpdater, (string)Model.Metadata.DisplayType))
74 changes: 36 additions & 38 deletions src/OrchardCore.Themes/TheTheme/Views/UserNotificationNavbar.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,49 @@
@model UserNotificationNavbarViewModel

<li class="nav-item dropdown text-end">
<div class="dropdown">
<button type="button" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
@if (Model.TotalUnread > 0)
<a type="button" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
@if (Model.TotalUnread > 0)
{
LocalizedHtmlString title;
if (Model.TotalUnread > Model.MaxVisibleNotifications)
{
LocalizedHtmlString title;
if (Model.TotalUnread > Model.MaxVisibleNotifications)
{
title = T["You have more than {0} unread notifications", Model.MaxVisibleNotifications];
}
else
{
title = T.Plural(Model.TotalUnread, "You have {1} unread notification", "You have {0} unread notifications", Model.TotalUnread);
}

<i class="fa-solid fa-bell" aria-hidden="true" data-bs-toggle="tooltip" data-bs-original-title="@title"></i>
title = T["You have more than {0} unread notifications", Model.MaxVisibleNotifications];
}
else
{
<i class="fa-regular fa-bell" aria-hidden="true" data-bs-toggle="tooltip" data-bs-original-title="@T["You have no unread notifications"]"></i>
}
</button>
<ul class="dropdown-menu dropdown-menu-end notification-navbar scrollable position-absolute">
@if (Model.Notifications.Count > 0)
{
var maxCount = Math.Min(Model.MaxVisibleNotifications, Model.Notifications.Count);
<li>
@for (int i = 0; i < maxCount; i++)
{
var notification = Model.Notifications[i];
dynamic shape = await NotificationDisplayDriver.BuildDisplayAsync(notification, UpdateModelAccessor.ModelUpdater, "Header");
shape.Notification = notification;
<div class="@(i == maxCount - 1 ? string.Empty : "border-bottom")">
@await DisplayAsync(shape)
</div>
}
</li>
<li>
<hr class="dropdown-divider">
</li>
title = T.Plural(Model.TotalUnread, "You have {1} unread notification", "You have {0} unread notifications", Model.TotalUnread);
}

<i class="fa-solid fa-bell" aria-hidden="true" data-bs-toggle="tooltip" data-bs-original-title="@title"></i>
}
else
{
<i class="fa-regular fa-bell" aria-hidden="true" data-bs-toggle="tooltip" data-bs-original-title="@T["You have no unread notifications"]"></i>
}
</a>
<ul class="dropdown-menu dropdown-menu-end notification-navbar scrollable position-absolute">
@if (Model.Notifications.Count > 0)
{
var maxCount = Math.Min(Model.MaxVisibleNotifications, Model.Notifications.Count);
<li>
<a class="dropdown-item fw-bold" asp-action="List" asp-controller="Admin" asp-area="OrchardCore.Notifications">@T["Notification Center"]</a>
@for (int i = 0; i < maxCount; i++)
{
var notification = Model.Notifications[i];
dynamic shape = await NotificationDisplayDriver.BuildDisplayAsync(notification, UpdateModelAccessor.ModelUpdater, "Header");
shape.Notification = notification;
<div class="@(i == maxCount - 1 ? string.Empty : "border-bottom")">
@await DisplayAsync(shape)
</div>
}
</li>
</ul>
</div>
<li>
<hr class="dropdown-divider">
</li>
}
<li>
<a class="dropdown-item fw-bold" asp-action="List" asp-controller="Admin" asp-area="OrchardCore.Notifications">@T["Notification Center"]</a>
</li>
</ul>
</li>

<script at="Foot" asp-name="notification-manager-initializes" depends-on="notification-manager">
Expand Down

0 comments on commit 23e9820

Please sign in to comment.