Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

1.8 KB
Raw Blame
@model Grand.Web.Common.Menu.SiteMapNode

@{
    var url = "javascript:;";
    if (!string.IsNullOrEmpty(Model.ControllerName) && !string.IsNullOrEmpty(Model.ActionName))
    {
        url = Url.Action(Model.ActionName, Model.ControllerName, new { area = Constants.AreaAdmin });
    }
    else if (!string.IsNullOrEmpty(Model.Url))
    {
        url = Model.Url.StartsWith("~/", StringComparison.Ordinal) ? Url.Content(Model.Url) : Model.Url;
    }

    var childNodes = Model.ChildNodes.Where(x => x.Visible).ToList();

<li class="@if (childNodes.Any()) { <text>has-submenu</text> }">
    @if (childNodes.Any())
    {
        <a class="nav-link">
            @if (!string.IsNullOrEmpty(Model.IconClass))
            {
                <i class="@Model.IconClass"></i>
            }
            <span class="title">@Loc[Model.ResourceName]</span>
        </a>
    }
    else
    {
        <a href="@url" class="nav-link" @(Model.OpenUrlInNewTab ? Html.Raw(" target=\"_blank\"") : null)>
            @if (!string.IsNullOrEmpty(Model.IconClass))
            {
                <i class="@Model.IconClass"></i>
            }
            <span class="title">@Loc[Model.ResourceName]</span>
            @if (childNodes.Any())
            {
                <span class="bi bi-chevron-right"></span>
            }

        </a>
    }

    @if (childNodes.Any())
    {
        <ul class="nav child_menu">
            <li class="menu-header">
                <span class="title">@Loc[Model.ResourceName]</span>
                <button type="button" class="close-menu" onclick="closeSubMenu(this)" aria-label="@Loc["Common.Close"]"><i class="bi bi-x-lg" aria-hidden="true"></i></button>
            </li>
            @foreach (var childItem in childNodes)
            {
                <partial name="Partials/MenuItem" model="childItem"/>
            }
        </ul>
    }
</li>}