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
@using Grand.Web.AdminShared.Models.News
@model NewsItemListModel
@{
    //page title
    ViewBag.Title = Loc["Admin.Content.News.NewsItems"];
    var area = ViewContext.RouteData.Values["area"]?.ToString();
}

@* The product list's shape: Add new in the page header, the store (Admin only - a store owner
   sees one store) as the only filter, and the grid in a flush card. The ids the script below
   looks up are unchanged. *@
<admin-page title="@Loc["Admin.Content.News.NewsItems"]" icon="bi-newspaper">
    <page-actions>
        <partial name="Partials/WidgetZone.ListButtons"/>
        <a href="@Url.Action("Create", new { area })" class="btn btn-primary">
            <i class="bi bi-plus-lg"></i> @Loc["Admin.Common.AddNew"]
        </a>
    </page-actions>

    @if (area == "Admin")
    {
        <admin-filters id="newsitem-filters" submit-id="search-newsitem" secondary-submit="true">
            <filters-search>
                <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores"/>
            </filters-search>
        </admin-filters>
    }

    <admin-card flush>
        <admin-grid id="newsitem-grid"
                    read-url="@Url.Action("List", "News", new { area })"
                    additional-data="additionalData">
            <grid-text name="comments" value="@Loc["Admin.Content.News.NewsItems.Fields.Comments"]"/>
            <grid-column field="Title" title="@Loc["Admin.Content.News.NewsItems.Fields.Title"]" width="300">
                <cell-template>
                    <a class="text-decoration-none" href="Edit/{{ Id }}">{{ Title }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="Comments" title="@Loc["Admin.Content.News.NewsItems.Fields.Comments"]" width="200">
                <cell-template>
                    <a class="text-decoration-none" href="Edit/{{ Id }}">{{ $texts.comments }} - {{ Comments }} </a>
                </cell-template>
            </grid-column>
            <grid-column field="StartDate" title="@Loc["Admin.Content.News.NewsItems.Fields.StartDate"]" width="150" format="{0:G}"/>
            <grid-column field="EndDate" title="@Loc["Admin.Content.News.NewsItems.Fields.EndDate"]" width="150" format="{0:G}"/>
            <grid-column field="Published" title="@Loc["Admin.Content.News.NewsItems.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="CreatedOn" title="@Loc["Admin.Content.News.NewsItems.Fields.CreatedOn"]" width="200" format="{0:G}"/>
        </admin-grid>
    </admin-card>
</admin-page>
<script>

    $(document).ready(function () {
        //search button
        $('#search-newsitem').click(function () {
            //search
            var grid = GrandAdmin.grids.get('#newsitem-grid');
            grid.dataSource.page(1); //new search. Set page size to 1
            //grid.dataSource.read(); we already loaded the grid above using "page" function
            return false;
        });
    });

    function additionalData() {
        var data = {};
        if ($('#SearchStoreId').length) {
            data.SearchStoreId = $('#SearchStoreId').val();
        }
        addAntiForgeryToken(data);
        return data;
    }
</script>