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.

4.7 KB
Raw Blame
@using Grand.Business.Core.Interfaces.Common.Localization
@model DocumentListModel
@inject ITranslationService translationService 
@{
    //page title
    ViewBag.Title = Loc["Admin.Documents.Document.Manage"];
    var selectedList = EnumTranslationService.ToSelectList(DocumentStatus.Open, false).ToList();
    selectedList.Insert(0, new SelectListItem { Text = translationService.GetResource("Admin.Common.All"), Value = "-1", Selected = true });
}

@* The product list's shape: Add new in the page header, the name as the quick search with the
   rest of the criteria behind the Filters toggle, and the grid in a flush card. The ids the
   scripts below look up are unchanged. *@
<admin-page title="@Loc["Admin.Documents.Document.Manage"]" icon="bi-diagram-3">
    <page-actions>
        <vc:admin-widget widget-zone="document_list_buttons" additional-data="null"/>
        <a href="@Url.Action("CreateDocument", 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="document-filters" submit-id="search-documents" secondary-submit="true">
        <filters-search>
            <admin-input asp-for="SearchName"/>
        </filters-search>
        <admin-field asp-for="SearchNumber"/>
        <admin-field asp-for="SearchEmail"/>
        <admin-field asp-for="StatusId" asp-items="selectedList"/>
    </admin-filters>

    <admin-card flush>
        <admin-grid id="documents-grid"
                    read-url="@Url.Action("ListDocuments", "Document", new { area = Constants.AreaAdmin })"
                    additional-data="additionalData">
            <grid-column field="Number" title="@Loc["Admin.Documents.Document.Fields.Number"]">
                <cell-template>
                    <a class="text-decoration-none" href="EditDocument/{{ Id }}">{{ Number }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="Name" title="@Loc["Admin.Documents.Document.Fields.Name"]">
                <cell-template>
                    <a class="text-decoration-none" href="EditDocument/{{ Id }}">{{ Name }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="CustomerEmail" title="@Loc["Admin.Documents.Document.Fields.CustomerEmail"]">
                <cell-template>
                    <a class="text-decoration-none" href="EditDocument/{{ Id }}">{{ CustomerEmail }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="Published" title="@Loc["Admin.Documents.Document.Fields.Published"]" width="100" align="Center" min-screen-width="500">
                <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.Documents.Document.Fields.DisplayOrder"]" width="100" align="Center" min-screen-width="750"/>
        </admin-grid>
    </admin-card>
</admin-page>
<script>
    $(document).ready(function () {
        $('#StatusId').val("-1");

    });
</script>
<script>
    $(document).ready(function () {
        //search button
        $('#search-documents').click(function () {
            //search
            var grid = GrandAdmin.grids.get('#documents-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;
        });

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


    });

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