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();
}
});

View File

@@ -88,11 +88,11 @@
<div class="form-group {if $error}has-error{/if}">
<label for="is-unlimited" class="checkbox control-label">
<input id="is-unlimited" type="checkbox" name="is-unlimited" {if $error}{else}checked{/if} >
<input id="is-unlimited" type="checkbox" name="is-unlimited" >
{intl l='Is unlimited'}
</label>
<label id="max-usage-label" for="max-usage" class="control-label">{intl l='Max usage :'}</label>
<input id="max-usage" type="text" class="form-control" name="{$name}" value="{$value}" placeholder="{intl l='max usage'}">
<input id="max-usage" type="text" class="form-control" name="{$name}" value="{if !$value}-1{else}{$value}{/if}" placeholder="{intl l='max usage'}">
{if $error}{$message}{/if}
</div>
{/form_field}
@@ -101,17 +101,19 @@
<div class="col-md-8">
<div class="well clearfix">
<div class="col-md-6">
{form_field form=$form field='effect'}
{form_field form=$form field='type'}
<div class="form-group {if $error}has-error{/if}">
<label for="effect" class="control-label">{intl l='Effect :'}</label>
<select name="{$name}" value="{$value}" id="effect" class="col-md-12 form-control">
<option value="-1" data-description="">{intl l='Please select an effect'}</option>
<label for="type" class="control-label">{intl l='Type :'}</label>
<select name="{$name}" value="{$value}" id="type" class="col-md-12 form-control">
<option value="-1" data-description="">{intl l='Please select an type'}</option>
{foreach from=$availableCoupons item=availableCoupon}
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}" {if $value == $availableCoupon.serviceId}selected="selected"{/if}>{$availableCoupon.name}</option>
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}" {if $value == $availableCoupon.serviceId}selected="selected"{/if}>
{$availableCoupon.name}
</option>
{/foreach}
</select>
{if $error}{$message}{/if}
<span id="effectToolTip" class="help-block">{$availableCoupons.0.toolTip}</span>
<span id="typeToolTip" class="help-block">{$availableCoupons.0.toolTip}</span>
</div>
{/form_field}
</div>