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.

3.9 KB
Raw Blame
@model IList<CustomerModel.CustomerAttributeModel>
@foreach (var attribute in Model)
{
    var controlId = $"attributes[{attribute.Id}]";
    var textPrompt = attribute.Name;
    @* one field of the customer info card per attribute: the label above the control *@
    <div class="grand-field">
        <label class="grand-field__label" for="@(controlId)">@textPrompt</label>
        <div class="grand-field__control">

                @switch (attribute.AttributeControlType)
                {
                    case AttributeControlType.DropdownList:
                    {
                        <select class="form-select" name="@(controlId)" id="@(controlId)">
                            @if (!attribute.IsRequired)
                            {
                                <option value="">---</option>
                            }
                            @foreach (var attributeValue in attribute.Values)
                            {
                                <option selected="@attributeValue.IsPreSelected" value="@attributeValue.Id">@attributeValue.Name</option>
                            }
                        </select>
                    }
                        break;
                    case AttributeControlType.RadioList:
                    {
                        <div class="radio-list">
                            @foreach (var attributeValue in attribute.Values)
                            {
                                <div class="form-check">
                                    <input id="@(controlId)_@(attributeValue.Id)" class="form-check-input" type="radio" name="@(controlId)" value="@attributeValue.Id" checked="@attributeValue.IsPreSelected"/>
                                    <label class="form-check-label" for="@(controlId)_@(attributeValue.Id)">@attributeValue.Name</label>
                                </div>
                            }
                        </div>
                    }
                        break;
                    case AttributeControlType.Checkboxes:
                    case AttributeControlType.ReadonlyCheckboxes:
                    {
                        <div class="checkbox-list">
                            @foreach (var attributeValue in attribute.Values)
                            {
                                <div class="form-check">
                                    <input id="@(controlId)_@(attributeValue.Id)" class="form-check-input" type="checkbox" name="@(controlId)" value="@attributeValue.Id" checked="@(attributeValue.IsPreSelected)" @(attribute.AttributeControlType == AttributeControlType.ReadonlyCheckboxes ? Html.Raw(" disabled=\"disabled\"") : null)/>
                                    <label class="form-check-label" for="@(controlId)_@(attributeValue.Id)">@attributeValue.Name</label>
                                </div>
                            }
                        </div>
                    }
                        break;
                    case AttributeControlType.TextBox:
                    {
                        <input name="@(controlId)" type="text" class="form-control text-box single-line" id="@(controlId)" value="@(attribute.DefaultValue)"/>
                    }
                        break;
                    case AttributeControlType.MultilineTextbox:
                    {
                        <textarea id="@(controlId)" rows="5" class="form-control" name="@(controlId)">@(attribute.DefaultValue)</textarea>
                    }
                        break;
                    case AttributeControlType.Datepicker:
                    case AttributeControlType.FileUpload:
                    case AttributeControlType.ColorSquares:
                    case AttributeControlType.ImageSquares:
                    {
                        //not support attribute type
                    }
                        break;
                }
        </div>
    </div>
}