Working : Coupon : fix update effect (becomes type), update max usage

This commit is contained in:
gmorel
2013-09-19 23:25:01 +02:00
parent b545e1c012
commit 8e308d21e9
8 changed files with 50 additions and 34 deletions

View File

@@ -138,17 +138,24 @@ $(function($){
// Set max usage to unlimited or not
couponManager.onUsageUnlimitedChange = function() {
if (!$('#max-usage').parent().hasClass('has-error')) {
$('#max-usage').hide().attr('value', '-1');
var isUnlimited = $('#is-unlimited');
if ($('#max-usage').val() == -1) {
isUnlimited.prop('checked', true);
$('#max-usage').hide();
$('#max-usage-label').hide();
} else {
$isUnlimited.prop('checked', false);
$('#max-usage').show();
$('#max-usage-label').show();
}
$('#is-unlimited').change(function(){
isUnlimited.change(function(){
var $this = $(this);
if ($this.is(':checked')) {
$('#max-usage').hide().attr('value', '-1');
$('#max-usage').hide().val('-1');
$('#max-usage-label').hide();
} else {
$('#max-usage').show().val('').attr('value', '');
$('#max-usage').show().val('');
$('#max-usage-label').show();
}
});