- Coupon : ajax add
This commit is contained in:
gmorel
2013-09-09 17:46:01 +02:00
parent 0fb331a5cb
commit 413e77fa97
8 changed files with 50 additions and 15 deletions

View File

@@ -344,8 +344,20 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
$cleanedCurrencies[$currency->getCode()] = $currency->getSymbol(); $cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
} }
$name1 = $this->translator->trans(
'Price',
array(),
'constraint'
);
$name2 = $this->translator->trans(
'Currency',
array(),
'constraint'
);
return array( return array(
self::INPUT1 => array( self::INPUT1 => array(
'title' => $name1,
'availableOperators' => $this->availableOperators[self::INPUT1], 'availableOperators' => $this->availableOperators[self::INPUT1],
'availableValues' => '', 'availableValues' => '',
'type' => 'text', 'type' => 'text',
@@ -354,6 +366,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
'selectedOperator' => '' 'selectedOperator' => ''
), ),
self::INPUT2 => array( self::INPUT2 => array(
'title' => $name2,
'availableOperators' => $this->availableOperators[self::INPUT2], 'availableOperators' => $this->availableOperators[self::INPUT2],
'availableValues' => $cleanedCurrencies, 'availableValues' => $cleanedCurrencies,
'type' => 'select', 'type' => 'select',

View File

@@ -304,8 +304,15 @@ class AvailableForXArticlesManager extends CouponRuleAbstract
*/ */
protected function generateInputs() protected function generateInputs()
{ {
$name1 = $this->translator->trans(
'Quantity',
array(),
'constraint'
);
return array( return array(
self::INPUT1 => array( self::INPUT1 => array(
'title' => $name1,
'availableOperators' => $this->availableOperators[self::INPUT1], 'availableOperators' => $this->availableOperators[self::INPUT1],
'type' => 'text', 'type' => 'text',
'class' => 'form-control', 'class' => 'form-control',

View File

@@ -330,7 +330,7 @@ class CouponController extends BaseAdminController
/** /**
* Manage Coupons read display * Manage Coupons read display
* *
* @param int $couponId Coupon Id * @param string $ruleId Rule service id
* *
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
*/ */
@@ -338,16 +338,21 @@ class CouponController extends BaseAdminController
{ {
$this->checkAuth('ADMIN', 'admin.coupon.read'); $this->checkAuth('ADMIN', 'admin.coupon.read');
// @todo uncomment if (!$this->getRequest()->isXmlHttpRequest()) {
// if (!$this->getRequest()->isXmlHttpRequest()) { $this->redirect(
// $this->redirect('index'); $this->getRoute(
// } 'admin',
array(),
Router::ABSOLUTE_URL
)
);
}
/** @var ConstraintFactory $constraintFactory */ /** @var ConstraintFactory $constraintFactory */
$constraintFactory = $this->container->get('thelia.constraint.factory'); $constraintFactory = $this->container->get('thelia.constraint.factory');
$inputs = $constraintFactory->getInputs($ruleId); $inputs = $constraintFactory->getInputs($ruleId);
if (!$inputs) { if ($inputs === null) {
return $this->pageNotFound(); return $this->pageNotFound();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -247,4 +247,10 @@
.ui-slider{ .ui-slider{
margin-top: 23px; margin-top: 23px;
}
.loading{
background: url("@{imgDir}/ajax-loader.gif") no-repeat;
height: 24px;
width: 24px;
} }

View File

@@ -43,6 +43,7 @@
}); });
$('#category-rule').on('change', function (e) { $('#category-rule').on('change', function (e) {
$('#rule-add-operators-values').html('<div class="loading" ></div>');
var url = "{$urlAjaxGetRuleInput}"; var url = "{$urlAjaxGetRuleInput}";
url = url.replace('ruleId', $(this).val()) url = url.replace('ruleId', $(this).val())
console.log(url); console.log(url);
@@ -50,13 +51,13 @@
url: url, url: url,
statusCode: { statusCode: {
404: function() { 404: function() {
alert("page not found"); $('#rule-add-operators-values').html(
'{intl l='Please select another rule'}'
);
} }
}, }
context: document.body
}).done(function(data) { }).done(function(data) {
console.log(data); $('#rule-add-operators-values').html(data);
$(this).addClass("done");
}); });
}); });

View File

@@ -194,8 +194,11 @@
<section class="row"> <section class="row">
<div class="col-md-12 general-block-decorator clearfix"> <div class="col-md-12 general-block-decorator clearfix">
<a title="{intl l='Save this rule'}" class="btn btn-default btn-primary pull-right">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
<div class="form-group col-md-2"> <div id="rule-add-organizer" class="form-group col-md-2">
<label for="type">{intl l='Condition type :'}</label> <label for="type">{intl l='Condition type :'}</label>
<label class="radio"> <label class="radio">
<input type="radio" name="type" id="type" value="1" checked> {intl l='And'} <input type="radio" name="type" id="type" value="1" checked> {intl l='And'}
@@ -205,7 +208,7 @@
</label> </label>
</div> </div>
<div class="form-group col-md-4"> <div id="rule-add-type" class="form-group col-md-4">
<label for="categoryRule">{intl l='Rule\'s category :'}</label> <label for="categoryRule">{intl l='Rule\'s category :'}</label>
<select name="categoryRule" id="category-rule" class="form-control"> <select name="categoryRule" id="category-rule" class="form-control">
{foreach from=$availableRules item=availableRule} {foreach from=$availableRules item=availableRule}
@@ -214,7 +217,7 @@
</select> </select>
</div> </div>
<div class="form-group col-md-6"> <div id="rule-add-operators-values" class="form-group col-md-6">
<label for="operator">{intl l='Operator :'}</label> <label for="operator">{intl l='Operator :'}</label>
<div class="row"> <div class="row">
<div class="col-lg-6"> <div class="col-lg-6">

View File

@@ -3,7 +3,7 @@
{*{$inputs|var_dump}*} {*{$inputs|var_dump}*}
{foreach from=$inputs key=name item=input} {foreach from=$inputs key=name item=input}
<label for="operator">Operator :</label> <label for="operator">{$input.title}</label>
<div class="row"> <div class="row">
<div class="col-lg-6"> <div class="col-lg-6">
<select class="form-control" id="{$name}[operator]" name="{$name}[operator]"> <select class="form-control" id="{$name}[operator]" name="{$name}[operator]">