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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
@using Microsoft.AspNetCore.Mvc.Razor
@model ProductModel.ProductAttributeValueModel
@{
var area = ViewContext.RouteData.Values["area"]?.ToString();
}
<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden"/>
<input asp-for="ProductAttributeMappingId" type="hidden"/>
<input asp-for="DisplayColorSquaresRgb" type="hidden"/>
<input asp-for="DisplayImageSquaresPicture" type="hidden"/>
<script>
$(document).ready(function () {
$("#@Html.IdFor(model => model.AttributeValueTypeId)").change(toggleProductType);
toggleProductType();
});
$('#btnAssociateProductToAttributeValuePopup').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');
}
}
});
function toggleProductType() {
var selectedProductTypeId = $("#@Html.IdFor(model => model.AttributeValueTypeId)").val();
if (selectedProductTypeId == @(((int)AttributeValueType.Simple).ToString())) {
$('#group-associated-product').hide();
$('#group-quantity').hide();
$('#group-weight-adjustment').show();
$('#group-cost').show();
} else if (selectedProductTypeId == @(((int)AttributeValueType.AssociatedToProduct).ToString())) {
$('#group-associated-product').show();
$('#group-quantity').show();
$('#group-weight-adjustment').hide();
$('#group-cost').hide();
}
}
</script>
<!-- #region languages template -->
@{
Func<int, HelperResult>
template = @<div class="grand-fields">
<admin-field asp-for="@Model.Locales[item].Name"/>
<input asp-for="@Model.Locales[item].LanguageId" type="hidden"/>
</div>;
}
<!-- #endregion -->
@* the group-* ids are what toggleProductType() above shows and hides; the product and quantity
of an "associated to product" value sit right under the type that reveals them *@
<div class="grand-reveal">
<admin-field asp-for="AttributeValueTypeId" size="md" asp-items="EnumTranslationService.ToSelectList(Model.AttributeValueTypeId)"/>
<div class="grand-reveal__body grand-fields grand-fields--2col">
<admin-field asp-for="AssociatedProductId" id="group-associated-product">
<input asp-for="AssociatedProductId" type="hidden"/>
<div class="d-flex flex-wrap align-items-center gap-2">
<span id="associate-product-name">@Model.AssociatedProductName</span>
<a id="btnAssociateProductToAttributeValuePopup" href="@(Url.Action("AssociateProductToAttributeValuePopup", "Product", new { productIdInput = Html.IdFor(model => model.AssociatedProductId), productNameInput = "associate-product-name", area = area }))" class="btn btn-outline-secondary btn-sm">
@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.AddNew"]
</a>
</div>
</admin-field>
<admin-field asp-for="Quantity" id="group-quantity" size="sm"/>
</div>
</div>
<localized-editor localized-template="@template" name="productattributevalue-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">
<div class="grand-fields">
<admin-field asp-for="Name"/>
</div>
</localized-editor>
<div class="grand-fields grand-fields--2col">
@if (Model.DisplayColorSquaresRgb)
{
<admin-field asp-for="ColorSquaresRgb">
<admin-input asp-for="ColorSquaresRgb"/>
<div id="color-picker"></div>
<script>
$(document).ready(function(){
$('#color-picker').farbtastic('#@Html.IdFor(model => model.ColorSquaresRgb)');
});
</script>
</admin-field>
}
@if (Model.DisplayImageSquaresPicture)
{
ViewData["Reference"] = "Product";
ViewData["ObjectId"] = Model.ProductId;
<admin-field asp-for="ImageSquaresPictureId"/>
}
<admin-field asp-for="PriceAdjustment" id="group-price-adjustment" suffix="@Model.PrimaryStoreCurrencyCode" size="md"/>
<admin-field asp-for="WeightAdjustment" id="group-weight-adjustment" size="md"/>
<admin-field asp-for="Cost" id="group-cost" suffix="@Model.PrimaryStoreCurrencyCode" size="md"/>
<admin-field asp-for="DisplayOrder" size="sm"/>
<admin-field asp-for="IsPreSelected"/>
</div>
<admin-field asp-for="PictureId">
@* one radio per product picture, and a "no picture" one; the pictures are the labels *@
<ul class="grand-picture-choice">
<li>
<input type="radio" name="@Html.NameFor(x => x.PictureId)" value="0" id="id_image_0"
@if (!string.IsNullOrEmpty(Model.PictureId))
{
<text> checked="checked" </text>
}>
<label for="id_image_0">
@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.ProductAttributes.Attributes.Values.Fields.Picture.NoPicture"]
</label>
</li>
@foreach (var picture in Model.ProductPictureModels)
{
<li>
<input type="radio" name="@Html.NameFor(x => x.PictureId)" value="@picture.PictureId" id="[email protected]"
@if (picture.PictureId == Model.PictureId)
{
<text> checked="checked" </text>
}>
<label for="[email protected]">
<img src="@picture.PictureUrl" alt="" title="">
</label>
</li>
}
</ul>
</admin-field>
<div class="grand-popup__actions">
<partial name="Partials/WidgetZone.AttributeValueButtons"/>
<button class="btn btn-primary" type="submit" name="save">
<i class="bi bi-check-lg"></i> @Loc[$"{Scope.ResourceKeyPrefix}.Common.Save"]
</button>
</div>