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.

10.2 KB
Raw Blame
@model CustomerSettingsModel
<script>
    $(document).ready(function () {
        $("#@Html.IdFor(model => model.CustomerSettings.DateOfBirthEnabled)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.DateOfBirthRequired)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.CountryEnabled)").click(toggleCustomerCountryFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.StateProvinceEnabled)").click(toggleCustomerStateProvinceFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.CompanyEnabled)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.StreetAddressEnabled)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.StreetAddress2Enabled)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.ZipPostalCodeEnabled)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.CityEnabled)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.PhoneEnabled)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.FaxEnabled)").click(toggleCustomerRequiredFormField);
        $("#@Html.IdFor(model => model.CustomerSettings.NewsletterEnabled)").click(toggleNewsletterEnabledField);
        $("#@Html.IdFor(model => model.CustomerSettings.HideNewsletterBlock)").click(toggleHideNewsletterBlock);

        toggleCustomerCountryFormField();
        toggleCustomerStateProvinceFormField();
        toggleCustomerRequiredFormField();
        toggleNewsletterEnabledField();
        toggleHideNewsletterBlock();
    });

    function toggleCustomerCountryFormField() {
        if ($('#@Html.IdFor(model => model.CustomerSettings.CountryEnabled)').is(':checked')) {
            $('#pnlCustomerCountryRequired').show();
            $('#pnlCustomerStateProvinceEnabled').show();
            toggleCustomerStateProvinceFormField();
        } else {
            $('#pnlCustomerCountryRequired').hide();
            $('#pnlCustomerStateProvinceEnabled').hide();
            toggleCustomerStateProvinceFormField();
        }
    }

    function toggleCustomerStateProvinceFormField() {
        if ($('#@Html.IdFor(model => model.CustomerSettings.CountryEnabled)').is(':checked') &&
            $('#@Html.IdFor(model => model.CustomerSettings.StateProvinceEnabled)').is(':checked')) {
            $('#pnlCustomerStateProvinceRequired').show();
        } else {
            $('#pnlCustomerStateProvinceRequired').hide();
        }
    }

    function toggleCustomerRequiredFormField() {
        if ($('#@Html.IdFor(model => model.CustomerSettings.DateOfBirthEnabled)').is(':checked')) {
            $('#pnlCustomerDateOfBirthRequired').show();
        } else {
            $('#pnlCustomerDateOfBirthRequired').hide();
        }

        if ($('#@Html.IdFor(model => model.CustomerSettings.DateOfBirthEnabled)').is(':checked') &&
            $('#@Html.IdFor(model => model.CustomerSettings.DateOfBirthRequired)').is(':checked')) {
            $('#pnlDateOfBirthMinimumAge').show();
        } else {
            $('#pnlDateOfBirthMinimumAge').hide();
        }

        if ($('#@Html.IdFor(model => model.CustomerSettings.CompanyEnabled)').is(':checked')) {
            $('#pnlCustomerCompanyRequired').show();
        } else {
            $('#pnlCustomerCompanyRequired').hide();
        }

        if ($('#@Html.IdFor(model => model.CustomerSettings.StreetAddressEnabled)').is(':checked')) {
            $('#pnlCustomerStreetAddressRequired').show();
        } else {
            $('#pnlCustomerStreetAddressRequired').hide();
        }

        if ($('#@Html.IdFor(model => model.CustomerSettings.StreetAddress2Enabled)').is(':checked')) {
            $('#pnlCustomerStreetAddress2Required').show();
        } else {
            $('#pnlCustomerStreetAddress2Required').hide();
        }

        if ($('#@Html.IdFor(model => model.CustomerSettings.ZipPostalCodeEnabled)').is(':checked')) {
            $('#pnlCustomerZipPostalCodeRequired').show();
        } else {
            $('#pnlCustomerZipPostalCodeRequired').hide();
        }

        if ($('#@Html.IdFor(model => model.CustomerSettings.CityEnabled)').is(':checked')) {
            $('#pnlCustomerCityRequired').show();
        } else {
            $('#pnlCustomerCityRequired').hide();
        }

        if ($('#@Html.IdFor(model => model.CustomerSettings.PhoneEnabled)').is(':checked')) {
            $('#pnlCustomerPhoneRequired').show();
        } else {
            $('#pnlCustomerPhoneRequired').hide();
        }

        if ($('#@Html.IdFor(model => model.CustomerSettings.FaxEnabled)').is(':checked')) {
            $('#pnlCustomerFaxRequired').show();
        } else {
            $('#pnlCustomerFaxRequired').hide();
        }
    }

    function toggleNewsletterEnabledField() {
        if ($('#@Html.IdFor(model => model.CustomerSettings.NewsletterEnabled)').is(':checked')) {
            $('#pnlCustomerNewsletterTickedByDefault').show();
        } else {
            $('#pnlCustomerNewsletterTickedByDefault').hide();
        }
    }

    function toggleHideNewsletterBlock() {
        if ($('#@Html.IdFor(model => model.CustomerSettings.HideNewsletterBlock)').is(':checked')) {
            $('#pnlNewsletterBlockAllowToUnsubscribe').hide();
        }
        else {
            $('#pnlNewsletterBlockAllowToUnsubscribe').show();
        }
    }

</script>
@* which fields the registration and account forms ask for; a field that is on reveals whether it
   is required, date of birth one level deeper the minimum age, the country the state field *@
<admin-card>
    <div class="note note-info">
        @Loc["Admin.Settings.Customer.CustomerFormFields.Description"]
    </div>
    <div class="grand-fields grand-fields--2col">
        <admin-field asp-for="CustomerSettings.FirstLastNameRequired"/>
        <admin-field asp-for="CustomerSettings.GenderEnabled"/>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.DateOfBirthEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <div class="grand-reveal">
                    <admin-field asp-for="CustomerSettings.DateOfBirthRequired" id="pnlCustomerDateOfBirthRequired"/>
                    <div class="grand-reveal__body grand-fields grand-fields--2col">
                        <admin-field asp-for="CustomerSettings.DateOfBirthMinimumAge" id="pnlDateOfBirthMinimumAge" size="sm"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.CompanyEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.CompanyRequired" id="pnlCustomerCompanyRequired"/>
            </div>
        </div>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.PhoneEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.PhoneRequired" id="pnlCustomerPhoneRequired"/>
            </div>
        </div>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.FaxEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.FaxRequired" id="pnlCustomerFaxRequired"/>
            </div>
        </div>
    </div>
</admin-card>
<admin-card>
    <div class="grand-fields grand-fields--2col">
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.StreetAddressEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.StreetAddressRequired" id="pnlCustomerStreetAddressRequired"/>
            </div>
        </div>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.StreetAddress2Enabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.StreetAddress2Required" id="pnlCustomerStreetAddress2Required"/>
            </div>
        </div>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.ZipPostalCodeEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.ZipPostalCodeRequired" id="pnlCustomerZipPostalCodeRequired"/>
            </div>
        </div>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.CityEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.CityRequired" id="pnlCustomerCityRequired"/>
            </div>
        </div>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.CountryEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.CountryRequired" id="pnlCustomerCountryRequired"/>
                <div class="grand-reveal">
                    <admin-field asp-for="CustomerSettings.StateProvinceEnabled" id="pnlCustomerStateProvinceEnabled"/>
                    <div class="grand-reveal__body grand-fields grand-fields--2col">
                        <admin-field asp-for="CustomerSettings.StateProvinceRequired" id="pnlCustomerStateProvinceRequired"/>
                    </div>
                </div>
            </div>
        </div>
    </div>
</admin-card>
<admin-card>
    <div class="grand-fields grand-fields--2col">
        <admin-field asp-for="CustomerSettings.AcceptPrivacyPolicyEnabled"/>
        <div class="grand-reveal">
            <admin-field asp-for="CustomerSettings.NewsletterEnabled"/>
            <div class="grand-reveal__body grand-fields grand-fields--2col">
                <admin-field asp-for="CustomerSettings.NewsletterTickedByDefault" id="pnlCustomerNewsletterTickedByDefault"/>
            </div>
        </div>
    </div>
</admin-card>