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.

2.8 KB
Raw Blame
@model MessageTemplateListModel
@{
    //page title
    ViewBag.Title = Loc["Admin.Content.MessageTemplates"];
}

@* 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.MessageTemplates"]" icon="bi-envelope">
    <page-actions>
        <vc:admin-widget widget-zone="message_template_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="template-filters" submit-id="search-templates" 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="templates-grid"
                    read-url="@Url.Action("List", "MessageTemplate", new { area = Constants.AreaAdmin })"
                    additional-data="additionalData">
            <grid-column field="Name" title="@Loc["Admin.Content.MessageTemplates.Fields.Name"]" width="200">
                <cell-template>
                    <a class="text-decoration-none" href="Edit/{{ Id }}">{{ Name }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="Subject" title="@Loc["Admin.Content.MessageTemplates.Fields.Subject"]" width="100"/>
            <grid-column field="IsActive" title="@Loc["Admin.Content.MessageTemplates.Fields.IsActive"]" width="50" align="Center">
                <cell-template>
                    <i data-if="IsActive" 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>
        </admin-grid>
    </admin-card>
</admin-page>

<script>

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

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

    });

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