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.

5.3 KB
Raw Blame
@using Microsoft.AspNetCore.Mvc.Razor
@model CourseModel

<script>
    $(document).ready(function () {
        toggleRemoveButton();
    });
    function toggleRemoveButton() {
        if ($('#@Html.IdFor(model => model.ProductId)').val() != '' ) {
            $('#purchased-with-product-name-remove').show();
        }
        else {
            $('#purchased-with-product-name-remove').hide();
        }
    }
</script>
<vc:admin-widget widget-zone="course_details_info_top" additional-data="Model"/>

@{
    Func<int, HelperResult>
        template = @<div class="grand-fields">
            <admin-field asp-for="@Model.Locales[item].Name"/>
            <admin-field asp-for="@Model.Locales[item].ShortDescription">
                <admin-textarea asp-for="@Model.Locales[item].ShortDescription"></admin-textarea>
            </admin-field>
            <admin-field asp-for="@Model.Locales[item].Description" asp-template="Editor"/>
            <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>
        </div>;
}

@* Two cards instead of one column of 3/9 rows: what the course says, then how it is sold and
   shown. The product it comes with keeps its chooser and remove buttons beside the name; the ids
   the scripts use - purchased-with-product-name, purchased-with-product-name-remove,
   btnAssociateProductToCoursePopup, btnRefreshPurchasedWithProduct - are unchanged. *@
<admin-card>
    <localized-editor localized-template="@template" name="course-info-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">
        <div class="grand-fields">
            <admin-field asp-for="Name"/>
            <admin-field asp-for="ShortDescription">
                <admin-textarea asp-for="ShortDescription"></admin-textarea>
            </admin-field>
            <admin-field asp-for="Description" asp-template="Editor"/>
        </div>
    </localized-editor>
</admin-card>
<admin-card>
    <div class="grand-fields grand-fields--2col">
        <admin-field asp-for="LevelId" asp-items="Model.AvailableLevels"/>
        <admin-field asp-for="Published"/>
        <admin-field asp-for="DisplayOrder" size="sm"/>
        <admin-field asp-for="Stores"/>
        <admin-field asp-for="ProductId">
            <input asp-for="ProductId" type="hidden"/>
            <div class="d-flex flex-wrap align-items-center gap-2">
                <span id="purchased-with-product-name">
                    @if (!string.IsNullOrEmpty(Model.ProductId) && !string.IsNullOrEmpty(Model.ProductName))
                    {
                        @Html.ActionLink(Model.ProductName, "Edit", "Product", new { id = Model.ProductId })
                    }
                </span>
                <a id="btnAssociateProductToCoursePopup" href="@(Url.Action("AssociateProductToCoursePopup", "Course", new { productIdInput = Html.IdFor(model => model.ProductId), productNameInput = "purchased-with-product-name", btnId = "btnRefreshPurchasedWithProduct", area = Constants.AreaAdmin }))" class="btn btn-outline-secondary btn-sm">
                    @Loc["Admin.Courses.Course.Fields.PurchasedWithProduct.Choose"]
                </a>
                <button type="button" id="purchased-with-product-name-remove" class="btn btn-outline-danger btn-sm">
                    @Loc["Admin.Courses.Course.Fields.PurchasedWithProduct.Remove"]
                </button>
                <input type="button" id="btnRefreshPurchasedWithProduct" style="display: none"/>
            </div>
                <script>
                            $(document).ready(function () {
                                $('#btnAssociateProductToCoursePopup').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');
                                        }
                                    }
                                });
                                $('#purchased-with-product-name-remove').click(function () {
                                    $('#purchased-with-product-name').text('');
                                    $("#@Html.IdFor(model => model.ProductId)").val('');
                                    toggleRemoveButton();
                                    //return false to don't reload a page
                                    return false;
                                });
                                $('#btnRefreshPurchasedWithProduct').click(function () {
                                    toggleRemoveButton();
                                    //return false to don't reload a page
                                    return false;
                                });
                            });
                </script>
        </admin-field>
        <admin-field asp-for="PictureId"/>
    </div>
</admin-card>

<vc:admin-widget widget-zone="course_details_info_bottom" additional-data="Model"/>