Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TheTheme navbar #15231

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading