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-plugins.git The following commit(s) were added to refs/heads/release18.12 by this push: new 1205ac5 Improved: display/selection of unit of measure is broken/plugins (OFBIZ-11993) 1205ac5 is described below commit 1205ac591c54d03301e2fcc7ea188d62ae0035cd Author: Jacques Le Roux <[hidden email]> AuthorDate: Mon Sep 14 07:57:16 2020 +0200 Improved: display/selection of unit of measure is broken/plugins (OFBIZ-11993) Better code Thanks: Alex Conflicts handled by hand ProductDetail.ftl --- ecommerce/template/catalog/ProductDetail.ftl | 114 +++++++------------------- ecommerce/template/catalog/ProductSummary.ftl | 3 +- 2 files changed, 33 insertions(+), 84 deletions(-) diff --git a/ecommerce/template/catalog/ProductDetail.ftl b/ecommerce/template/catalog/ProductDetail.ftl index dafa686..19c791c 100644 --- a/ecommerce/template/catalog/ProductDetail.ftl +++ b/ecommerce/template/catalog/ProductDetail.ftl @@ -27,50 +27,23 @@ ${virtualVariantJavaScript!} <script type="application/javascript"> //<![CDATA[ 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 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); - } + 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; } - 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??> @@ -168,29 +141,33 @@ ${virtualVariantJavaScript!} } 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; // using the selected index locate the sku var sku = document.forms["addform"].elements[name].options[indexSelected].value; - + // display alternative packaging dropdown 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)); } } @@ -216,7 +193,7 @@ ${virtualVariantJavaScript!} return (y[0]+"-"+y[1]+"-"+y[2]); } - function showAlert(msg){ + function showAlert(msg) { showErrorAlert("${uiLabelMap.CommonErrorMessage2}", msg); } @@ -276,37 +253,6 @@ ${virtualVariantJavaScript!} } </#if> - function displayProductVirtualVariantId(variantId) { - if(variantId){ - document.addform.product_id.value = variantId; - }else{ - 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); - } - - var priceElem = document.getElementById('variant_price_display'); - var price = getVariantPrice(variantId); - var priceTxt = null; - if(price){ - priceTxt = document.createTextNode(price); - }else{ - priceTxt = document.createTextNode(''); - } - if(priceElem.hasChildNodes()) { - priceElem.replaceChild(priceTxt, priceElem.firstChild); - } else { - priceElem.appendChild(priceTxt); - } - } -//]]> $(function(){ $('a[id^=productTag_]').click(function(){ var id = $(this).attr('id'); @@ -722,9 +668,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"/> @@ -743,7 +690,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> diff --git a/ecommerce/template/catalog/ProductSummary.ftl b/ecommerce/template/catalog/ProductSummary.ftl index 8473aeb..d5cea7f 100644 --- a/ecommerce/template/catalog/ProductSummary.ftl +++ b/ecommerce/template/catalog/ProductSummary.ftl @@ -203,7 +203,8 @@ ${variantInfoJavaScript!} <option value="${mainProduct.productId}">${mainProduct.uomDesc} : ${mainProduct.piecesIncluded}</option> </#list> </select> - <div class="variant-price" style="display: none;"> + <div class="variant-price" style="display: inline-block;"> + <input type="hidden" name="product_id_bak" value="${product.productId}"/> <strong><span class="product_id_display"> </span></strong> <strong><span class="variant_price_display"> </span></strong> </div> |
Free forum by Nabble | Edit this page |