@model VendorSearchModel
@{
    //page title
    ViewBag.PageTitle = T("Admin.Vendors").Text;
    //active menu item (system name)
    NopHtml.SetActiveMenuItemSystemName("Vendors");
}

@{
    const string hideSearchBlockAttributeName = "VendorsPage.HideSearchBlock";
    var hideSearchBlock = await genericAttributeService.GetAttributeAsync<bool>(await workContext.GetCurrentCustomerAsync(), hideSearchBlockAttributeName);
}

<div class="content-header clearfix">
    <h1 class="float-left">
        @T("Admin.Vendors")
    </h1>
    <div class="float-right">
        <a asp-action="Create" class="btn btn-primary">
            <i class="fas fa-plus-square"></i>
            @T("Admin.Common.AddNew")
        </a>
        @await Component.InvokeAsync(typeof(AdminWidgetViewComponent), new { widgetZone = AdminWidgetZones.VendorListButtons, additionalData = Model })
    </div>
</div>

<section class="content">
    <div class="container-fluid">
    <div class="form-horizontal">
        <div class="cards-group">
            <div class="card card-default card-search">
                <div class="card-body">
                    <div class="row search-row @(!hideSearchBlock ? "opened" : "")" data-hideAttribute="@hideSearchBlockAttributeName">
                        <div class="search-text">@T("Admin.Common.Search")</div>
                        <div class="icon-search"><i class="fas fa-search" aria-hidden="true"></i></div>
                        <div class="icon-collapse"><i class="far fa-angle-@(!hideSearchBlock ? "up" : "down")" aria-hidden="true"></i></div>
                    </div>

                    <div class="search-body @(hideSearchBlock ? "closed" : "")">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group row">
                                    <div class="col-md-4">
                                        <nop-label asp-for="SearchName" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="SearchName" />
                                    </div>
                                </div>
                                </div>
                            <div class="col-md-6">
                                <div class="form-group row">
                                    <div class="col-md-4">
                                        <nop-label asp-for="SearchEmail" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-editor asp-for="SearchEmail" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="text-center col-12">
                                <button type="button" id="search-vendors" class="btn btn-primary btn-search">
                                    <i class="fas fa-search"></i>
                                    @T("Admin.Common.Search")
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="card card-default">
                <div class="card-body">
                    <nop-doc-reference asp-string-resource="@T("Admin.Documentation.Reference.VendorManagement", Docs.VendorManagement + Utm.OnAdmin)" />

                    @await Html.PartialAsync("Table", new DataTablesModel
                    {
                        Name = "vendors-grid",
                        UrlRead = new DataUrl("List", "Vendor", null),
                        SearchButtonId = "search-vendors",
                        Length = Model.PageSize,
                        LengthMenu = Model.AvailablePageSizes,
                        Filters = new List<FilterParameter>
                        {
                            new FilterParameter(nameof(Model.SearchName)),
                            new FilterParameter(nameof(Model.SearchEmail))
                        },
                        ColumnCollection = new List<ColumnProperty>
                        {
                            new ColumnProperty(nameof(VendorModel.Name))
                            {
                                Title = T("Admin.Vendors.Fields.Name").Text,
                                Width = "300"
                            },
                            new ColumnProperty(nameof(VendorModel.Email))
                            {
                                Title = T("Admin.Vendors.Fields.Email").Text,
                                Width = "300"
                            },
                            new ColumnProperty(nameof(VendorModel.Active))
                            {
                                Title = T("Admin.Vendors.Fields.Active").Text,
                                Width = "50",
                                ClassName =  NopColumnClassDefaults.CenterAll,
                                Render = new RenderBoolean()
                            },
                            new ColumnProperty(nameof(VendorModel.Id))
                            {
                                Title = T("Admin.Common.Edit").Text,
                                Width = "50",
                                ClassName =  NopColumnClassDefaults.Button,
                                Render = new RenderButtonEdit(new DataUrl("Edit"))
                            }
                        }
                    })
                </div>
            </div>
        </div>
    </div>
</div>
</section>