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.

2.7 KB
Raw Blame
@using Grand.Web.AdminShared.Models.Common
@using Microsoft.AspNetCore.Mvc.Razor
@model AddressAttributeModel
@{
    var isReadOnly = Model.IsGlobalAttribute;
    var area = ViewContext.RouteData.Values["area"]?.ToString();
}
<script>
    $(document).ready(function () {
        $("#@Html.IdFor(model => model.AttributeControlTypeId)").change(toggleAttributeControlType);
        toggleAttributeControlType();

    });
    function toggleAttributeControlType() {
        var selectedAttributeControlTypeId = $("#@Html.IdFor(model => model.AttributeControlTypeId)").val();
        if (selectedAttributeControlTypeId == @(((int)AttributeControlType.TextBox).ToString())) {
            $('#tab-addressattributesvalues').hide();
        } else if (selectedAttributeControlTypeId == @(((int)AttributeControlType.MultilineTextbox).ToString())) {
            $('#tab-addressattributesvalues').hide();
        } else {
            $('#tab-addressattributesvalues').show();
        }
    }

</script>
<partial name="Partials/WidgetZone.Info.Top" model="Model"/>
@{
    Func<int, HelperResult>
        template = @<div class="grand-fields">
            <admin-field asp-for="@Model.Locales[item].Name"/>
            <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>
        </div>;
    var attributeControlTypes = EnumTranslationService.ToSelectList(((AttributeControlType)Model.AttributeControlTypeId), valuesToExclude:
            //custom address attributes don't support some attribute control types
            [(int)AttributeControlType.Hidden, (int)AttributeControlType.FileUpload, (int)AttributeControlType.Datepicker, (int)AttributeControlType.ColorSquares, (int)AttributeControlType.ImageSquares]);
}

@* The localized name, then one card of two-column fields. A global attribute opened by a store
   owner is shown in a disabled fieldset: nothing on it can be saved. *@
<admin-card>
    <fieldset disabled="@isReadOnly">
        <localized-editor localized-template="@template" name="addressattribute-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 mt-3">
            <admin-field asp-for="AttributeControlTypeId" asp-items="attributeControlTypes" size="md"/>
            <admin-field asp-for="DisplayOrder" size="sm"/>
            <admin-field asp-for="IsRequired"/>
            @if (area == "Admin")
            {
                <admin-field asp-for="Stores"/>
            }
        </div>
    </fieldset>
</admin-card>
<partial name="Partials/WidgetZone.Info.Bottom" model="Model"/>