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.

adresses - state and province minor changes

DanielŻuławski78cc6f5397cc
diff --git a/src/Web/Grand.Web/Views/Account/Info.cshtml b/src/Web/Grand.Web/Views/Account/Info.cshtml
index 1b4b50c16..f8aaccf36 100644
--- a/src/Web/Grand.Web/Views/Account/Info.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Info.cshtml
@@ -15,51 +15,40 @@
@if (Model.CountryEnabled && Model.StateProvinceEnabled)
{
- <script asp-location="Footer">
- function toggleNewsletterCat() {
- var element = document.getElementById('@Html.IdFor(model => model.Newsletter)');
- if (element) {
- if (document.getElementById('@Html.IdFor(model => model.Newsletter)').checked) {
- if (document.querySelector('.register-category-newsletter')) {
- document.querySelector('.register-category-newsletter').style.display = "block";
- }
- }
- else {
- if (document.querySelector('.register-category-newsletter')) {
- document.querySelector('.register-category-newsletter').style.display = "none";
- }
- }
- }
- }
-
- document.addEventListener("DOMContentLoaded", function () {
- document.getElementById("@Html.IdFor(model => model.CountryId)").addEventListener('change', function () {
- var selectedItem = this.value;
+ <script asp-location="Footer" asp-order="300">
+ function @Html.IdFor(model => model.CountryId)_select_element(e) {
+ var selectedItem = e.value;
var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- var statesProgress = document.getElementById("states-loading-progress");
- statesProgress.style.display = "block";
axios({
method: 'get',
- url: '@(Url.RouteUrl("GetStatesByCountryId"))',
+ url: "@(Url.RouteUrl("GetStatesByCountryId"))",
params: { "countryId": selectedItem, "addSelectStateItem": "true" },
}).then(function (response) {
- ddlStates.innerHTML = "";
+ ddlStates.innerHTML = '';
response.data.forEach(function (id, option) {
elChild = document.createElement('option');
elChild.setAttribute('value', id.id);
elChild.innerHTML = id.name;
ddlStates.appendChild(elChild);
});
- statesProgress.style.display = "none";
+ customerinfo.StateProvinceId = response.data[0].id;
+ }).then(function () {
+ ddlStates.classList.remove('is-valid');
+ ddlStates.classList.add('is-invalid');
}).catch(function (error) {
alert(error);
- statesProgress.style.display = "none";
- })
- });
-
- toggleNewsletterCat();
-
- });
+ });
+ }
+ function @Html.IdFor(model => model.StateProvinceId)_select_element(e) {
+ var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
+ if (e.selectedIndex > 0) {
+ ddlStates.classList.remove('is-invalid');
+ ddlStates.classList.add('is-valid');
+ } else {
+ ddlStates.classList.remove('is-valid');
+ ddlStates.classList.add('is-invalid');
+ }
+ }
</script>
}
<script asp-location="Footer">
@@ -379,7 +368,8 @@
<validation-provider tag="div" rules="required" name="CountryId" v-slot="{ errors }">
<label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>
<span class="required">*</span>
- <select asp-for="CountryId" v-model="customerinfo.CountryId" class="custom-select form-control" asp-items="Model.AvailableCountries"></select>
+ <select asp-for="CountryId" asp-items="Model.AvailableCountries"
+ onchange="@Html.IdFor(model => model.CountryId)_select_element(this)" class="custom-select form-control" v-model="customerinfo.CountryId"></select>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="CountryId"></span>
</validation-provider>
@@ -401,9 +391,8 @@
{
<span class="required">*</span>
}
- <select asp-for="StateProvinceId"
- class="custom-select form-control"
- asp-items="Model.AvailableStates"></select>
+ <select asp-for="StateProvinceId" data-val-required="@Loc["Address.Fields.StateProvince.Required"]" class="custom-select form-control"
+ onchange="@Html.IdFor(model => model.StateProvinceId)_select_element(this)" asp-items="Model.AvailableStates" v-model="customerinfo.StateProvinceId"></select>
<span asp-validation-for="StateProvinceId"></span>
<span id="states-loading-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>
</fieldset>
diff --git a/src/Web/Grand.Web/Views/Account/Register.cshtml b/src/Web/Grand.Web/Views/Account/Register.cshtml
index 473ce7f9c..bfbc7e1bd 100644
--- a/src/Web/Grand.Web/Views/Account/Register.cshtml
+++ b/src/Web/Grand.Web/Views/Account/Register.cshtml
@@ -5,90 +5,43 @@
//title
pagebuilder.AddTitleParts(Loc["Title.Register"]);
}
-<script asp-location="Footer" asp-order="300">
- var register = new Vue({
- data: () => ({
- @{
- <text>
- FirstName: '@Html.Raw(Model.FirstName)',
- LastName: '@Html.Raw(Model.LastName)',
- Company: '@Html.Raw(Model.Company)',
- StreetAddress: '@Html.Raw(Model.StreetAddress)',
- StreetAddress2: '@Html.Raw(Model.StreetAddress2)',
- ZipPostalCode: '@Html.Raw(Model.ZipPostalCode)',
- City: '@Html.Raw(Model.City)',
- CountryId: '@Model.CountryId',
- StateProvinceId: '@Model.StateProvinceId',
- Phone: '@Html.Raw(Model.Phone)',
- Fax: '@Html.Raw(Model.Fax)',
- Username: '@Html.Raw(Model.Username)',
- Email: '@Html.Raw(Model.Email)',
- Password: '',
- ConfirmPassword: '',
- AcceptPrivacyPolicy: false
- </text>
- }
- })
- });
-</script>
@if (Model.CountryEnabled && Model.StateProvinceEnabled)
{
<script asp-location="Footer" asp-order="300">
-
- document.addEventListener("DOMContentLoaded", function () {
-
- var select_element = document.getElementById('@Html.IdFor(model => model.CountryId)');
- if (document.getElementById("@Html.IdFor(model => model.StateProvinceId)")) {
- var state_element = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- var ddlStates2 = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- state_element.onchange = function () {
- if (ddlStates2.options[0].selected) {
- ddlStates2.nextSibling.nextElementSibling.style.display = "block";
- } else {
- ddlStates2.nextSibling.nextElementSibling.style.display = "none";
- }
- }
+ function @Html.IdFor(model => model.CountryId)_select_element(e) {
+ var selectedItem = e.value;
+ var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
+ axios({
+ method: 'get',
+ url: "@(Url.RouteUrl("GetStatesByCountryId"))",
+ params: { "countryId": selectedItem, "addSelectStateItem": "true" },
+ }).then(function (response) {
+ ddlStates.innerHTML = '';
+ response.data.forEach(function (id, option) {
+ elChild = document.createElement('option');
+ elChild.setAttribute('value', id.id);
+ elChild.innerHTML = id.name;
+ ddlStates.appendChild(elChild);
+ });
+ register.StateProvinceId = response.data[0].id;
+ }).then(function () {
+ ddlStates.classList.remove('is-valid');
+ ddlStates.classList.add('is-invalid');
+ }).catch(function (error) {
+ alert(error);
+ });
}
-
- document.getElementById("@Html.IdFor(model => model.CountryId)").addEventListener('change', function () {
- var selectedItem = this.value;
+ function @Html.IdFor(model => model.StateProvinceId)_select_element(e) {
var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- var statesProgress = document.getElementById("states-loading-progress");
- statesProgress.style.display = "block";
- axios({
- method: 'GET',
- url: "@(Url.RouteUrl("GetStatesByCountryId"))",
- params: { "countryId": selectedItem, "addSelectStateItem": "true" },
- }).then(function (response) {
- ddlStates.innerHTML = '';
- response.data.forEach(function (id, option) {
- elChild = document.createElement('option');
- elChild.setAttribute('value', id.id);
- elChild.innerHTML = id.name;
- ddlStates.appendChild(elChild);
- })
- if (ddlStates.length > 1) {
- if (ddlStates.options[0].selected = true) {
- ddlStates.nextSibling.nextElementSibling.style.display = "block";
- if (ddlStates.nextSibling.nextSibling.nextElementSibling) {
- ddlStates.nextSibling.nextSibling.nextElementSibling.style.display = "none";
- }
- } else {
- ddlStates.nextSibling.nextElementSibling.style.display = "none";
- if (ddlStates.nextSibling.nextSibling.nextElementSibling) {
- ddlStates.nextSibling.nextSibling.nextElementSibling.style.display = "none";
- }
- }
- } else {
- ddlStates.nextSibling.nextElementSibling.style.display = "none";
- }
- statesProgress.style.display = "none";
- }).catch(function (error) {
- alert(error);
- });
- });
- });
-</script>
+ if (e.selectedIndex > 0) {
+ ddlStates.classList.remove('is-invalid');
+ ddlStates.classList.add('is-valid');
+ } else {
+ ddlStates.classList.remove('is-valid');
+ ddlStates.classList.add('is-invalid');
+ }
+ }
+ </script>
}
<script asp-location="Footer">
@@ -391,8 +344,8 @@
<validation-provider tag="div" rules="required" name="CountryId" v-slot="{ errors }">
<label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>
<span class="required">*</span>
- <select asp-for="CountryId" v-model="register.CountryId" class="custom-select form-control"
- asp-items="Model.AvailableCountries"></select>
+ <select asp-for="CountryId" asp-items="Model.AvailableCountries"
+ onchange="@Html.IdFor(model => model.CountryId)_select_element(this)" class="custom-select form-control" v-model="register.CountryId"></select>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="CountryId"></span>
</validation-provider>
@@ -412,8 +365,8 @@
<validation-provider tag="div" rules="required" name="StateProvinceId" v-slot="{ errors }">
<label asp-for="StateProvinceId" class="col-form-label">@Loc["Account.Fields.StateProvince"]:</label>
<span class="required">*</span>
- <select asp-for="StateProvinceId" v-model="register.StateProvinceId" class="custom-select form-control"
- asp-items="Model.AvailableStates"></select>
+ <select asp-for="StateProvinceId" data-val-required="@Loc["Address.Fields.StateProvince.Required"]" class="custom-select form-control"
+ onchange="@Html.IdFor(model => model.StateProvinceId)_select_element(this)" asp-items="Model.AvailableStates" v-model="register.StateProvinceId"></select>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="StateProvinceId"></span>
<span id="states-loading-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>
@@ -556,4 +509,30 @@
</div>
<input type="submit" id="register-button" class="btn btn-secondary register-next-step-button my-3" value="@Loc["Account.Register.Button"]" />
</form>
-</validation-observer>
\ No newline at end of file
+</validation-observer>
+<script asp-location="Footer" asp-order="300">
+ var register = new Vue({
+ data: () => ({
+ @{
+ <text>
+ FirstName: '@Html.Raw(Model.FirstName)',
+ LastName: '@Html.Raw(Model.LastName)',
+ Company: '@Html.Raw(Model.Company)',
+ StreetAddress: '@Html.Raw(Model.StreetAddress)',
+ StreetAddress2: '@Html.Raw(Model.StreetAddress2)',
+ ZipPostalCode: '@Html.Raw(Model.ZipPostalCode)',
+ City: '@Html.Raw(Model.City)',
+ CountryId: '@Model.CountryId',
+ StateProvinceId: '@Model.StateProvinceId',
+ Phone: '@Html.Raw(Model.Phone)',
+ Fax: '@Html.Raw(Model.Fax)',
+ Username: '@Html.Raw(Model.Username)',
+ Email: '@Html.Raw(Model.Email)',
+ Password: '',
+ ConfirmPassword: '',
+ AcceptPrivacyPolicy: false
+ </text>
+ }
+ })
+ });
+</script>
\ No newline at end of file
diff --git a/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateAddress.cshtml b/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateAddress.cshtml
index c61a4c1e4..93376a765 100644
--- a/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateAddress.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateAddress.cshtml
@@ -4,46 +4,41 @@
}
@if (Model.CountryEnabled && Model.StateProvinceEnabled)
{
-<script asp-location="Footer" asp-order="300">
- function @Html.IdFor(model => model.CountryId)_select_element(e) {
- var selectedItem = e.value;
- var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- axios({
- method: 'get',
- url: "@(Url.RouteUrl("GetStatesByCountryId"))",
- params: { "countryId": selectedItem, "addSelectStateItem": "true" },
- }).then(function (response) {
- ddlStates.innerHTML = '';
- response.data.forEach(function (id, option) {
- elChild = document.createElement('option');
- elChild.setAttribute('value', id.id);
- elChild.innerHTML = id.name;
- ddlStates.appendChild(elChild);
- });
- createorupdateaddress.StateProvinceId = response.data[0].id;
- }).then(function () {
- if (ddlStates.length > 1) {
+ <script asp-location="Footer" asp-order="300">
+ function @Html.IdFor(model => model.CountryId)_select_element(e) {
+ var selectedItem = e.value;
+ var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
+ axios({
+ method: 'get',
+ url: "@(Url.RouteUrl("GetStatesByCountryId"))",
+ params: { "countryId": selectedItem, "addSelectStateItem": "true" },
+ }).then(function (response) {
+ ddlStates.innerHTML = '';
+ response.data.forEach(function (id, option) {
+ elChild = document.createElement('option');
+ elChild.setAttribute('value', id.id);
+ elChild.innerHTML = id.name;
+ ddlStates.appendChild(elChild);
+ });
+ createorupdateaddress.StateProvinceId = response.data[0].id;
+ }).then(function () {
ddlStates.classList.remove('is-valid');
ddlStates.classList.add('is-invalid');
- } else {
- ddlStates.classList.remove('is-invalid');
- ddlStates.classList.add('is-valid');
- }
- }).catch(function (error) {
- alert(error);
- });
- }
- function @Html.IdFor(model => model.StateProvinceId)_select_element(e) {
- var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- if (e.selectedIndex > 0) {
- ddlStates.classList.remove('is-invalid');
- ddlStates.classList.add('is-valid');
- } else {
- ddlStates.classList.remove('is-valid');
- ddlStates.classList.add('is-invalid');
+ }).catch(function (error) {
+ alert(error);
+ });
+ }
+ function @Html.IdFor(model => model.StateProvinceId)_select_element(e) {
+ var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
+ if (e.selectedIndex > 0) {
+ ddlStates.classList.remove('is-invalid');
+ ddlStates.classList.add('is-valid');
+ } else {
+ ddlStates.classList.remove('is-valid');
+ ddlStates.classList.add('is-invalid');
+ }
}
- }
-</script>
+ </script>
}
<input asp-for="Id" type="hidden" />
<div class="edit-address row">
diff --git a/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateVendorAddress.cshtml b/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateVendorAddress.cshtml
index 15590d147..98c81afbd 100644
--- a/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateVendorAddress.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_CreateOrUpdateVendorAddress.cshtml
@@ -5,68 +5,39 @@
@if (Model.CountryEnabled && Model.StateProvinceEnabled)
{
<script asp-location="Footer" asp-order="300">
- document.addEventListener("DOMContentLoaded", function () {
- var select_element = document.getElementById('@Html.IdFor(model => model.CountryId)');
- if (document.getElementById("@Html.IdFor(model => model.StateProvinceId)")) {
- var state_element = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- var ddlStates2 = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- state_element.onchange = function () {
- if (ddlStates2.options[0].selected) {
- ddlStates2.nextSibling.nextElementSibling.style.display = "block";
- } else {
- ddlStates2.nextSibling.nextElementSibling.style.display = "none";
- }
- }
- }
-
- select_element.onchange = function () {
- var selectedItem = this.value;
- var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
- var statesProgress = document.getElementById("states-loading-progress");
- statesProgress.style.display = "block";
- axios({
- method: 'get',
- url: "@(Url.RouteUrl("GetStatesByCountryId"))",
- params: { "countryId": selectedItem, "addSelectStateItem": "true" },
- }).then(function (response) {
- ddlStates.innerHTML = '';
- response.data.forEach(function (id, option) {
- elChild = document.createElement('option');
- elChild.setAttribute('value', id.id);
- elChild.innerHTML = id.name;
- ddlStates.appendChild(elChild);
- });
- createorupdatevendoraddress.StateProvinceId = response.data[0].id;
- if (ddlStates.length > 1) {
- if (ddlStates.options[0].selected = true) {
- ddlStates.nextSibling.nextElementSibling.style.display = "block";
- if (ddlStates.nextSibling.nextSibling.nextElementSibling) {
- ddlStates.nextSibling.nextSibling.nextElementSibling.style.display = "none";
- }
- } else {
- ddlStates.nextSibling.nextElementSibling.style.display = "none";
- if (ddlStates.nextSibling.nextSibling.nextElementSibling) {
- ddlStates.nextSibling.nextSibling.nextElementSibling.style.display = "none";
- }
- }
- } else {
- ddlStates.nextSibling.nextElementSibling.style.display = "none";
- }
- statesProgress.style.display = "none";
- }).catch(function (error) {
- alert(error);
- statesProgress.style.display = "none";
- }).then(function () {
- if (ddlStates.length > 1) {
+ function @Html.IdFor(model => model.CountryId)_select_element(e) {
+ var selectedItem = e.value;
+ var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
+ axios({
+ method: 'get',
+ url: "@(Url.RouteUrl("GetStatesByCountryId"))",
+ params: { "countryId": selectedItem, "addSelectStateItem": "true" },
+ }).then(function (response) {
+ ddlStates.innerHTML = '';
+ response.data.forEach(function (id, option) {
+ elChild = document.createElement('option');
+ elChild.setAttribute('value', id.id);
+ elChild.innerHTML = id.name;
+ ddlStates.appendChild(elChild);
+ });
+ createorupdatevendoraddress.StateProvinceId = response.data[0].id;
+ }).then(function () {
ddlStates.classList.remove('is-valid');
ddlStates.classList.add('is-invalid');
- } else {
- ddlStates.classList.remove('is-invalid');
- ddlStates.classList.add('is-valid');
- }
- })
+ }).catch(function (error) {
+ alert(error);
+ });
+ }
+ function @Html.IdFor(model => model.StateProvinceId)_select_element(e) {
+ var ddlStates = document.getElementById("@Html.IdFor(model => model.StateProvinceId)");
+ if (e.selectedIndex > 0) {
+ ddlStates.classList.remove('is-invalid');
+ ddlStates.classList.add('is-valid');
+ } else {
+ ddlStates.classList.remove('is-valid');
+ ddlStates.classList.add('is-invalid');
+ }
}
- });
</script>
}
<input asp-for="Id" type="hidden" />
@@ -113,7 +84,7 @@
<label asp-for="StateProvinceId" class="col-form-label">@Loc["Address.Fields.StateProvince"]:</label>
<span class="required">*</span>
<select asp-for="StateProvinceId" data-val-required="@Loc["Address.Fields.StateProvince.Required"]" class="custom-select form-control"
- onchange="@Html.IdFor(model => model.StateProvinceId)_select_element(this)" asp-items="Model.AvailableStates" v-model="createorupdatevendoraddress.StateProvinceId"></select>
+ onchange="@Html.IdFor(model => model.StateProvinceId)_select_element(this)" asp-items="Model.AvailableStates" v-model="createorupdatevendoraddress.StateProvinceId"></select>
<span class="field-validation-error">{{ errors[0] }}</span>
<span asp-validation-for="StateProvinceId"></span>
<span id="states-loading-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>
diff --git a/src/Web/Grand.Web/Views/Vendor/Info.cshtml b/src/Web/Grand.Web/Views/Vendor/Info.cshtml
index b4aedf7a7..1a6618039 100644
--- a/src/Web/Grand.Web/Views/Vendor/Info.cshtml
+++ b/src/Web/Grand.Web/Views/Vendor/Info.cshtml
@@ -27,7 +27,7 @@
</div>
<div class="form-group">
<validation-provider tag="div" rules="required|email" name="Email" v-slot="{ errors }">
- <label asp-for="Email" class="col-form-label">@Loc["Account.VendorInfo.NaEmailme"]:</label>
+ <label asp-for="Email" class="col-form-label">@Loc["Account.VendorInfo.Email"]:</label>
<span class="required">*</span>
<input asp-for="Email" v-model="vendorinfo.Email" placeholder="@Loc["Account.VendorInfo.Email.Hint"]" class="form-control" />
<span class="field-validation-error">{{ errors[0] }}</span>