// fix #PSTEST-701 - added some warnings when informations is missing in product edition / creation
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13475 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -79,11 +79,19 @@
|
||||
<script type="text/javascript">
|
||||
var token = '{$token}';
|
||||
var id_product = {if isset($product->id)}{$product->id}{else}0{/if};
|
||||
|
||||
var product_type_pack = {Product::PTYPE_PACK};
|
||||
var product_type_virtual = {Product::PTYPE_VIRTUAL};
|
||||
var product_type_simple = {Product::PTYPE_SIMPLE};
|
||||
|
||||
var toload = new Array();
|
||||
var empty_pack_msg = '{l s='Pack is empty. You need to add at least one product to the pack before you can save it.'}';
|
||||
var empty_name_msg = '{l s='Product name is empty. You need to enter a name at least for the default language before you can save it.'}';
|
||||
var empty_link_rewrite_msg = '{l s='Friendly URL is empty. You need to enter a friendly url at least for the default language before you can save it.'}';
|
||||
$('#product-tab-content-wait').show();
|
||||
var post_data = {$post_data};
|
||||
|
||||
var product_type;
|
||||
$(document).ready(function()
|
||||
{
|
||||
$('#product-tab-content-wait').show();
|
||||
@@ -102,8 +110,8 @@
|
||||
$('li.tab-row a[id*="VirtualProduct"]').hide();
|
||||
{/if}
|
||||
|
||||
$('input[name="type_product"]').click(function() {
|
||||
|
||||
$('input[name="type_product"]').click(function()
|
||||
{
|
||||
// Reset settings
|
||||
$('li.tab-row a[id*="Pack"]').hide();
|
||||
$('li.tab-row a[id*="VirtualProduct"]').hide();
|
||||
@@ -112,8 +120,9 @@
|
||||
$('div.is_virtual_good').hide();
|
||||
$('#is_virtual').val(0);
|
||||
$("#virtual_good_attributes").hide();
|
||||
|
||||
var product_type = $(this).val();
|
||||
|
||||
// product_type is now global
|
||||
product_type = $(this).val();
|
||||
|
||||
// until a product is added in the pack
|
||||
// if product is PTYPE_PACK, save buttons will be disabled
|
||||
@@ -137,12 +146,9 @@
|
||||
$('#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 (product_type == {Product::PTYPE_VIRTUAL})
|
||||
{
|
||||
enableSave();
|
||||
$('li.tab-row a[id*="VirtualProduct"]').show();
|
||||
$('#is_virtual_good').attr('checked', true);
|
||||
$('#virtual_good').show();
|
||||
@@ -166,12 +172,13 @@
|
||||
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');
|
||||
$('.stockForVirtualProduct').show();
|
||||
}
|
||||
// this handle the save button displays and warnings
|
||||
handleSaveButtons();
|
||||
|
||||
});
|
||||
|
||||
@@ -217,16 +224,13 @@
|
||||
}
|
||||
else if (btn_name == "Attachments")
|
||||
{
|
||||
disableSave();
|
||||
handleSaveButtons();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#desc-product-newCombination').hide();
|
||||
// if pack is enabled, save button are visible only if pack is valid
|
||||
if ($("#link-Pack:visible").length)
|
||||
handleSaveForPack();
|
||||
else
|
||||
enableSave();
|
||||
handleSaveButtons();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -238,7 +242,7 @@
|
||||
|
||||
$('#product-tab-content-Associations').bind('loaded', function()
|
||||
{
|
||||
enableSave();
|
||||
handleSaveButtons();
|
||||
});
|
||||
|
||||
$('.confirm_leave').live('click', function(){
|
||||
|
||||
@@ -103,7 +103,8 @@
|
||||
}
|
||||
});
|
||||
// show / hide save buttons
|
||||
handleSaveForPack();
|
||||
// if product has a name
|
||||
handleSaveButtons();
|
||||
}
|
||||
|
||||
function delPackItem(id)
|
||||
@@ -143,7 +144,7 @@
|
||||
});
|
||||
|
||||
// if no item left in the pack, disable save buttons
|
||||
handleSaveForPack();
|
||||
handleSaveButtons();
|
||||
}
|
||||
|
||||
function getSelectedIds()
|
||||
|
||||
+79
-11
@@ -310,25 +310,79 @@ function disableSave()
|
||||
*/
|
||||
function enableSave()
|
||||
{
|
||||
// if no item left in the pack, disable save buttons
|
||||
if ($("#disablePackMessage").length)
|
||||
$("#disablePackMessage").remove();
|
||||
|
||||
$('#desc-product-save').show();
|
||||
$('#desc-product-save-and-stay').show();
|
||||
}
|
||||
|
||||
function handleSaveForPack()
|
||||
function handleSaveButtons(e)
|
||||
{
|
||||
// if no item left in the pack, disable save buttons
|
||||
$("#disablePackMessage").remove();
|
||||
if ($("#inputPackItems").val() == "")
|
||||
msg = [];
|
||||
var i = 0;
|
||||
// relative to type of product
|
||||
if (product_type == product_type_pack)
|
||||
msg[i++] = handleSaveButtonsForPack();
|
||||
else if (product_type == product_type_pack)
|
||||
msg[i++] = handleSaveButtonsForVirtual();
|
||||
else
|
||||
msg[i++] = handleSaveButtonsForSimple();
|
||||
|
||||
// common for all products
|
||||
// name[defaultlangid]
|
||||
$("#disableSaveMessage").remove();
|
||||
if ($("#name_"+defaultLanguage.id_lang).val() == "")
|
||||
{
|
||||
disableSave();
|
||||
$(".leadin").append('<div id="disablePackMessage" class="warn">' + empty_pack_msg + '</div>');
|
||||
msg[i++] = empty_name_msg;
|
||||
}
|
||||
// friendly_url_[defaultlangid]
|
||||
if ($("#link_rewrite_"+defaultLanguage.id_lang).val() == "")
|
||||
msg[i++] = empty_link_rewrite_msg;
|
||||
|
||||
if (msg.length == 0)
|
||||
{
|
||||
$("#disableSaveMessage").remove();
|
||||
enableSave()
|
||||
}
|
||||
else
|
||||
enableSave();
|
||||
{
|
||||
$("#disableSaveMessage").remove();
|
||||
do_not_save = false;
|
||||
for (var key in msg)
|
||||
{
|
||||
if (msg != "")
|
||||
{
|
||||
if (do_not_save == false)
|
||||
{
|
||||
$(".leadin").append('<div id="disableSaveMessage" class="warn"></div>');
|
||||
warnDiv = $("#disableSaveMessage");
|
||||
do_not_save = true;
|
||||
}
|
||||
warnDiv.append('<p id="'+key+'">'+msg[key]+'</p>');
|
||||
}
|
||||
}
|
||||
if (do_not_save)
|
||||
disableSave();
|
||||
else
|
||||
enableSave();
|
||||
}
|
||||
}
|
||||
|
||||
function handleSaveButtonsForSimple()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
function handleSaveButtonsForVirtual()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
function handleSaveButtonsForPack()
|
||||
{
|
||||
// if no item left in the pack, disable save buttons
|
||||
if ($("#inputPackItems").val() == "")
|
||||
return empty_pack_msg;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function enableProductName()
|
||||
@@ -412,6 +466,20 @@ urlToCall = null;
|
||||
|
||||
$(document).ready(function() {
|
||||
updateCurrentText();
|
||||
$("#name_"+defaultLanguage.id_lang+",#link_rewrite_"+defaultLanguage.id_lang)
|
||||
.live("change", function(e)
|
||||
{
|
||||
if(typeof e == KeyboardEvent)
|
||||
if(isArrowKey(e))
|
||||
return;
|
||||
$(this).trigger("handleSaveButtons");
|
||||
});
|
||||
// bind that custom event
|
||||
$("#name_"+defaultLanguage.id_lang+",#link_rewrite_"+defaultLanguage.id_lang)
|
||||
.live("handleSaveButtons", function(e)
|
||||
{
|
||||
handleSaveButtons()
|
||||
});
|
||||
updateFriendlyURL();
|
||||
|
||||
// Pressing enter in an input field should not submit the form
|
||||
|
||||
+3
-1
@@ -107,6 +107,8 @@ function copy2friendlyURL()
|
||||
$('#link_rewrite_' + id_language).val(str2url($('#name_' + id_language).val().replace(/^[0-9]+\./, ''), 'UTF-8'));
|
||||
if ($('#friendly-url'))
|
||||
$('#friendly-url').html($('#link_rewrite_' + id_language).val());
|
||||
// trigger onchange event to use anything binded there
|
||||
$('#link_rewrite_' + id_language).change();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1175,4 +1177,4 @@ function display_action_details(row_id, controller, token, action, params) {
|
||||
current_element.parent().parent().parent().find('.details_'+id).show('fast');
|
||||
current_element.data('opened', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user