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.3 KB
Raw Blame
@model PageListModel
@{
    //page title
    ViewBag.Title = Loc["Admin.Content.Pages"];
}

@* The product list's shape: Add new in the page header, the name as the quick search with the
   store behind the Filters toggle, and the grid in a flush card. The ids the script below looks
   up are unchanged. *@
<admin-page title="@Loc["Admin.Content.Pages"]" icon="bi-file-earmark">
    <page-actions>
        <partial name="Partials/WidgetZone.ListButtons"/>
        <a href="@Url.Action("Create", new { area = Constants.AreaAdmin })" class="btn btn-primary">
            <i class="bi bi-plus-lg"></i> @Loc["Admin.Common.AddNew"]
        </a>
    </page-actions>

    <admin-filters id="page-filters" submit-id="search-pages" secondary-submit="true">
        <filters-search>
            <admin-input asp-for="Name"/>
        </filters-search>
        <admin-field asp-for="SearchStoreId" asp-items="Model.AvailableStores"/>
    </admin-filters>

    <admin-card flush>
        <admin-grid id="pages-grid"
                    read-url="@Url.Action("List", "Page", new { area = Constants.AreaAdmin })"
                    additional-data="additionalData">
            <grid-column field="SystemName" title="@Loc["Admin.Content.Pages.Fields.SystemName"]">
                <cell-template>
                    <a class="text-decoration-none" href="Edit/{{ Id }}">{{ SystemName }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="Title" title="@Loc["Admin.Content.Pages.Fields.Title"]">
                <cell-template>
                    {{ Title }}
                </cell-template>
            </grid-column>
            <grid-column field="IncludeInMenu" title="@Loc["Admin.Content.Pages.Fields.IncludeInMenu"]" width="100" align="Center">
                <cell-template>
                    <i data-if="IncludeInMenu" 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="Published" title="@Loc["Admin.Content.Pages.Fields.Published"]" width="100" 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.Pages.Fields.DisplayOrder"]" width="100"/>
        </admin-grid>
    </admin-card>
</admin-page>

<script>

    $(document).ready(function () {
        //search button
        $('#search-pages').click(function () {
            //search
            var grid = GrandAdmin.grids.get('#pages-grid');
            grid.dataSource.read();
            return false;
        });

        $("#@Html.IdFor(model => model.Name)").keydown(function (event) {
            if (event.keyCode == 13) {
                $("#search-pages").click();
                return false;
            }
        });

    });

    function additionalData() {
        var data = {
            SearchStoreId: $('#SearchStoreId').val(),
            Name: $('#@Html.IdFor(model => model.Name)').val()
        };
        addAntiForgeryToken(data);
        return data;
    }
</script>