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
@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">
<div class="grand-card__header">
<h2 class="grand-card__title"></h2>
@if (!readOnly)
{
<a id="btnAddNewSpecification" href="@(Url.Action("ProductSpecAttrPopup", "Product", new { productId = Model.Id, area = area }))" class="btn btn-outline-secondary btn-sm"><i class="bi bi-plus-lg"></i> @Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.SpecificationAttributes.AddButton"]</a>
}
</div>
<partial name="Partials/WidgetZone.SpecificationAttributes.Top" model="Model"/>
<div class="grand-card__body grand-card__body--flush">
<admin-grid id="specificationattributes-grid"
read-only="@readOnly"
read-url="@Url.Action("ProductSpecAttrList", "Product", new { productId = Model.Id, area = area })"
destroy-url="@Url.Action("ProductSpecAttrDelete", "Product", new { area = area })"
pager="Compact"
auto-bind="false"
on-data-bound="bindSpecificationAttributePopups">
<grid-column field="AttributeTypeName" title="@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.SpecificationAttributes.Fields.AttributeType"]">
<cell-template>
@if (readOnly)
{
<span>{{ AttributeTypeName }}</span>
}
else
{
<a class='text-decoration-none btnMagnificPopup' href='@Url.Action("ProductSpecAttrPopup", "Product", new { area = area })/?productId=@(Model.Id)&id={{ Id }}'>{{ AttributeTypeName }}</a>
}
</cell-template>
</grid-column>
@*ValueRaw is HTML-encoded by the server (hyperlink values are kept as they are), so it is inserted as markup like before*@
<grid-column field="ValueRaw" title="@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.SpecificationAttributes.Fields.Value"]">
<cell-template>
@if (readOnly)
{
<span>{{ AttributeName }} : {{{ ValueRaw }}}</span>
}
else
{
<a class='text-decoration-none btnMagnificPopup' href='@Url.Action("ProductSpecAttrPopup", "Product", new { area = area })/?productId=@(Model.Id)&id={{ Id }}'>{{ AttributeName }} : {{{ ValueRaw }}} </a>
}
</cell-template>
</grid-column>
<grid-column field="AllowFiltering" title="@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.SpecificationAttributes.Fields.AllowFiltering"]" align="Center">
<cell-template>
<i data-if="AllowFiltering" class="bi bi-check-lg" aria-hidden="true" style="color:green"></i>
<i data-else class="bi bi-x-lg" aria-hidden="true" style="color:red"></i>
</cell-template>
</grid-column>
<grid-column field="ShowOnProductPage" title="@Loc[$"{Scope.ResourceKeyPrefix}.Catalog.Products.SpecificationAttributes.Fields.ShowOnProductPage"]" align="Center">
<cell-template>
<i data-if="ShowOnProductPage" class="bi bi-check-lg" aria-hidden="true" style="color:green"></i>
<i data-else class="bi bi-x-lg" aria-hidden="true" style="color:red"></i>
</cell-template>
</grid-column>
<grid-commands destroy="true"/>
</admin-grid>
</div>
<partial name="Partials/WidgetZone.SpecificationAttributes.Bottom" model="Model"/>
</div>
<script>
$(document).ready(function () {
$('#btnAddNewSpecification').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 bindSpecificationAttributePopups() {
$('.btnMagnificPopup').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>
<input type="submit" id="btnRefreshProductSpec" style="display: none"/>
<script>
$(document).ready(function () {
$('#btnRefreshProductSpec').click(function () {
//refresh grid
var grid = GrandAdmin.grids.get("#specificationattributes-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.SpecificationAttributes.SaveBeforeEdit"]
</div>
}