Skip to content

Commit

Permalink
VueTheme - AddressAttributes - add field-validation-error for TextBox…
Browse files Browse the repository at this point in the history
…/MultilineTextbox
  • Loading branch information
KrzysztofPajak committed Jan 27, 2021
1 parent b475967 commit a594bde
Showing 1 changed file with 81 additions and 79 deletions.
160 changes: 81 additions & 79 deletions Grand.Web/Themes/VueTheme/Views/Shared/_AddressAttributes.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,86 +4,88 @@
string controlId = string.Format("address_attribute_{0}", attribute.Id);
string textPrompt = attribute.Name;

<div class="inputs custom-attributes col-sm-12 mb-3">
<label class="col-form-label" for="@(controlId)">@textPrompt:</label>
@if (attribute.IsRequired)
{
<span class="required">*</span>
}
<div class="inputs custom-attributes col-sm-12 mb-3">
<label class="col-form-label" for="@(controlId)">@textPrompt:</label>
@if (attribute.IsRequired)
{
<span class="required">*</span>
}

@switch (attribute.AttributeControlType)
{
case AttributeControlType.DropdownList:
{
<select class="custom-selec form-control" name="@(controlId)" id="@(controlId)">
@if (!attribute.IsRequired)
{
<option value="0">---</option>
}
@foreach (var attributeValue in attribute.Values)
{
<option selected="@attributeValue.IsPreSelected" value="@attributeValue.Id">@attributeValue.Name</option>
}
</select>
}
break;
case AttributeControlType.RadioList:
{
<ul class="option-list pl-0">
@foreach (var attributeValue in attribute.Values)
{
<li>
@switch (attribute.AttributeControlType)
{
case AttributeControlType.DropdownList:
{
<select class="custom-selec form-control" name="@(controlId)" id="@(controlId)">
@if (!attribute.IsRequired)
{
<option value="0">---</option>
}
@foreach (var attributeValue in attribute.Values)
{
<option selected="@attributeValue.IsPreSelected" value="@attributeValue.Id">@attributeValue.Name</option>
}
</select>
}
break;
case AttributeControlType.RadioList:
{
<ul class="option-list pl-0">
@foreach (var attributeValue in attribute.Values)
{
<li>

<label for="@(controlId)_@(attributeValue.Id)" class="custom-control custom-radio">
<input class="custom-control-input" id="@(controlId)_@(attributeValue.Id)" type="radio" name="@(controlId)" value="@attributeValue.Id" checked="@attributeValue.IsPreSelected" />
<span class="custom-control-label"></span>
<span class="custom-control-description">@attributeValue.Name</span>
</label>
<label for="@(controlId)_@(attributeValue.Id)" class="custom-control custom-radio">
<input class="custom-control-input" id="@(controlId)_@(attributeValue.Id)" type="radio" name="@(controlId)" value="@attributeValue.Id" checked="@attributeValue.IsPreSelected" />
<span class="custom-control-label"></span>
<span class="custom-control-description">@attributeValue.Name</span>
</label>

</li>
}
</ul>
}
break;
case AttributeControlType.Checkboxes:
case AttributeControlType.ReadonlyCheckboxes:
{
<ul class="option-list pl-0">
@foreach (var attributeValue in attribute.Values)
{
<li>
<label class="custom-control custom-checkbox">
<input class="custom-control-input" id="@(controlId)_@(attributeValue.Id)" type="checkbox" name="@(controlId)" value="@(attributeValue.Id)" checked="@attributeValue.IsPreSelected" @(attribute.AttributeControlType == AttributeControlType.ReadonlyCheckboxes ? Html.Raw(" disabled=\"disabled\"") : null) />
<span class="custom-control-label"></span>
<span class="custom-control-description">@attributeValue.Name</span>
</label>
</li>
}
</ul>
}
break;
case AttributeControlType.TextBox:
{
<input name="@(controlId)" type="text" class="form-control textbox"
v-validate="'@(attribute.IsRequired ? "required":"")'"
id="@(controlId)" value="@(attribute.DefaultValue)" />
}
break;
case AttributeControlType.MultilineTextbox:
{
<textarea class="form-control" id="@(controlId)"
v-validate="'@(attribute.IsRequired ? "required":"")'"
name="@(controlId)">@(attribute.DefaultValue)</textarea>
}
break;
case AttributeControlType.Datepicker:
case AttributeControlType.FileUpload:
case AttributeControlType.ColorSquares:
case AttributeControlType.ImageSquares:
{
//not support attribute type
}
break;
}
</div>
</li>
}
</ul>
}
break;
case AttributeControlType.Checkboxes:
case AttributeControlType.ReadonlyCheckboxes:
{
<ul class="option-list pl-0">
@foreach (var attributeValue in attribute.Values)
{
<li>
<label class="custom-control custom-checkbox">
<input class="custom-control-input" id="@(controlId)_@(attributeValue.Id)" type="checkbox" name="@(controlId)" value="@(attributeValue.Id)" checked="@attributeValue.IsPreSelected" @(attribute.AttributeControlType == AttributeControlType.ReadonlyCheckboxes ? Html.Raw(" disabled=\"disabled\"") : null) />
<span class="custom-control-label"></span>
<span class="custom-control-description">@attributeValue.Name</span>
</label>
</li>
}
</ul>
}
break;
case AttributeControlType.TextBox:
{
<input name="@(controlId)" type="text" class="form-control textbox"
v-validate="'@(attribute.IsRequired ? "required":"")'"
id="@(controlId)" value="@(attribute.DefaultValue)" data-val-required="@(string.Format(@T("Fields.IsRequired").Text, textPrompt))" />
<span class="field-validation-error">{{veeErrors.first('@(controlId)')}}</span>
}
break;
case AttributeControlType.MultilineTextbox:
{
<textarea class="form-control" id="@(controlId)"
v-validate="'@(attribute.IsRequired ? "required":"")'" data-val-required="@(string.Format(@T("Fields.IsRequired").Text, textPrompt))"
name="@(controlId)">@(attribute.DefaultValue)</textarea>
<span class="field-validation-error">{{veeErrors.first('@(controlId)')}}</span>
}
break;
case AttributeControlType.Datepicker:
case AttributeControlType.FileUpload:
case AttributeControlType.ColorSquares:
case AttributeControlType.ImageSquares:
{
//not support attribute type
}
break;
}
</div>
}

0 comments on commit a594bde

Please sign in to comment.