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
QuickView - Fix conditional attributes #114
KrzysztofPajak8f01669d661c
diff --git a/src/Web/Grand.Web/Controllers/ProductController.cs b/src/Web/Grand.Web/Controllers/ProductController.csindex 9a0dae5b2..cffe2f688 100644--- a/src/Web/Grand.Web/Controllers/ProductController.cs+++ b/src/Web/Grand.Web/Controllers/ProductController.cs@@ -186,7 +186,7 @@ namespace Grand.Web.Controllers//handle product attribute selection event. this way we return new price, overridden gtin/sku/mpn//currently we use this method on the product details pages[HttpPost]- public virtual async Task<IActionResult> ProductDetails_AttributeChange(string productId, bool validateAttributeConditions, bool loadPicture, IFormCollection form)+ public virtual async Task<IActionResult> ProductDetails_AttributeChange(string productId, bool loadPicture, IFormCollection form){var product = await _productService.GetProductById(productId);if (product == null)@@ -199,7 +199,6 @@ namespace Grand.Web.ControllersForm = form,LoadPicture = loadPicture,Product = product,- ValidateAttributeConditions = validateAttributeConditions});return Json(newdiff --git a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.csindex 5929eee81..58395276e 100644--- a/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs+++ b/src/Web/Grand.Web/Features/Handlers/Products/GetProductDetailsAttributeChangeHandler.cs@@ -148,7 +148,7 @@ namespace Grand.Web.Features.Handlers.Products}//conditional attributes- if (request.ValidateAttributeConditions)+ if (request.Product.ProductAttributeMappings.Where(x=>x.ConditionAttribute.Any()).Any()){var attributes = request.Product.ProductAttributeMappings;foreach (var attribute in attributes)diff --git a/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsAttributeChange.cs b/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsAttributeChange.csindex 08ee4ca93..c02daec2e 100644--- a/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsAttributeChange.cs+++ b/src/Web/Grand.Web/Features/Models/Products/GetProductDetailsAttributeChange.cs@@ -14,7 +14,6 @@ namespace Grand.Web.Features.Models.Productspublic Currency Currency { get; set; }public Store Store { get; set; }public Product Product { get; set; }- public bool ValidateAttributeConditions { get; set; }public bool LoadPicture { get; set; }public IFormCollection Form { get; set; }}diff --git a/src/Web/Grand.Web/Views/Product/_ProductAttributes.cshtml b/src/Web/Grand.Web/Views/Product/_ProductAttributes.cshtmlindex 29d67bc4c..733145599 100644--- a/src/Web/Grand.Web/Views/Product/_ProductAttributes.cshtml+++ b/src/Web/Grand.Web/Views/Product/_ProductAttributes.cshtml@@ -4,7 +4,6 @@<div id="product-attributes"></div>@{//dynamic update support- var attributesHaveConditions = Model.Any(x => x.HasCondition);var attributesHaveAssociatedPictures = true;var attributeChangeScriptsBuilder = new StringBuilder();var productId = Model.First().ProductId;@@ -229,7 +228,7 @@var form = document.getElementById('product-details-form');var data = new FormData(form);axios({- url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = productId, validateAttributeConditions = attributesHaveConditions, loadPicture = attributesHaveAssociatedPictures }))',+ url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = productId, loadPicture = attributesHaveAssociatedPictures }))',data: data,method: 'post',params: { product: '@productId' },diff --git a/src/Web/Grand.Web/Views/Product/_ProductAttributesBundle.cshtml b/src/Web/Grand.Web/Views/Product/_ProductAttributesBundle.cshtmlindex 49787181c..9bc970828 100644--- a/src/Web/Grand.Web/Views/Product/_ProductAttributesBundle.cshtml+++ b/src/Web/Grand.Web/Views/Product/_ProductAttributesBundle.cshtml@@ -2,7 +2,6 @@@using System.Text;@{//dynamic update support- var attributesHaveConditions = Model.Any(x => x.HasCondition);var attributesHaveAssociatedPictures = true;var attributeChangeScriptsBuilder = new StringBuilder();var bundleProductId = ViewData["BundleProductId"]?.ToString();@@ -50,7 +49,7 @@var form = document.getElementById('product-details-form');var data = new FormData(form);axios({- url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = bundleProductId, validateAttributeConditions = attributesHaveConditions, loadPicture = attributesHaveAssociatedPictures }))',+ url: '@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = bundleProductId, loadPicture = attributesHaveAssociatedPictures }))',data: data,method: 'post',params: { product: '@bundleProductId' },diff --git a/src/Web/Grand.Web/Views/Product/_ReservationInfo.cshtml b/src/Web/Grand.Web/Views/Product/_ReservationInfo.cshtmlindex 101a8a1b3..db211a2bb 100644--- a/src/Web/Grand.Web/Views/Product/_ReservationInfo.cshtml+++ b/src/Web/Grand.Web/Views/Product/_ReservationInfo.cshtml@@ -43,6 +43,6 @@document.addEventListener("DOMContentLoaded", function () {Reservation.init("@Model.StartDate.ToString("d", CultureInfo.CreateSpecificCulture("en-US"))", "@Model.StartDate.Year", "@Model.StartDate.Month", "@Loc["Products.Noavailablereservations"]","@(Url.Action("GetDatesForMonth", "Product"))", "@Model.Id",- "@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = Model.Id, validateAttributeConditions = false }))");+ "@Html.Raw(Url.Action("productdetails_attributechange", "product", new { productId = Model.Id }))");});</script>\ No newline at end of filediff --git a/src/Web/Grand.Web/Views/Shared/_AttributesQV.cshtml b/src/Web/Grand.Web/Views/Shared/_AttributesQV.cshtmlindex 32e2d78c1..d5f003ee7 100644--- a/src/Web/Grand.Web/Views/Shared/_AttributesQV.cshtml+++ b/src/Web/Grand.Web/Views/Shared/_AttributesQV.cshtml@@ -13,11 +13,11 @@<td :id="'product_attribute_input_' + attribute.Id"><template v-if="attribute.AttributeControlType==4"><label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>- <input :name="'product_attribute_' + attribute.Id" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="vm.attrchange(attribute.ProductId, attribute.HasCondition, true)" />+ <input :name="'product_attribute_' + attribute.Id" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="vm.attrchange(attribute.ProductId, true)" /></template><template v-if="attribute.AttributeControlType==1"><label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>- <select :id="'product_attribute_' + attribute.Id" class="form-control custom-select" :name="'product_attribute_' + attribute.Id" @@change="vm.attrchange(attribute.ProductId, attribute.HasCondition, true)">+ <select :id="'product_attribute_' + attribute.Id" class="form-control custom-select" :name="'product_attribute_' + attribute.Id" @@change="vm.attrchange(attribute.ProductId, true)"><template v-if="attribute.IsRequired==false"><option value="">---</option></template>@@ -44,7 +44,7 @@:value="attributeValue.Id":checked="attributeValue.IsPreSelected":data-disable="attributeValue.Id"- @@change="vm.attrchange(attribute.ProductId, attribute.HasCondition, true)" />+ @@change="vm.attrchange(attribute.ProductId, true)" /><span class="custom-control-label"></span><span class="custom-control-description" :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"><template v-if="attributeValue.PriceAdjustment==null">@@ -72,7 +72,7 @@:name="'product_attribute_' + attribute.Id":value="attributeValue.Id":checked="attributeValue.IsPreSelected"- @@change="vm.attrchange(attribute.ProductId, attribute.HasCondition, true)"+ @@change="vm.attrchange(attribute.ProductId, true)"disabled="disabled" /><input v-elseclass="custom-control-input"@@ -82,7 +82,7 @@:value="attributeValue.Id":checked="attributeValue.IsPreSelected":data-disable="attributeValue.Id"- @@change="vm.attrchange(attribute.ProductId, attribute.HasCondition, true)" />+ @@change="vm.attrchange(attribute.ProductId, true)" /><span class="custom-control-label"></span><span class="custom-control-description" :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"><template v-if="attributeValue.PriceAdjustment==null">@@ -124,7 +124,7 @@<ul class="option-list color-squares w-100 d-inline-flex flex-wrap px-0 mb-0" :id="'color-squares-' + attribute.Id"><li v-for="attributeValue in attribute.Values" class="mr-1 p-0"><label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :data-disable="attributeValue.Id" :checked="attributeValue.IsPreSelected" @@change="vm.attrchange(attribute.ProductId, attribute.HasCondition, true)" />+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :data-disable="attributeValue.Id" :checked="attributeValue.IsPreSelected" @@change="vm.attrchange(attribute.ProductId, true)" /><template v-if="attributeValue.PriceAdjustment==null"><span class="color-container" :title="attributeValue.Name"> <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span> </span></template>@@ -140,7 +140,7 @@<li v-for="attributeValue in attribute.Values" class="mr-1 p-0"><label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0"><template v-if="attributeValue.PriceAdjustment==null">- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, attribute.HasCondition, true)" />+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)" /><span :id="'imgSqr_' + attributeValue.Id" class="color-container"><span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span></span>@@ -149,7 +149,7 @@</b-tooltip></template><template v-else>- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, attribute.HasCondition, true)" />+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'product_attribute_' + attribute.Id" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)" /><span class="color-container"> <span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span> </span><b-tooltip :target="'imgSqr_' + attributeValue.Id" placement="bottom"><div class="image-square-tooltip">diff --git a/src/Web/Grand.Web/wwwroot/theme/script/app.js b/src/Web/Grand.Web/wwwroot/theme/script/app.jsindex d546f8dcf..1e0b5fd85 100644--- a/src/Web/Grand.Web/wwwroot/theme/script/app.js+++ b/src/Web/Grand.Web/wwwroot/theme/script/app.js@@ -158,7 +158,7 @@isMobile: function () {return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);},- attrchange: function (productId, hasCondition, loadPicture) {+ attrchange: function (productId, loadPicture) {var form = document.getElementById('product-details-form');var data = new FormData(form);var pId;@@ -170,7 +170,7 @@}axios({- url: '/product/productdetails_attributechange?productId=' + pId + '&validateAttributeConditions=' + hasCondition + '&loadPicture=' + loadPicture,+ url: '/product/productdetails_attributechange?productId=' + pId + '&loadPicture=' + loadPicture,data: data,method: 'post',params: { product: pId },@@ -268,7 +268,7 @@var fullDate = vm.PopupQuickViewVueModal.ReservationFullDate;var year = vm.PopupQuickViewVueModal.ReservationYear;var month = vm.PopupQuickViewVueModal.ReservationMonth;- Reservation.init(fullDate, year, month, "No available reservations", "/Product/GetDatesForMonth", productId, "/product/productdetails_attributechange?productId=" + productId + "&validateAttributeConditions=False");+ Reservation.init(fullDate, year, month, "No available reservations", "/Product/GetDatesForMonth", productId, "/product/productdetails_attributechange?productId=" + productId);}},getLinkedProductsQV: function (id) {@@ -321,11 +321,11 @@},QuickViewShown: function () {if (vm.PopupQuickViewVueModal.ProductAttributes.length > 0) {- vm.attrchange(vm.PopupQuickViewVueModal.Id, vm.PopupQuickViewVueModal.HasCondition, true)+ vm.attrchange(vm.PopupQuickViewVueModal.Id, true)} else {var bundleProducts = vm.PopupQuickViewVueModal.ProductBundleModels;if (bundleProducts.length > 0) {- vm.attrchange(vm.PopupQuickViewVueModal.Id, vm.PopupQuickViewVueModal.HasCondition, true)+ vm.attrchange(vm.PopupQuickViewVueModal.Id, true)}}if (vm.PopupQuickViewVueModal.ProductType == 20) {