You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2020/09/14 06:16:25 UTC
[ofbiz-plugins] branch trunk updated: Improved: display/selection
of unit of measure is broken/plugins (OFBIZ-11993)
This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push:
new b1c98ee Improved: display/selection of unit of measure is broken/plugins (OFBIZ-11993)
b1c98ee is described below
commit b1c98eee47736b89fd4f54ce45ec012b2a972ccd
Author: Jacques Le Roux <ja...@les7arts.com>
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
---
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 3a5b5da..277c732 100644
--- a/ecommerce/template/catalog/ProductDetail.ftl
+++ b/ecommerce/template/catalog/ProductDetail.ftl
@@ -26,50 +26,23 @@ ${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 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??>
@@ -167,29 +140,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", "<@o...@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));
}
}
@@ -215,7 +192,7 @@ ${virtualVariantJavaScript!}
return (y[0]+"-"+y[1]+"-"+y[2]);
}
- function showAlert(msg){
+ function showAlert(msg) {
showErrorAlert("${uiLabelMap.CommonErrorMessage2}", msg);
}
@@ -275,37 +252,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');
@@ -721,9 +667,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"/>
@@ -742,7 +689,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 c377a58..e891ff1 100644
--- a/ecommerce/template/catalog/ProductSummary.ftl
+++ b/ecommerce/template/catalog/ProductSummary.ftl
@@ -205,7 +205,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>