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 Grand.Web.AdminShared.Models.Common
@model AddressAttributeModel
@{
var isReadOnly = Model.IsGlobalAttribute;
var area = ViewContext.RouteData.Values["area"]?.ToString();
if (!string.IsNullOrEmpty(Model.Id))
{
@* the grid in a hand-written card so its Add new sits in the header; the hidden refresh
button the value popups click stays beside it *@
<div class="grand-card">
<div class="grand-card__header">
<h2 class="grand-card__title">@Loc["Admin.Address.AddressAttributes.Values"]</h2>
@if (!isReadOnly)
{
<a id="btnAddNewValue" href="@(Url.Action("ValueCreatePopup", "AddressAttribute", new { addressAttributeId = Model.Id, area }))" class="btn btn-outline-secondary btn-sm"><i class="bi bi-plus-lg"></i> @Loc["Admin.Address.AddressAttributes.Values.AddNew"]</a>
}
<input type="submit" id="btnRefresh" style="display: none"/>
</div>
<div class="grand-card__body grand-card__body--flush">
<partial name="Partials/WidgetZone.Values.Top" model="Model"/>
<admin-grid id="addressattributevalues-grid"
read-url="@Url.Action("ValueList", "AddressAttribute", new { addressAttributeId = Model.Id, area })"
destroy-url="@(isReadOnly ? null : Url.Action("ValueDelete", "AddressAttribute", new { area }))"
pager="Compact"
confirm-destroy="true"
on-data-bound="@(isReadOnly ? null : "bindAddressAttributeValuePopups")">
<grid-column field="Name" title="@Loc["Admin.Address.AddressAttributes.Values.Fields.Name"]">
<cell-template>
@if (!isReadOnly)
{
<a class="text-decoration-none editvalue" href="@Url.Action("ValueEditPopup", "AddressAttribute", new { area })/{{ Id }}[email protected]">{{ Name }}</a>
}
else
{
@:{{ Name }}
}
</cell-template>
</grid-column>
<grid-column field="IsPreSelected" title="@Loc["Admin.Address.AddressAttributes.Values.Fields.IsPreSelected"]" width="100" align="Center" min-screen-width="500">
<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.Address.AddressAttributes.Values.Fields.DisplayOrder"]" width="100" align="Center"/>
@if (!isReadOnly)
{
<grid-commands destroy="true" title="@Loc["Admin.Common.Delete"]" width="100"/>
}
</admin-grid>
<partial name="Partials/WidgetZone.Values.Bottom" model="Model"/>
</div>
</div>
if (!isReadOnly)
{
<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 () {
var grid = GrandAdmin.grids.get("#addressattributevalues-grid");
grid.dataSource.read();
return false;
});
});
function bindAddressAttributeValuePopups() {
$('.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.Address.AddressAttributes.Values.SaveBeforeEdit"]
</div>
}
}