Combination creation management

This commit is contained in:
Franck Allimant
2013-10-30 15:44:32 +01:00
parent 7a2469cdc8
commit 0cabe7b9e8
21 changed files with 766 additions and 77 deletions

View File

@@ -344,6 +344,21 @@ $(function() {
}
}
// -- Combination builder stuff --------------------------------------------
$('#open_combination_builder').click(function(ev) {
if (! confirm("{intl l='Existing combiations will be deleted. Do you want to continue ?'}'")) {
ev.preventDefault();
ev.stopPropagation();
}
});
{include
file = "includes/generic-js-dialog.html"
dialog_id = "combination_builder_dialog"
form_name = "thelia.admin.product_combination.build"
}
// Automatic update of price fields: any change in the taxed (resp. untaxed) price
// will update the untaxed (resp. taxed) one
$('.automatic_price_field').typeWatch({
@@ -353,6 +368,47 @@ $(function() {
update_price($(this).val(), $(this).data('price-type'), $(this).data('rel-price'));
}
});
// Count generated combinations in real time
function countGeneratedCombinations() {
var total = 0;
var counter = {};
var list = $('.attribute_av_value:checked');
if (list.length > 0) {
console.log("ok !");
list.each(function() {
var attr_id = $(this).data('attribute-id');
console.log("att="+attr_id);
if (undefined != counter[attr_id])
counter[attr_id]++;
else
counter[attr_id] = 1;
});
console.log(counter);
total = 1;
for(var count in counter) {
total *= counter[count];
}
}
return total;
}
$('.attribute_av_value').change(function(ev) {
var total = countGeneratedCombinations();
$('#number_of_generated_combinations').text(total);
});
});
</script>