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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
custom address attributes - vee validation added
DanielŻuławski182c6e6b25cd
diff --git a/src/Web/Grand.Web/Views/Shared/_AddressAttributes.cshtml b/src/Web/Grand.Web/Views/Shared/_AddressAttributes.cshtmlindex c4d042373..3f77b3674 100644--- a/src/Web/Grand.Web/Views/Shared/_AddressAttributes.cshtml+++ b/src/Web/Grand.Web/Views/Shared/_AddressAttributes.cshtml@@ -15,16 +15,19 @@{case AttributeControlType.DropdownList:{- <select class="custom-selec form-control" 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>+ <validation-provider @if (attribute.IsRequired) { <text> rules="required" </text> } name="@(controlId)" v-slot="{ errors, classes }">+ <select v-model="createorupdateaddress.@(controlId)" data-val-required="@(string.Format(Loc["Fields.IsRequired"], textPrompt))" v-bind:class="[classes , 'custom-select form-control']" 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>+ <span class="field-validation-error">{{ errors[0] }}</span>+ </validation-provider>}break;case AttributeControlType.RadioList:@@ -33,12 +36,14 @@@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>+ <validation-provider tag="li" vid="@(controlId)" @if (attribute.IsRequired) { <text> rules="required" </text> } v-slot="{ errors, classes }">+ <label for="@(controlId)_@(attributeValue.Id)" class="custom-control custom-radio">+ <input v-bind:class="[classes , 'custom-control-input']" data-val="true" data-val-required="@(string.Format(Loc["Fields.IsRequired"], textPrompt))" v-model="createorupdateaddress.@(controlId)" 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>+ <span class="field-validation-error d-flex w-100">{{ errors[0] }}</span>+ </label>+ </validation-provider></li>}@@ -51,21 +56,25 @@<ul class="option-list pl-0">@foreach (var attributeValue in attribute.Values){- <li>+ <validation-provider tag="li" vid="@(controlId)" @if (attribute.IsRequired) { <text> :rules="{ required: { allowFalse: false } }" </text> } v-slot="{ errors, classes }"><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) />+ <input v-bind:class="[classes , 'custom-control-input']" data-val="true" data-val-required="@(string.Format(Loc["Fields.IsRequired"], textPrompt))" v-model="createorupdateaddress.@(controlId)" 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>+ <span class="field-validation-error d-flex w-100">{{ errors[0] }}</span></label>- </li>+ </validation-provider>}</ul>}break;case AttributeControlType.TextBox:{- <input name="@(controlId)" type="text" class="form-control textbox"- id="@(controlId)" value="@(attribute.DefaultValue)" data-val-required="@(string.Format(Loc["Fields.IsRequired"], textPrompt))" />+ <validation-provider @if (attribute.IsRequired) { <text> rules="required" </text> } name="@(controlId)" v-slot="{ errors, classes }">+ <input name="@(controlId)" type="text"+ id="@(controlId)" v-model="createorupdateaddress.@(controlId)" data-val-required="@(string.Format(Loc["Fields.IsRequired"], textPrompt))" v-bind:class="[classes , 'form-control textbox']" />+ <span class="field-validation-error">{{ errors[0] }}</span>+ </validation-provider>}break;case AttributeControlType.MultilineTextbox:diff --git a/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateAddress.cshtml b/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateAddress.cshtmlindex 1479a80ab..1df0c7e5d 100644--- a/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateAddress.cshtml+++ b/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateAddress.cshtml@@ -1,5 +1,5 @@@model AddressModel-@{+@{var prefix = ViewData.TemplateInfo.HtmlFieldPrefix;}@if (Model.CountryEnabled && Model.StateProvinceEnabled)@@ -303,7 +303,11 @@FaxNumber: '@Html.Raw(Model.FaxNumber)',VatNumber: '@Html.Raw(Model.VatNumber)',Email: '@Html.Raw(Model.Email)',- prefix: '@prefix'+ prefix: '@prefix',+ @foreach (var item in Model.CustomAddressAttributes)+ {+ <text>address_attribute_</text> @item.Id <text>: '',</text>+ }</text>}})