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.7 KB
Raw Blame
@model GiftVoucherListModel

@{
    var area = ViewContext.RouteData.Values["area"]?.ToString();
    ViewBag.Title = Loc["Admin.GiftVouchers"];
}

@* The product list's shape: Add new in the page header, the coupon code as the quick search with
   the rest of the criteria 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.GiftVouchers"]" icon="bi-gift">
    <page-actions>
        <partial name="Partials/WidgetZone.ListButtons" model="Model"/>
        <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>

    <admin-filters id="giftvoucher-filters" submit-id="search-giftvouchers" secondary-submit="true">
        <filters-search>
            <admin-input asp-for="CouponCode"/>
        </filters-search>
        <admin-field asp-for="ActivatedId" asp-items="Model.ActivatedList"/>
        <admin-field asp-for="RecipientName"/>
    </admin-filters>

    <admin-card flush>
        <admin-grid id="giftvouchers-grid"
                    read-url="@Url.Action("GiftVoucherList", "GiftVoucher", new { area })"
                    additional-data="additionalData">
            <grid-column field="AmountStr" title="@Loc["Admin.GiftVouchers.Fields.Amount"]" width="100">
                <cell-template>
                    <a class="text-decoration-none" href="Edit/{{ Id }}">{{ AmountStr }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="RemainingAmountStr" title="@Loc["Admin.GiftVouchers.Fields.RemainingAmount"]" width="100">
                <cell-template>
                    <a class="text-decoration-none" href="Edit/{{ Id }}">{{ RemainingAmountStr }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="Code" title="@Loc["Admin.GiftVouchers.Fields.Code"]" width="120">
                <cell-template>
                    <a class="text-decoration-none" href="Edit/{{ Id }}">{{ Code }}</a>
                </cell-template>
            </grid-column>
            <grid-column field="RecipientName" title="@Loc["Admin.GiftVouchers.Fields.RecipientName"]" width="150" min-screen-width="750"/>
            <grid-column field="IsGiftVoucherActivated" title="@Loc["Admin.GiftVouchers.Fields.IsGiftVoucherActivated"]" width="100" align="Center">
                <cell-template>
                    <i data-if="IsGiftVoucherActivated" 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.GiftVouchers.Fields.CreatedOn"]" width="180" format="{0:G}"/>
        </admin-grid>
    </admin-card>
</admin-page>

<script>
    $(document).ready(function () {

        $('#search-giftvouchers').click(function () {
            var grid = GrandAdmin.grids.get('#giftvouchers-grid');
            grid.dataSource.page(1);
            return false;
        });
    });

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

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