diff --git a/admin-dev/themes/default/template/products/form.tpl b/admin-dev/themes/default/template/products/form.tpl
index 31c9e5a5e..8b7717cd1 100644
--- a/admin-dev/themes/default/template/products/form.tpl
+++ b/admin-dev/themes/default/template/products/form.tpl
@@ -107,11 +107,14 @@
$('#is_virtual').val(0);
$("#virtual_good_attributes").hide();
- var val = $(this).val();
+ var product_type = $(this).val();
- if (val == 1)
+ // until a product is added in the pack
+ // if product is PTYPE_PACK, save buttons will be disabled
+ if (product_type == {Product::PTYPE_PACK})
{
- $('li.tab-row a[id*="Pack"]').show();
+ //when you change the type of the product, directly go to the pack tab
+ $('li.tab-row a[id*="Pack"]').show().click();
$('#ppack').val(1).attr('checked', true).attr('disabled', 'disabled');
$('#ppackdiv').show();
// If the pack tab has not finished loaded the changes will be made when the loading event is triggered
@@ -127,9 +130,13 @@
$('#condition').removeAttr('disabled');
$('#condition option[value=new]').removeAttr('selected');
$('.stockForVirtualProduct').show();
+ // if pack is enabled, if you choose pack, automatically switch to pack page
+ if ($("#link-Pack:visible").length)
+ handleSaveForPack();
}
- else if (val == 2)
+ else if (product_type == {Product::PTYPE_VIRTUAL})
{
+ enableSave();
$('li.tab-row a[id*="VirtualProduct"]').show();
$('#is_virtual_good').attr('checked', true);
$('#virtual_good').show();
@@ -152,6 +159,8 @@
}
else
{
+ // 3rd case : product_type is PTYPE_SIMPLE (0)
+ enableSave();
$('li.tab-row a[id*="Shipping"]').show();
$('#condition').removeAttr('disabled');
$('#condition option[value=new]').removeAttr('selected');
@@ -195,21 +204,22 @@
if (btn_name == "Combinations")
{
$('#desc-product-new').hide();
- $('#desc-product-save-and-stay').hide();
- $('#desc-product-save').hide();
+ disableSave();
$('#desc-product-newCombination').show();
populate_attrs();
}
else if (btn_name == "Attachments")
{
- $('#desc-product-save-and-stay').hide();
- $('#desc-product-save').hide();
+ disableSave();
}
else
{
$('#desc-product-newCombination').hide();
- $('#desc-product-save-and-stay').show();
- $('#desc-product-save').show();
+ // if pack is enabled, save button are visible only if pack is valid
+ if ($("#link-Pack:visible").length)
+ handleSaveForPack();
+ else
+ enableSave();
}
});
diff --git a/admin-dev/themes/default/template/products/pack.tpl b/admin-dev/themes/default/template/products/pack.tpl
index 90ad40349..61b9433bd 100644
--- a/admin-dev/themes/default/template/products/pack.tpl
+++ b/admin-dev/themes/default/template/products/pack.tpl
@@ -92,9 +92,10 @@
divContent += '
';
// QTYxID-QTYxID
+ // @todo : it should be better to create input for each items and each qty
+ // instead of only one separated by x, - and ¤
var line = curPackItemQty+ 'x' +curPackItemId;
-
$('#inputPackItems').val($('#inputPackItems').val() + line + '-');
$('#divPackItems').html(divContent);
$('#namePackItems').val($('#namePackItems').val() + lineDisplay + '¤');
@@ -108,6 +109,8 @@
excludeIds : getSelectedIds()
}
});
+ // show / hide save buttons
+ handleSaveForPack();
}
function delPackItem(id)
@@ -145,6 +148,9 @@
excludeIds : getSelectedIds()
}
});
+
+ // if no item left in the pack, disable save buttons
+ handleSaveForPack();
}
function getSelectedIds()
@@ -155,6 +161,19 @@
return ids;
}
+ function handleSaveForPack()
+ {
+ // if no item left in the pack, disable save buttons
+ $("#disablePackMessage").remove();
+ if ($("#inputPackItems").val() == "")
+ {
+ disableSave();
+ $(".leadin").append('