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.

5.5 KB
Raw Blame
@{
    //page title
    ViewBag.Title = Loc["Admin.Content.Knowledgebase.Manage"];

    //the resources below ship with 2.4; an installation that has not imported them yet
    //shows the English default instead of the raw resource key
    string Res(string key, string fallback)
    {
        //a missing resource comes back as its own (lowercased) key
        var resource = Loc[key];
        return resource.ResourceNotFound || string.IsNullOrEmpty(resource.Value) ||
               string.Equals(resource.Value, key, StringComparison.OrdinalIgnoreCase)
            ? fallback
            : resource.Value;
    }
}

@* The product list's shape: the two create actions in the page header (a new article the one
   primary action), and the category tree grid in a flush card. *@
<admin-page title="@Loc["Admin.Content.Knowledgebase.Manage"]" icon="bi-chat-square-text">
    <page-actions>
        <a href="@Url.Action("CreateCategory", new { area = Constants.AreaAdmin })" class="btn btn-outline-secondary">
            <i class="bi bi-folder-plus"></i> @Loc["Admin.Content.Knowledgebase.CreateKnowledgebaseCategory"]
        </a>
        <a href="@Url.Action("CreateArticle", new { area = Constants.AreaAdmin })" class="btn btn-primary">
            <i class="bi bi-plus-lg"></i> @Loc["Admin.Content.Knowledgebase.CreateKnowledgebaseArticle"]
        </a>
    </page-actions>

    <admin-card flush>
        @*the root categories, then the articles without a category; a category expands to its
          subcategories and articles, and each of those categories expands the same way*@
        <admin-grid id="knowledgebase-grid" read-url="@Url.Action("NodeList", "Knowledgebase", new { area = Constants.AreaAdmin })">
            <grid-text name="category" value="@Res("Admin.Content.Knowledgebase.Node.Category", "Category")"/>
            <grid-text name="article" value="@Res("Admin.Content.Knowledgebase.Node.Article", "Article")"/>
            <grid-column field="Name" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.Name"]" width="400">
                <cell-template>
                    <a data-if="IsCategory" class="text-decoration-none" href="@Url.Action("EditCategory", "Knowledgebase", new { area = Constants.AreaAdmin })/{{ Id }}">{{ Name }}</a>
                    <a data-else class="text-decoration-none" href="@Url.Action("EditArticle", "Knowledgebase", new { area = Constants.AreaAdmin })/{{ Id }}">{{ Name }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="IsCategory" title="@Res("Admin.Content.Knowledgebase.Node.Type", "Type")" width="120">
                <cell-template>
                    <span data-if="IsCategory"><i class="bi bi-folder2 bi-fw" aria-hidden="true"></i> {{ $texts.category }}</span>
                    <span data-else><i class="bi bi-file-earmark-text bi-fw" aria-hidden="true"></i> {{ $texts.article }}</span>
                </cell-template>
            </grid-column>
            <grid-column field="Published" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.Published"]" width="80" align="Center">
                <cell-template>
                    <i data-if="Published" class="bi bi-check-lg text-success" aria-hidden="true"></i>
                    <i data-else class="bi bi-x-lg text-danger" aria-hidden="true"></i>
                </cell-template>
            </grid-column>
            <grid-column field="DisplayOrder" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.DisplayOrder"]" width="100" format="{0:0}"/>
            <grid-detail read-url="@Url.Action("NodeList", "Knowledgebase", new { area = Constants.AreaAdmin })"
                         param="parentCategoryId:Id" page-size="10" pager="Full" recursive="true"
                         visible-if="ChildCount > 0">
                <grid-column field="Name" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.Name"]" width="400">
                    <cell-template>
                        <a data-if="IsCategory" class="text-decoration-none" href="@Url.Action("EditCategory", "Knowledgebase", new { area = Constants.AreaAdmin })/{{ Id }}">{{ Name }}</a>
                        <a data-else class="text-decoration-none" href="@Url.Action("EditArticle", "Knowledgebase", new { area = Constants.AreaAdmin })/{{ Id }}">{{ Name }}</a>
                    </cell-template>
                </grid-column>
                <grid-column field="IsCategory" title="@Res("Admin.Content.Knowledgebase.Node.Type", "Type")" width="120">
                    <cell-template>
                        <span data-if="IsCategory"><i class="bi bi-folder2 bi-fw" aria-hidden="true"></i> {{ $texts.category }}</span>
                        <span data-else><i class="bi bi-file-earmark-text bi-fw" aria-hidden="true"></i> {{ $texts.article }}</span>
                    </cell-template>
                </grid-column>
                <grid-column field="Published" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.Published"]" width="80" align="Center">
                    <cell-template>
                        <i data-if="Published" class="bi bi-check-lg text-success" aria-hidden="true"></i>
                        <i data-else class="bi bi-x-lg text-danger" aria-hidden="true"></i>
                    </cell-template>
                </grid-column>
                <grid-column field="DisplayOrder" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseCategory.Fields.DisplayOrder"]" width="100" format="{0:0}"/>
            </grid-detail>
        </admin-grid>
    </admin-card>
</admin-page>