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.0 KB
Raw Blame
@model CollectionListModel
@{
    ViewBag.Title = Loc["Admin.Catalog.Collections"];
}
@* The product list's shape: the page header carries Add new as the one primary action and
   export/import in the overflow menu, the filter bar the name search with the store behind the
   Filters toggle, and the grid a flush card. The ids the script below looks up are unchanged. *@
<admin-page title="@Loc["Admin.Catalog.Collections"]" icon="bi-building">
    <page-actions>
        <admin-action-menu text="@Loc["Admin.Common.Export"]">
            <admin-action url="@Url.Action("ExportXlsx", new { area = Constants.AreaAdmin })"
                          icon="bi-file-earmark-excel" text="@Loc["Admin.Common.ExportToExcel"]"/>
            <admin-action id="importexcel" name="importexcel" icon="bi-upload" text="@Loc["Admin.Common.ImportFromExcel"]"/>
        </admin-action-menu>
        <vc:admin-widget widget-zone="collection_list_buttons" additional-data="null"/>
        <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="collection-filters" submit-id="search-collections">
        <filters-search>
            <admin-input asp-for="SearchCollectionName"/>
        </filters-search>
        <admin-field asp-for="SearchStoreId" asp-items="Model.AvailableStores"/>
    </admin-filters>

    <admin-card flush>
        <admin-grid id="collections-grid"
                    read-url="@Url.Action("List", "Collection", new { area = Constants.AreaAdmin })"
                    additional-data="additionalData">
            <grid-text name="published" value="@Loc["Admin.Catalog.Collections.Fields.Published"]"/>
            <grid-text name="unpublished" value="@Loc["Admin.Catalog.Products.Fields.Published.Unpublished"]"/>
            <grid-column field="Name" title="@Loc["Admin.Catalog.Collections.Fields.Name"]">
                <cell-template>
                    <a class="text-decoration-none" href="Edit/{{ Id }}">{{ Name }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="ShowOnHomePage" title="@Loc["Admin.Catalog.Collections.Fields.ShowOnHomePage"]" width="175" align="Center" min-screen-width="750">
                <cell-template>
                    <i data-if="ShowOnHomePage" 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="IncludeInMenu" title="@Loc["Admin.Catalog.Collections.Fields.IncludeInMenu"]" width="175" align="Center" min-screen-width="750">
                <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>
            @* a state is a word, not a tick *@
            <grid-column field="Published" title="@Loc["Admin.Catalog.Collections.Fields.Published"]" width="110" align="Center" min-screen-width="500">
                <cell-template>
                    <span data-if="Published" class="grand-chip grand-chip--green">{{ $texts.published }}</span>
                    <span data-else class="grand-chip grand-chip--red">{{ $texts.unpublished }}</span>
                </cell-template>
            </grid-column>
            <grid-column field="DisplayOrder" title="@Loc["Admin.Catalog.Collections.Fields.DisplayOrder"]" width="125" align="Center" min-screen-width="750"/>
        </admin-grid>
    </admin-card>
</admin-page>
<script>
    $(document).ready(function () {
        //search button
        $('#search-collections').click(function () {
            //search
            var grid = GrandAdmin.grids.get('#collections-grid');
            grid.dataSource.page(1);
            return false;
        });

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

    function additionalData() {
        var data = {
            SearchCollectionName: $('#@Html.IdFor(model => model.SearchCollectionName)').val(),
            SearchStoreId: $('#SearchStoreId').val()
        };
        addAntiForgeryToken(data);
        return data;
    }
</script>
<admin-import-window id="importexcel-window" button-id="importexcel"
                     title="@Loc["Admin.Common.ImportFromExcel"]"
                     controller="Collection" action="ImportFromXlsx"
                     file-name="importexcelfile" file-label="@Loc["Admin.Common.ExcelFile"]"
                     accept=".xlsx,.xls"
                     submit-text="@Loc["Admin.Common.ImportFromExcel"]">
    <em>@Loc["Admin.Catalog.Collection.List.ImportFromExcelTip"]</em>
</admin-import-window>