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.

4.9 KB
Raw Blame
@model IList<ProductAttributeCombinationModel.ProductAttributeModel>
@* The attribute choices of a new combination: one field per attribute, in the field layout of
   the rest of the popup. Every control keeps the attributes[{id}] name the controller reads. *@
@if (Model.Count > 0)
{
    <div class="grand-fields grand-fields--2col">
        @foreach (var attribute in Model)
        {
            var controlId = $"attributes[{attribute.Id}]";
            var textPrompt = !string.IsNullOrEmpty(attribute.TextPrompt) ? attribute.TextPrompt : attribute.Name;
            <div class="grand-field">
                <label class="grand-field__label@(attribute.IsRequired ? " required" : "")" for="@(controlId)">@textPrompt</label>
                <div class="grand-field__control">
                    @switch (attribute.AttributeControlType)
                    {
                        case AttributeControlType.DropdownList:
                        {
                            <select name="@(controlId)" id="@(controlId)" class="form-select">
                                @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:
                        case AttributeControlType.ColorSquares:
                        case AttributeControlType.ImageSquares:
                        {
                            foreach (var attributeValue in attribute.Values)
                            {
                                <label class="form-check">
                                    <input id="@(controlId)" class="form-check-input" type="radio" name="@(controlId)" value="@attributeValue.Id" checked="@attributeValue.IsPreSelected"/>
                                    <span class="form-check-label">@attributeValue.Name</span>
                                </label>
                            }
                        }
                            break;
                        case AttributeControlType.Checkboxes:
                        case AttributeControlType.ReadonlyCheckboxes:
                        {
                            foreach (var attributeValue in attribute.Values)
                            {
                                <label class="form-check">
                                    <input id="@(controlId)" class="form-check-input" type="checkbox" name="@(controlId)" value="@attributeValue.Id" checked="@attributeValue.IsPreSelected" @(attribute.AttributeControlType == AttributeControlType.ReadonlyCheckboxes ? Html.Raw(" disabled=\"disabled\"") : null)/>
                                    <span class="form-check-label">@attributeValue.Name</span>
                                </label>
                            }
                        }
                            break;
                        case AttributeControlType.TextBox:
                        {
                            <input name="@(controlId)" type="text" id="@(controlId)" class="form-control"/>
                        }
                            break;
                        case AttributeControlType.MultilineTextbox:
                        {
                            <textarea cols="20" id="@(controlId)" name="@(controlId)" rows="2" class="form-control"></textarea>
                        }
                            break;
                        case AttributeControlType.Datepicker:
                        {
                            <date-picker-dropdown control-day="@(controlId + "_day")"
                                                  control-month="@(controlId + "_month")"
                                                  control-year="@(controlId + "_year")"
                                                  begin-year="@(DateTime.Now.Year)"
                                                  end-year="@(DateTime.Now.Year + 1)"
                                                  PartialViewName="Partials/DateDropDowns"
                                                  class="col-12 input-group"/>
                        }
                            break;
                        case AttributeControlType.FileUpload:
                        {
                            <input type="file" id="@(controlId)" name="@(controlId)" class="form-control"/>
                        }
                            break;
                    }
                </div>
            </div>
        }
    </div>
}