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.0 KB
Raw Blame
@model DiscountModel
@{
    var area = ViewContext.RouteData.Values["area"]?.ToString();
    if (!string.IsNullOrEmpty(Model.Id))
    {
        <partial name="Partials/WidgetZone.AppliedToCollections.Top" model="Model"/>
        <div class="grand-card">
            <div class="grand-card__header">
                <a id="btnAddNewCollection" href="@(Url.Action("CollectionAddPopup", "Discount", new { discountId = Model.Id, btnId = "btnRefreshCollections", formId = "discount-form", area = area }))" class="btn btn-outline-secondary btn-sm"><i class="bi bi-plus-lg"></i> @Loc["admin.marketing.Discounts.AppliedToCollections.AddNew"]</a>
                <input type="submit" id="btnRefreshCollections" style="display: none"/>
            </div>
            <div class="grand-card__body grand-card__body--flush">
                <admin-grid id="collections-grid"
                            key="CollectionId"
                            read-url="@Url.Action("CollectionList", "Discount", new { discountId = Model.Id, area = area })"
                            destroy-url="@Url.Action("CollectionDelete", "Discount", new { discountId = Model.Id, area = area })"
                            pager="Compact">
                    <grid-column field="CollectionName" title="@Loc["admin.marketing.Discounts.AppliedToCollections.Collection"]">
                        <cell-template>
                            <a class="text-decoration-none" href="@Url.Action("Edit", "Collection", new { area = area })/{{ CollectionId }}">{{ CollectionName }}</a>
                        </cell-template>
                    </grid-column>
                    <grid-commands destroy="true" width="150"/>
                </admin-grid>
            </div>
        </div>
        <partial name="Partials/WidgetZone.AppliedToCollections.Bottom" model="Model"/>
        <script>
            $(document).ready(function () {
                $('#btnAddNewCollection').magnificPopup({
                    type: 'ajax',
                    settings: { cache: false, async: false },
                    midClick: true,
                    callbacks: {
                        parseAjax: function (mfpResponse) {
                            mfpResponse.data = $('<div></div>').html(mfpResponse.data);
                        },
                        ajaxContentAdded: function () {
                            $('.mfp-wrap').removeAttr('tabindex');
                        }
                    }
                });
            });
        </script>
        <script>
            $(document).ready(function () {
                $('#btnRefreshCollections').click(function () {
                    //refresh grid
                    var grid = GrandAdmin.grids.get("#collections-grid");
                    grid.dataSource.read();

                    //return false to don't reload a page
                    return false;
                });
            });
        </script>
    }
    else
    {
        <div class="note note-info">
            @Loc["admin.marketing.Discounts.AppliedToCollections.SaveBeforeEdit"]
        </div>
    }
}