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.3 KB
Raw Blame
@model ProductModel
@{
    var area = ViewContext.RouteData.Values["area"]?.ToString();
    //a product the store may see but not change (see BaseProductController.Edit)
    bool readOnly = ViewBag.IsReadOnly == true;
}
@if (!string.IsNullOrEmpty(Model.Id))
{
    <div class="grand-card">
        <partial name="Partials/WidgetZone.CrossSells.Top" model="Model"/>
        <div class="grand-card__header">
            <h2 class="grand-card__title">@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.CrossSells"]</h2>
            @if (!readOnly)
            {
                <a id="btnAddNewCrossSellProduct" href="@(Url.Action("CrossSellProductAddPopup", "Product", new { productId = Model.Id, btnId = "btnRefreshCrossSellProducts", formId = "product-form", area = area }))" class="btn btn-outline-secondary btn-sm"><i class="bi bi-plus-lg"></i> @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.CrossSells.AddNew"]</a>
                <input type="submit" id="btnRefreshCrossSellProducts" style="display: none"/>
            }
        </div>
        <div class="grand-card__body grand-card__body--flush">
            <admin-grid id="crosssellproducts-grid"
                        read-only="@readOnly"
                        read-url="@Url.Action("CrossSellProductList", "Product", new { productId = Model.Id, area = area })"
                        destroy-url="@Url.Action("CrossSellProductDelete", "Product", new { productId = Model.Id, area = area })"
                        pager="Compact"
                        auto-bind="false">
                <grid-column field="Product2Name" title="@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.CrossSells.Fields.Product"]">
                    <cell-template>
                        <a class="text-decoration-none" href="@Url.Action("Edit", "Product", new { id = "", area = area })/{{ Id }}">{{ Product2Name }}</a>
                    </cell-template>
                </grid-column>
                <grid-commands destroy="true" title="@Loc[$"{Scope.ResourceKeyPrefix}.Common.Delete"]"/>
            </admin-grid>
        </div>
        <partial name="Partials/WidgetZone.CrossSells.Bottom" model="Model"/>
    </div>

    <script>
        $(document).ready(function () {
            $('#btnAddNewCrossSellProduct').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 () {
            $('#btnRefreshCrossSellProducts').click(function () {
                //refresh grid
                var grid = GrandAdmin.grids.get("#crosssellproducts-grid");
                grid.dataSource.read();

                //return false to don't reload a page
                return false;
            });
        });
    </script>
}
else
{
    <div class="note note-info">
        @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.CrossSells.SaveBeforeEdit"]
    </div>
}