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.

4.9 KB
Raw Blame
@model ProductAttributeModel
@{
    var area = ViewContext.RouteData.Values["area"]?.ToString();
    if (!string.IsNullOrEmpty(Model.Id))
    {
        <div class="grand-card">
            <div class="grand-card__header">
                <h2 class="grand-card__title">@Loc["Admin.Catalog.Attributes.ProductAttributes.PredefinedValues"]</h2>
                <a id="btnAddNewValue" href="@(Url.Action("PredefinedProductAttributeValueCreatePopup", "ProductAttribute", new { productAttributeId = Model.Id, area }))" class="btn btn-outline-secondary btn-sm"><i class="bi bi-plus-lg"></i> @Loc["Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.AddNew"]</a>
                <input type="submit" id="btnRefresh" style="display:none"/>
            </div>
            <partial name="Partials/WidgetZone.PredefinedValues.Top" model="Model"/>
            <div class="grand-card__body grand-card__body--flush">
                <admin-grid id="productattributevalues-grid"
                            read-url="@Url.Action("PredefinedProductAttributeValueList", "ProductAttribute", new { productAttributeId = Model.Id, area })"
                            destroy-url="@Url.Action("PredefinedProductAttributeValueDelete", "ProductAttribute", new { area })"
                            pager="Compact"
                            confirm-destroy="true"
                            on-data-bound="bindPredefinedValuePopups">
                    <grid-column field="Name" title="@Loc["Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.Name"]" width="200">
                        <cell-template>
                            <a class='text-decoration-none editvalue' href="@Url.Action("PredefinedProductAttributeValueEditPopup", "ProductAttribute", new { area })/{{ Id }}[email protected]">{{ Name }}</a>
                        </cell-template>
                    </grid-column>
                    <grid-column field="PriceAdjustmentStr" title="@Loc["Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.PriceAdjustment"]" width="150"/>
                    <grid-column field="WeightAdjustmentStr" title="@Loc["Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.WeightAdjustment"]" width="150"/>
                    <grid-column field="IsPreSelected" title="@Loc["Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.IsPreSelected"]" width="100" align="Center">
                        <cell-template>
                            <i data-if="IsPreSelected" 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="DisplayOrder" title="@Loc["Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.Fields.DisplayOrder"]" width="100"/>
                    <grid-commands destroy="true" title="@Loc["Admin.Common.Delete"]" width="200"/>
                </admin-grid>
            </div>
            <partial name="Partials/WidgetZone.PredefinedValues.Bottom" model="Model"/>
        </div>
        <script>
            $(document).ready(function() {
                $('#btnAddNewValue').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');
                            }
                        }
                });

                $('#btnRefresh').click(function () {
                    //refresh grid
                    var grid = GrandAdmin.grids.get("#productattributevalues-grid");
                    grid.dataSource.read();

                    //return false to don't reload a page
                    return false;
                });
            });
            function bindPredefinedValuePopups() {
                $('.editvalue').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>
    }
    else
    {
        <div class="note note-info">
            @Loc["Admin.Catalog.Attributes.ProductAttributes.PredefinedValues.SaveBeforeEdit"]
        </div>
    }
}