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.

3.4 KB
Raw Blame
@model KnowledgebaseArticleModel

@if (!string.IsNullOrEmpty(Model.Id))
{
    <div class="grand-card">
        <div class="grand-card__header">
            <h2 class="grand-card__title">@Loc["Admin.Content.Knowledgebase.KnowledgebaseArticle.Related"]</h2>
            <a id="btnAddNewRelatedArticle" href="@(Url.Action("ArticlesPopup", "Knowledgebase", new { articleId = Model.Id, btnId = "btnRefreshRelatedArticles", formId = "article-form", area = Constants.AreaAdmin }))" class="btn btn-outline-secondary btn-sm"><i class="bi bi-plus-lg"></i> @Loc["Admin.Content.Knowledgebase.KnowledgebaseArticle.Related.AddNew"]</a>
            <input type="submit" id="btnRefreshRelatedArticles" style="display: none"/>
        </div>
        <div class="grand-card__body grand-card__body--flush">
            <admin-grid id="relatedarticles-grid"
                        read-url="@Url.Action("RelatedArticlesList", "Knowledgebase", new { articleId = Model.Id, area = Constants.AreaAdmin })"
                        destroy-url="@Url.Action("RelatedArticleDelete", "Knowledgebase", new { articleId = Model.Id, area = Constants.AreaAdmin })"
                        pager="Compact">
                <grid-column field="Article2Name" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseArticle.Fields.Name"]" width="400">
                    <cell-template>
                        <a href="@Url.Action("EditArticle", "Knowledgebase", new { id = "", area = Constants.AreaAdmin })/{{ Article2Id }}">{{ Article2Name }}</a>
                    </cell-template>
                </grid-column>
                <grid-column field="DisplayOrder" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseArticle.Fields.DisplayOrder"]" width="10" format="{0:0}"/>
                <grid-column field="Published" title="@Loc["Admin.Content.Knowledgebase.KnowledgebaseArticle.Fields.Published"]" width="10" 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-commands destroy="true" width="10"/>
            </admin-grid>
        </div>
    </div>

    <script>
        $(document).ready(function () {
            $('#btnAddNewRelatedArticle').magnificPopup({
                type: 'ajax',
                settings: { cache: false, async: false },
                midClick: true,
                callbacks: {
                    parseAjax: function (mfpResponse) {
                        mfpResponse.data = $('<div></div>').html(mfpResponse.data);
                    },
                    ajaxContentAdded: function () {
                        $('.mfp-wrap').removeAttr('tabindex');
                    }
                }
            });
        });
    </script>

    <script>
        $(document).ready(function () {
            $('#btnRefreshRelatedArticles').click(function () {
                //refresh grid
                var grid = GrandAdmin.grids.get("#relatedarticles-grid");
                grid.dataSource.read();

                //return false to don't reload a page
                return false;
            });
        });
    </script>
}
else
{
    <div class="note note-info">
        @Loc["Admin.Content.Knowledgebase.KnowledgebaseArticle.Related.SaveBeforeEdit"]
    </div>
}