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.2 KB
Raw Blame
@using Grand.Web.AdminShared.Models.Messages
@using Microsoft.AspNetCore.Mvc.Razor
@model ContactAttributeModel
@{
    var isReadOnly = Model.IsReadOnly;
    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())) {
            $('#pnlValidationMinLength').show();
            $('#pnlValidationMaxLength').show();
            $('#pnlValidationFileMaximumSize').hide();
            $('#pnlValidationFileAllowedExtensions').hide();
            $('#pnlDefaultValue').show();
            $('#tab-contactAttributesValues').hide();
        } else if (selectedAttributeControlTypeId == @(((int)AttributeControlType.MultilineTextbox).ToString())) {
            $('#pnlValidationMinLength').show();
            $('#pnlValidationMaxLength').show();
            $('#pnlValidationFileMaximumSize').hide();
            $('#pnlValidationFileAllowedExtensions').hide();
            $('#pnlDefaultValue').show();
            $('#tab-contactAttributesValues').hide();
        } else if (selectedAttributeControlTypeId == @(((int)AttributeControlType.FileUpload).ToString())) {
            $('#pnlValidationMinLength').hide();
            $('#pnlValidationMaxLength').hide();
            $('#pnlValidationFileMaximumSize').show();
            $('#pnlValidationFileAllowedExtensions').show();
            $('#pnlDefaultValue').hide();
            $('#tab-contactAttributesValues').hide();
        } else if (selectedAttributeControlTypeId == @(((int)AttributeControlType.Checkboxes).ToString()) ||
            selectedAttributeControlTypeId == @(((int)AttributeControlType.ReadonlyCheckboxes).ToString()) ||
            selectedAttributeControlTypeId == @(((int)AttributeControlType.RadioList).ToString()) ||
            selectedAttributeControlTypeId == @(((int)AttributeControlType.ColorSquares).ToString()) ||
            selectedAttributeControlTypeId == @(((int)AttributeControlType.DropdownList).ToString())) {
            $('#pnlValidationMinLength').hide();
            $('#pnlValidationMaxLength').hide();
            $('#pnlValidationFileMaximumSize').hide();
            $('#pnlValidationFileAllowedExtensions').hide();
            $('#pnlDefaultValue').hide();
            $('#tab-contactAttributesValues').show();
        } else {
            $('#pnlValidationMinLength').hide();
            $('#pnlValidationMaxLength').hide();
            $('#pnlValidationFileMaximumSize').hide();
            $('#pnlValidationFileAllowedExtensions').hide();
            $('#pnlDefaultValue').hide();
            $('#tab-contactAttributesValues').hide();
        }
    }
</script>
<partial name="Partials/WidgetZone.Info.Top" model="Model"/>

@{
    Func<int, HelperResult>
        template = @<fieldset disabled="@isReadOnly" class="grand-fields grand-fields--2col">
            <admin-field asp-for="@Model.Locales[item].Name"/>
            <admin-field asp-for="@Model.Locales[item].TextPrompt"/>
            <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/>
        </fieldset>;
    var attributeControlTypes = EnumTranslationService.ToSelectList(((AttributeControlType)Model.AttributeControlTypeId), valuesToExclude: [(int)AttributeControlType.ImageSquares, (int)AttributeControlType.Hidden]);
}

@* The checkout attribute's layout: the names in the localized editor, then one card of
   two-column fields. The panels the script above shows and hides keep their ids on the
   <admin-field> itself. A global attribute a store owner only looks at is a disabled fieldset,
   which keeps the language tabs clickable. *@
<admin-card>
    <localized-editor localized-template="@template" name="contactattribute-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">
        <fieldset disabled="@isReadOnly" class="grand-fields grand-fields--2col">
            <admin-field asp-for="Name"/>
            <admin-field asp-for="TextPrompt"/>
        </fieldset>
    </localized-editor>
    <fieldset disabled="@isReadOnly" class="grand-fields grand-fields--2col mt-3">
        <admin-field asp-for="AttributeControlTypeId" asp-items="attributeControlTypes"/>
        <admin-field asp-for="DisplayOrder" size="sm"/>
        <admin-field asp-for="IsRequired"/>
        @if (area == "Admin")
        {
            <admin-field asp-for="CustomerGroups"/>
            <admin-field asp-for="Stores"/>
        }
        <admin-field asp-for="ValidationMinLength" size="sm" id="pnlValidationMinLength"/>
        <admin-field asp-for="ValidationMaxLength" size="sm" id="pnlValidationMaxLength"/>
        <admin-field asp-for="ValidationFileAllowedExtensions" id="pnlValidationFileAllowedExtensions"/>
        <admin-field asp-for="ValidationFileMaximumSize" size="sm" id="pnlValidationFileMaximumSize"/>
        <admin-field asp-for="DefaultValue" id="pnlDefaultValue"/>
    </fieldset>
</admin-card>
<partial name="Partials/WidgetZone.Info.Bottom" model="Model"/>