Using template for coupons HTML fragments
This commit is contained in:
@@ -4,7 +4,7 @@ $(function($){
|
||||
$.couponManager = {};
|
||||
|
||||
// Condition being updated category id
|
||||
$.couponManager.conditionToUpdateServiceId = -1;
|
||||
$.couponManager.conditionToUpdateServiceId = '';
|
||||
// Condition being updated index
|
||||
$.couponManager.conditionToUpdateIndex = false;
|
||||
|
||||
@@ -20,6 +20,7 @@ $(function($){
|
||||
$.couponManager.intlPleaseRetry = '';
|
||||
$.couponManager.intlPleaseSelectAnotherCondition = '';
|
||||
$.couponManager.intlDoYouReallyWantToSetCouponAvailableForEveryOne = '';
|
||||
$.couponManager.intlDoYouReallyWantToDeleteThisCondition = '';
|
||||
|
||||
// *****************************************
|
||||
// ****************** Delete ***************
|
||||
@@ -28,11 +29,13 @@ $(function($){
|
||||
$.couponManager.onClickDeleteCondition = function() {
|
||||
$('.condition-delete-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
var index = $this.attr('data-conditionIndex');
|
||||
$.couponManager.conditionToUpdateServiceId = -1;
|
||||
$.couponManager.conditionToUpdateIndex = false;
|
||||
$.couponManager.removeConditionAjax(index);
|
||||
if (confirm($.couponManager.intlDoYouReallyWantToDeleteThisCondition)) {
|
||||
var $this = $(this);
|
||||
var index = $this.data('condition-index');
|
||||
$.couponManager.conditionToUpdateServiceId = '';
|
||||
$.couponManager.conditionToUpdateIndex = false;
|
||||
$.couponManager.removeConditionAjax(index);
|
||||
}
|
||||
});
|
||||
};
|
||||
$.couponManager.onClickDeleteCondition();
|
||||
@@ -94,7 +97,7 @@ $(function($){
|
||||
$('#condition-add-operators-values').html('');
|
||||
// Set the condition selector to default
|
||||
$("#category-condition option").filter(function() {
|
||||
return $(this).val() == '-1';
|
||||
return $(this).val() == '';
|
||||
}).prop('selected', true);
|
||||
}).fail(function() {
|
||||
$('#condition-add-operators-values').html(
|
||||
@@ -115,8 +118,8 @@ $(function($){
|
||||
$('.condition-update-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
$.couponManager.conditionToUpdateServiceId = $this.attr('data-serviceId');
|
||||
$.couponManager.conditionToUpdateIndex = $this.attr('data-conditionIndex');
|
||||
$.couponManager.conditionToUpdateServiceId = $this.data('service-id');
|
||||
$.couponManager.conditionToUpdateIndex = $this.data('condition-index');
|
||||
|
||||
$.couponManager.updateConditionSelectFromConditionInterfaceAjax(
|
||||
$.couponManager.conditionToUpdateIndex,
|
||||
@@ -135,7 +138,7 @@ $(function($){
|
||||
var $this = $(this);
|
||||
var mainDiv = $('#condition-add-type');
|
||||
var optionSelected = $('option:selected', this);
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.attr('data-description'));
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.data('description'));
|
||||
|
||||
// Only if add mode
|
||||
if (false != $.couponManager.conditionToUpdateIndex) {
|
||||
@@ -179,7 +182,7 @@ $(function($){
|
||||
}
|
||||
}).done(function(data) {
|
||||
$('#condition-add-operators-values').html(data);
|
||||
if ($.couponManager.conditionToUpdateServiceId == -1) {
|
||||
if ($.couponManager.conditionToUpdateServiceId == '') {
|
||||
// Placeholder can't be saved
|
||||
$('#condition-save-btn').hide();
|
||||
} else {
|
||||
@@ -213,7 +216,7 @@ $(function($){
|
||||
$.couponManager.onEffectChange = function() {
|
||||
var mainDiv = $('#coupon-type');
|
||||
var optionSelected = mainDiv.find('#type option:selected');
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.attr('data-description'));
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.data('description'));
|
||||
|
||||
mainDiv.find('#type').on('change', function () {
|
||||
var optionSelected = $('option:selected', this);
|
||||
@@ -225,7 +228,7 @@ $(function($){
|
||||
|
||||
$.couponManager.displayEfffect = function(optionSelected) {
|
||||
var mainDiv = $('#coupon-type');
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.attr('data-description'));
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.data('description'));
|
||||
|
||||
var inputsDiv = mainDiv.find('.inputs');
|
||||
inputsDiv.html('<div class="loading" ></div>');
|
||||
|
||||
@@ -17,12 +17,8 @@
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div class="page-header">
|
||||
<h1>{intl l='Coupons : '}<small>{intl l='Create a new coupon'}</small></h1>
|
||||
</div>
|
||||
|
||||
{form name="thelia.admin.coupon.creation"}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} noConditions=true}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} noConditions=true title={intl l='Create a new coupon'}}
|
||||
{/form}
|
||||
</section> <!-- #wrapper -->
|
||||
|
||||
@@ -48,6 +44,7 @@
|
||||
$.couponManager.urlAjaxAdminCouponDrawInputs = "{$urlAjaxAdminCouponDrawInputs}";
|
||||
$.couponManager.intlPleaseRetry = '{intl l='Please retry'}';
|
||||
$.couponManager.intlDoYouReallyWantToSetCouponAvailableForEveryOne = '{intl l='Do you really want to set this coupon available to everyone ?'}';
|
||||
$.couponManager.intlDoYouReallyWantToDeleteThisCondition = '{intl l='Do you really want to delete this condition ?'}';
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
|
||||
<li><a href="{url path='admin/tools'}">{intl l='Tools'}</a></li>
|
||||
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
|
||||
<li>{intl l="Editing %title" title="$couponCode"}</li>
|
||||
<li>{intl l='Editing coupon "%title"' title="$couponCode"}</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
{form name="thelia.admin.coupon.creation"}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form noConditions=false}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form noConditions=false title={intl l='Editing coupon "%title"' title=$couponCode}}
|
||||
{/form}
|
||||
</div> <!-- #wrapper -->
|
||||
</div>
|
||||
@@ -52,6 +52,7 @@
|
||||
$.couponManager.intlPleaseRetry = '{intl l='Please retry'}';
|
||||
$.couponManager.intlPleaseSelectAnotherCondition = '{intl l='Please select another condition'}';
|
||||
$.couponManager.intlDoYouReallyWantToSetCouponAvailableForEveryOne = '{intl l='Do you really want to set this coupon available to everyone ?'}';
|
||||
$.couponManager.intlDoYouReallyWantToDeleteThisCondition = '{intl l='Do you really want to delete this condition ?'}';
|
||||
|
||||
$('#condition-save-btn').hide();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{* List all condition with their summary *}
|
||||
{foreach from=$conditions item=condition key=i name=conditionsForeach}
|
||||
{foreach from=$conditions item=condition name=conditionsForeach}
|
||||
<tr>
|
||||
<td>
|
||||
{if !$smarty.foreach.conditionsForeach.first}
|
||||
@@ -7,13 +7,15 @@
|
||||
{/if}
|
||||
{$condition.summary nofilter}
|
||||
</td>
|
||||
<td>
|
||||
<a data-serviceId="{$condition.serviceId}" data-conditionIndex="{$condition.index}" class="btn btn-default btn-primary btn-medium condition-update-btn" href="{$urlEdit}">
|
||||
<span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
|
||||
|
||||
<td class="text-center">
|
||||
<a title="{intl l='Change this condition'}" data-service-id="{$condition.serviceId}" data-condition-index="{$condition.index}" class="condition-update-btn" href="{$urlEdit}">
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
</a>
|
||||
|
||||
{if $conditions|count != 1}
|
||||
<a data-conditionIndex="{$condition.index}" data-target="#delete" data-toggle="confirm" class="btn btn-default btn-danger btn-medium condition-delete-btn" href="{$urlDelete}">
|
||||
<span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}
|
||||
<a title="{intl l='Delete this condition'}" data-condition-index="{$condition.index}" data-target="#delete" data-toggle="confirm" class="condition-delete-btn" href="{$urlDelete}">
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-7 title">
|
||||
{intl l='Edit %title' title={$couponCode}}
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{$title}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -34,19 +35,12 @@
|
||||
{/if}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="col-md-3">
|
||||
{form_field form=$form field='code'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label class="control-label" for="code">{intl l='Code :'}</label>
|
||||
<label class="control-label" for="code">{intl l='Coupon code :'}</label>
|
||||
<input id="code" class="form-control" type="text" name="{$name}" value="{$value}" placeholder="{intl l='code'}">
|
||||
{if $error}{$message}{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="title" class="control-label" >{intl l='Title :'}</label>
|
||||
<input id="title" class="form-control" type="text" name="{$name}" value="{$value}" placeholder="{intl l='title'}">
|
||||
<span class="help-block">{intl l='This is the code entered by your customers to use this coupon'}</span>
|
||||
{if $error}{$message}{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
@@ -56,7 +50,7 @@
|
||||
<label for="is-enabled" class="checkbox control-label">
|
||||
<input id="is-enabled" type="checkbox" name="{$name}" {if $value}value="1" checked{/if} />
|
||||
{if $error}{$message}{/if}
|
||||
{intl l='Is enabled'}
|
||||
{intl l='Enabled'}
|
||||
</label>
|
||||
</div>
|
||||
{/form_field}
|
||||
@@ -66,7 +60,7 @@
|
||||
<label for="is-available-on-special-offers" class="checkbox control-label">
|
||||
<input id="is-available-on-special-offers" type="checkbox" name="{$name}" {if $value}value="1" checked{/if} />
|
||||
{if $error}{$message}{/if}
|
||||
{intl l='Is available on special offers'}
|
||||
{intl l='Valid on special offers'}
|
||||
</label>
|
||||
</div>
|
||||
{/form_field}
|
||||
@@ -76,7 +70,7 @@
|
||||
<label for="is-cumulative" class="checkbox control-label">
|
||||
<input id="is-cumulative" type="checkbox" name="{$name}" {if $value}value="1" checked{/if} />
|
||||
{if $error}{$message}{/if}
|
||||
{intl l='Is cumulative'}
|
||||
{intl l='Combinable with other promotions'}
|
||||
</label>
|
||||
</div>
|
||||
{/form_field}
|
||||
@@ -86,7 +80,7 @@
|
||||
<label for="is-removing-postage" class="checkbox control-label">
|
||||
<input id="is-removing-postage" type="checkbox" name="{$name}" {if $value}value="1" checked{/if} />
|
||||
{if $error}{$message}{/if}
|
||||
{intl l='Is removing postage'}
|
||||
{intl l='Provides free shipping'}
|
||||
</label>
|
||||
</div>
|
||||
{/form_field}
|
||||
@@ -107,125 +101,127 @@
|
||||
|
||||
<label for="is-unlimited" class="checkbox control-label">
|
||||
<input id="is-unlimited" type="checkbox" name="is-unlimited" >
|
||||
{intl l='Is unlimited'}
|
||||
{intl l='Unlimited usage'}
|
||||
</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="{if !$value}-1{else}{$value}{/if}" placeholder="{intl l='max usage'}">
|
||||
<label id="max-usage-label" for="max-usage" class="control-label">{intl l='Maximum usage count :'}</label>
|
||||
<input id="max-usage" type="text" class="form-control" name="{$name}" value="{if !$value}-1{else}{$value}{/if}" placeholder="{intl l='Usage count'}">
|
||||
{if $error}{$message}{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<div id="coupon-type" class="well clearfix">
|
||||
<div class="col-md-6">
|
||||
{form_field form=$form field='type'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="type" class="control-label">{intl l='Type :'}</label>
|
||||
<select name="{$name}" id="type" class="col-md-12 form-control">
|
||||
<option value="-1" data-description="" data-inputName="">{intl l='Please select a coupon type'}</option>
|
||||
{foreach from=$availableCoupons item=availableCoupon}
|
||||
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}" data-inputName="{$availableCoupon.inputName}" {if $value == $availableCoupon.serviceId}selected{/if}>
|
||||
{$availableCoupon.name}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
{if $error}{$message}{/if}
|
||||
<span class="help-block typeToolTip">{$availableCoupons.0.toolTip}</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
|
||||
<div class="col-md-6 inputs">
|
||||
<div id="coupon-type">
|
||||
{form_field form=$form field='type'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="type" class="control-label">{intl l='Coupon type :'}</label>
|
||||
<select name="{$name}" id="type" class="col-md-12 form-control">
|
||||
<option value="-1" data-description="" data-inputName="">{intl l='Please select a coupon type'}</option>
|
||||
{foreach from=$availableCoupons item=availableCoupon}
|
||||
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}" data-inputName="{$availableCoupon.inputName}" {if $value == $availableCoupon.serviceId}selected{/if}>
|
||||
{$availableCoupon.name}
|
||||
</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
{if $error}{$message}{/if}
|
||||
<span class="help-block typeToolTip">{$availableCoupons.0.toolTip}</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<div class="inputs">
|
||||
{form_field form=$form field='amount'}
|
||||
{$couponInputsHtml nofilter}
|
||||
{$couponInputsHtml nofilter}
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="title" class="control-label" >{intl l='Title :'}</label>
|
||||
<input id="title" class="form-control" type="text" name="{$name}" value="{$value}" placeholder="{intl l='title'}">
|
||||
{if $error}{$message}{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='shortDescription'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="short-description" class="control-label">{intl l='Short description :'}</label>
|
||||
<textarea id="short-description" name="{$name}" class="form-control" placeholder="{intl l='short description'}" class="span12" rows="5">{$value nofilter}</textarea>
|
||||
<textarea id="short-description" name="{$name}" class="form-control" placeholder="{intl l='short description'}" rows="3">{$value nofilter}</textarea>
|
||||
{if $error}{$message}{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="col-md-12">
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="description" class="control-label">{intl l='Long description :'}</label>
|
||||
<textarea id="description" name="{$name}" placeholder="{intl l='long description'}" class="form-control wysiwyg" rows="10">{$value nofilter}</textarea>
|
||||
<textarea id="description" name="{$name}" placeholder="{intl l='long description'}" class="form-control wysiwyg" rows="3">{$value nofilter}</textarea>
|
||||
{if $error}{$message}{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{if $noConditions}
|
||||
<button id="save-coupon-btn" type="submit" class="btn btn-default btn-primary">{intl l='Save your modifications'}</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if $noConditions}
|
||||
{include file='includes/notifications.html' message={intl l='Please save your Coupon in oder to affect it some conditions'}}
|
||||
{else}
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed" id="folder_list">
|
||||
<caption class="clearfix">
|
||||
{intl l='Conditions'}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{intl l='Conditions'}</th>
|
||||
<th>{intl l='Actions'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="condition-list">
|
||||
{include file='coupon/conditions.html' conditions=$conditions}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
|
||||
<div class="form-container">
|
||||
<form id="condition-form" action="{$urlAjaxSaveConditions}" {form_enctype form=$form} method="POST" >
|
||||
<div class="well clearfix">
|
||||
<a id="condition-save-btn" title="{intl l='Save this condition'}" class="btn btn-default btn-primary pull-right" data-toggle="confirm" data-script="">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span> {intl l='Save this condition'}
|
||||
</a>
|
||||
|
||||
<div id="condition-add-type" class="form-group col-md-4">
|
||||
<label for="categoryCondition">{intl l='Condition\'s category :'}</label>
|
||||
<select name="categoryCondition" id="category-condition" class="form-control">
|
||||
<option value="-1" data-description="">{intl l='Please select a condition category'}</option>
|
||||
{foreach from=$availableConditions item=availableCondition}
|
||||
<option value="{$availableCondition.serviceId}" data-description="{$availableCondition.toolTip}">{$availableCondition.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<span class="help-block typeToolTip"></span>
|
||||
</div>
|
||||
|
||||
<div id="condition-add-operators-values" class="form-group col-md-6"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl l='Coupon conditions'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
{if $noConditions}
|
||||
<div class="col-md-12">
|
||||
<br />
|
||||
{include file='includes/notifications.html' type='info' dismissable=false message={intl l='Please save this coupon first to define coupon conditions'}}
|
||||
</div>
|
||||
{else}
|
||||
<div class="col-md-6">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed" id="folder_list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{intl l='Condition description'}</th>
|
||||
<th class="text-center">{intl l='Actions'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="condition-list">
|
||||
{include file='coupon/conditions.html' conditions=$conditions}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<form id="condition-form" action="{$urlAjaxSaveConditions}" {form_enctype form=$form} method="POST" >
|
||||
|
||||
<div id="condition-add-type" class="form-group">
|
||||
<label for="categoryCondition">{intl l='Condition\'s category :'}</label>
|
||||
<select name="categoryCondition" id="category-condition" class="form-control">
|
||||
<option value="" data-description="">{intl l='Please select a condition'}</option>
|
||||
{foreach from=$availableConditions item=availableCondition}
|
||||
<option value="{$availableCondition.serviceId}" data-description="{$availableCondition.toolTip}">{$availableCondition.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<span class="help-block typeToolTip"></span>
|
||||
</div>
|
||||
|
||||
<div id="condition-add-operators-values" class="form-group">
|
||||
|
||||
</div>
|
||||
|
||||
<a id="condition-save-btn" title="{intl l='Save this condition'}" class="btn btn-default btn-primary pull-right" data-toggle="confirm" data-script="">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span> {intl l='Save this condition'}
|
||||
</a>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user