This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch release18.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/release18.12 by this push: new 207d8f8 Fixed: display/selection of unit of measure is broken (OFBIZ-11955) 207d8f8 is described below commit 207d8f8ac080996ec11882fd6cb7f38a56dcc7d6 Author: Jacques Le Roux <[hidden email]> AuthorDate: Fri Sep 11 10:43:13 2020 +0200 Fixed: display/selection of unit of measure is broken (OFBIZ-11955) Improve code for UOM dropdown of products like WG-9943 Thanks: Alex --- .../entry/catalog/InlineProductDetail.groovy | 2 +- .../entry/catalog/ProductDetail.groovy | 3 +- .../entry/catalog/ProductSummary.groovy | 3 +- .../order/template/entry/catalog/ProductDetail.ftl | 102 +++++++-------------- .../template/entry/catalog/ProductSummary.ftl | 5 +- .../template/entry/catalog/ProductVariantJS.ftl | 38 ++++++-- 6 files changed, 72 insertions(+), 81 deletions(-) diff --git a/applications/order/groovyScripts/entry/catalog/InlineProductDetail.groovy b/applications/order/groovyScripts/entry/catalog/InlineProductDetail.groovy index 46b2865..9a232c2 100644 --- a/applications/order/groovyScripts/entry/catalog/InlineProductDetail.groovy +++ b/applications/order/groovyScripts/entry/catalog/InlineProductDetail.groovy @@ -103,7 +103,7 @@ if (inlineProduct) { featureOrder = [] variantInfoJS = new StringBuffer() - variantInfoJS.append("<script language=\"JavaScript\" type=\"text/javascript\">\n \$(document).ready(function(\$) {\n") + variantInfoJS.append("<script language=\"JavaScript\" type=\"text/javascript\">\n jQuery(document).ready(function(jQuery) {\n") // make the productContentWrapper productContentWrapper = new ProductContentWrapper(inlineProduct, request) diff --git a/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy b/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy index 0784be3..2d4a2f2 100644 --- a/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy +++ b/applications/order/groovyScripts/entry/catalog/ProductDetail.groovy @@ -107,7 +107,7 @@ if (product) { featureOrder = [] variantInfoJS = new StringBuffer() - variantInfoJS.append("<script language=\"JavaScript\" type=\"text/javascript\">\n \$(document).ready(function(\$) {\n") + variantInfoJS.append("<script language=\"JavaScript\" type=\"text/javascript\">\n jQuery(document).ready(function(jQuery) {\n") // set this as a last viewed LAST_VIEWED_TO_KEEP = 10 // modify this to change the number of last viewed to keep @@ -561,6 +561,7 @@ if (product) { } } } + variantInfoJS.append(" variantPrices['" + product.productId + "'] = '" + UtilFormatOut.formatCurrency(priceMap.basePrice, currencyUomId, locale, 10) + "';\n") variantInfoJS.append(" });\n</script>\n") context.variantInfoJavaScript = variantInfoJS diff --git a/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy b/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy index 9e07931..43cf65a 100644 --- a/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy +++ b/applications/order/groovyScripts/entry/catalog/ProductSummary.groovy @@ -97,6 +97,7 @@ if (product) { categoryId = null reviews = null if (product) { + numberFormat = NumberFormat.getCurrencyInstance(locale) categoryId = parameters.category_id ?: request.getAttribute("productCategoryId") variantInfoJS = new StringBuffer() @@ -170,7 +171,6 @@ if (product) { } } variantPriceList = [] - numberFormat = NumberFormat.getCurrencyInstance(locale) if(virtualVariants){ amt = new StringBuffer() @@ -208,6 +208,7 @@ if (product) { context.virtualJavaScript = jsBuf } } + variantInfoJS.append(" variantPrices['" + product.productId + "'] = '" + numberFormat.format(priceMap.basePrice) + "';\n") variantInfoJS.append(" });\n</script>\n") context.variantInfoJavaScript = variantInfoJS diff --git a/applications/order/template/entry/catalog/ProductDetail.ftl b/applications/order/template/entry/catalog/ProductDetail.ftl index f02194c..0471364 100644 --- a/applications/order/template/entry/catalog/ProductDetail.ftl +++ b/applications/order/template/entry/catalog/ProductDetail.ftl @@ -17,58 +17,32 @@ specific language governing permissions and limitations under the License. --> <#-- variable setup --> -<#assign price = priceMap!/> +<#assign price = priceMap! /> <#-- end variable setup --> <#-- virtual product javascript --> ${virtualJavaScript!} +${virtualVariantJavaScript!} <script type="application/javascript"> <!-- var detailImageUrl = null; - function setAddProductId(name) { - document.addform.add_product_id.value = name; - if (document.addform.quantity == null) return; - if (name == '' || name == 'NULL' || isVirtual(name) == true) { - document.addform.quantity.disabled = true; - var elem = document.getElementById('product_id_display'); - var txt = document.createTextNode(''); - if(elem.hasChildNodes()) { - elem.replaceChild(txt, elem.firstChild); - } else { - elem.appendChild(txt); - } - } else { - document.addform.quantity.disabled = false; - var elem = document.getElementById('product_id_display'); - var txt = document.createTextNode(name); - if(elem.hasChildNodes()) { - elem.replaceChild(txt, elem.firstChild); - } else { - elem.appendChild(txt); - } + function setAddProductId2(sku, with_bak) { + document.addform.add_product_id.value = sku; + var disable = (sku == '' || sku == 'NULL' || isVirtual(sku) == true); + if (document.addform.quantity != null) { + document.addform.quantity.disabled = disable; } - } - function setVariantPrice(sku) { - if (sku == '' || sku == 'NULL' || isVirtual(sku) == true) { - var elem = document.getElementById('variant_price_display'); - var txt = document.createTextNode(''); - if(elem.hasChildNodes()) { - elem.replaceChild(txt, elem.firstChild); - } else { - elem.appendChild(txt); - } - } - else { - var elem = document.getElementById('variant_price_display'); - var price = getVariantPrice(sku); - var txt = document.createTextNode(price); - if(elem.hasChildNodes()) { - elem.replaceChild(txt, elem.firstChild); - } else { - elem.appendChild(txt); - } + var txt = disable ? '' : sku; + $('#product_id_display').text(txt); + if (with_bak) { + document.addform.product_id_bak.value = txt; } } + function setVariantPrice2(sku) { + var disable = (sku == '' || sku == 'NULL' || isVirtual(sku) == true); + var txt = disable ? '' : getVariantPrice2(sku); + $('#variant_price_display').text(txt || ''); + } function isVirtual(product) { var isVirtual = false; <#if virtualJavaScript??> @@ -159,11 +133,15 @@ ${virtualJavaScript!} } else { var Variable1 = eval("list" + OPT[(currentFeatureIndex+1)] + selectedValue + "()"); } + + // reset uom select + $('#product_uom').text(''); + // set the product ID to NULL to trigger the alerts - setAddProductId('NULL'); + setAddProductId2('NULL'); // set the variant price to NULL - setVariantPrice('NULL'); + setVariantPrice2('NULL'); } else { // this is the final selection -- locate the selected index of the last selection var indexSelected = document.forms["addform"].elements[name].selectedIndex; @@ -175,13 +153,13 @@ ${virtualJavaScript!} ajaxUpdateArea("product_uom", "<@ofbizUrl>ProductUomDropDownOnly</@ofbizUrl>", "productId=" + sku); // set the product ID - setAddProductId(sku); + setAddProductId2(sku, true); // set the variant price - setVariantPrice(sku); + setVariantPrice2(sku); // check for amount box - toggleAmt(checkAmtReq(sku)); + toggleAmt(checkAmtReq2(sku)); } } @@ -208,7 +186,7 @@ ${virtualJavaScript!} } function showAlert(msg) { - showErrorAlert("${uiLabelMap.CommonErrorMessage2}",msg); + showErrorAlert("${uiLabelMap.CommonErrorMessage2}", msg); } function additemSubmit(){ @@ -266,18 +244,6 @@ ${virtualJavaScript!} block2.style.display = "none"; } </#if> - - function displayProductVirtualVariantId(variantId) { - document.addform.product_id.value = variantId; - var elem = document.getElementById('product_id_display'); - var txt = document.createTextNode(variantId); - if(elem.hasChildNodes()) { - elem.replaceChild(txt, elem.firstChild); - } else { - elem.appendChild(txt); - } - setVariantPrice(variantId); - } //--> </script> @@ -323,9 +289,9 @@ ${variantInfoJavaScript!} <#if sizeProductFeatureAndAppls?has_content> <div> <#if (sizeProductFeatureAndAppls?size == 1)> - Size: + ${uiLabelMap.OrderSizeAvailableSingle}: <#else> - Sizes Available: + ${uiLabelMap.OrderSizeAvailableMultiple}: </#if> <#list sizeProductFeatureAndAppls as sizeProductFeatureAndAppl> ${sizeProductFeatureAndAppl.description?default(sizeProductFeatureAndAppl.abbrev?default(sizeProductFeatureAndAppl.productFeatureId))}<#if sizeProductFeatureAndAppl_has_next>,</#if> @@ -484,9 +450,10 @@ ${variantInfoJavaScript!} </div> </#list> <span id="product_uom"></span><br/> - <div class="variant-price" style="display: none;"> - <strong><span class="product_id_display"> </span></strong> - <strong><span class="variant_price_display"> </span></strong> + <input type="hidden" name="product_id_bak" value=""/> + <div class="variant-price" style="display: inline-block;"> + <strong><span id="product_id_display" class="product_id_display"> </span></strong> + <strong><span id="variant_price_display" class="variant_price_display"> </span></strong> </div> <input type="hidden" name="product_id" value="${product.productId}"/> <input type="hidden" name="add_product_id" value="NULL"/> @@ -507,7 +474,8 @@ ${variantInfoJavaScript!} <option value="${mainProduct.productId}">${mainProduct.uomDesc} : ${mainProduct.piecesIncluded}</option> </#list> </select><br/> - <div class="variant-price" style="display: none;"> + <input type="hidden" name="product_id_bak" value="${product.productId}"/> + <div class="variant-price" style="display: inline-block;"> <strong><span class="product_id_display"> </span></strong> <strong><span class="variant_price_display"> </span></strong> </div> @@ -554,7 +522,7 @@ ${variantInfoJavaScript!} <td nowrap="nowrap" align="right">Number of persons</td> <td><input type="text" size="4" name="reservPersons" value="2"/></td> </#if> - <td nowrap="nowrap" align="right">Quantity</td> + <td nowrap="nowrap" align="right">${uiLabelMap.CommonQuantity}</td> <td><input type="text" size="5" name="quantity" value="1"/></td> </tr> </table> diff --git a/applications/order/template/entry/catalog/ProductSummary.ftl b/applications/order/template/entry/catalog/ProductSummary.ftl index 0fe9ac0..0e37a9d 100644 --- a/applications/order/template/entry/catalog/ProductSummary.ftl +++ b/applications/order/template/entry/catalog/ProductSummary.ftl @@ -96,6 +96,7 @@ ${variantInfoJavaScript!} </table> </div> <script type="application/javascript"> + /* jQuery(document).ready(function(jQuery) { jQuery("#${productInfoLinkId}").attr('title', jQuery("#${productDetailId}").remove().html()); jQuery("#${productInfoLinkId}").tooltip({ @@ -106,6 +107,7 @@ ${variantInfoJavaScript!} track: true }); }); + */ </script> <div class="productbuy"> <#-- check to see if introductionDate hasn't passed yet --> @@ -143,7 +145,8 @@ ${variantInfoJavaScript!} <option value="${mainProduct.productId}">${mainProduct.uomDesc} : ${mainProduct.piecesIncluded}</option> </#list> </select> - <div class="variant-price" style="display: none;"> + <input type="hidden" name="product_id_bak" value="${product.productId}"/> + <div class="variant-price" style="display: inline-block;"> <strong><span class="product_id_display"> </span></strong> <strong><span class="variant_price_display"> </span></strong> </div> diff --git a/applications/order/template/entry/catalog/ProductVariantJS.ftl b/applications/order/template/entry/catalog/ProductVariantJS.ftl index 0912299..d2cfb06 100644 --- a/applications/order/template/entry/catalog/ProductVariantJS.ftl +++ b/applications/order/template/entry/catalog/ProductVariantJS.ftl @@ -32,20 +32,38 @@ if (typeof(checkAmtReq2) == 'undefined') { function variantUomSelection (select) { var $select = $(select); var form = $select.closest('form'); - var price_div = $('.variant-price', form); - var variantId = $select.val() || ''; + var variantId = $select.val(); $("[name='product_id']", form).val(variantId); - $('.product_id_display', price_div).text(variantId); + if (!variantId) { + variantId = $("[name='product_id_bak']", form).val() || ''; + } + $('.product_id_display', form).text(variantId); var price = getVariantPrice2(variantId); - if (price) { - $('.variant_price_display', price_div).text(price); - price_div.css('display', 'inline-block'); - } - else { - price_div.hide(); - } + $('.variant_price_display', form).text(price || ''); +// var price_div = $('.variant-price', form); +// if (price) { +// price_div.css('display', 'inline-block'); +// } +// else { +// price_div.hide(); +// } } + jQuery(document).ready(function(jQuery) { + jQuery('.popup_link').each( + function(index) { + var $this = jQuery(this); + var popup = $('.popup', $this.closest('.productsummary')); + $this.attr('title', popup.remove().html()); + $this.tooltip({ + content: function(){ + return this.getAttribute("title"); + }, + tooltipClass: "popup", + track: true + }); + }); + }); } </script> |
Free forum by Nabble | Edit this page |