diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php index 62c77ead2..6ab746e6c 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php @@ -344,8 +344,20 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $cleanedCurrencies[$currency->getCode()] = $currency->getSymbol(); } + $name1 = $this->translator->trans( + 'Price', + array(), + 'constraint' + ); + $name2 = $this->translator->trans( + 'Currency', + array(), + 'constraint' + ); + return array( self::INPUT1 => array( + 'title' => $name1, 'availableOperators' => $this->availableOperators[self::INPUT1], 'availableValues' => '', 'type' => 'text', @@ -354,6 +366,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract 'selectedOperator' => '' ), self::INPUT2 => array( + 'title' => $name2, 'availableOperators' => $this->availableOperators[self::INPUT2], 'availableValues' => $cleanedCurrencies, 'type' => 'select', diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php index 69b7589fd..20d7eddca 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php @@ -304,8 +304,15 @@ class AvailableForXArticlesManager extends CouponRuleAbstract */ protected function generateInputs() { + $name1 = $this->translator->trans( + 'Quantity', + array(), + 'constraint' + ); + return array( self::INPUT1 => array( + 'title' => $name1, 'availableOperators' => $this->availableOperators[self::INPUT1], 'type' => 'text', 'class' => 'form-control', diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index a46f3372d..d2368a573 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -330,7 +330,7 @@ class CouponController extends BaseAdminController /** * Manage Coupons read display * - * @param int $couponId Coupon Id + * @param string $ruleId Rule service id * * @return \Symfony\Component\HttpFoundation\Response */ @@ -338,16 +338,21 @@ class CouponController extends BaseAdminController { $this->checkAuth('ADMIN', 'admin.coupon.read'); - // @todo uncomment -// if (!$this->getRequest()->isXmlHttpRequest()) { -// $this->redirect('index'); -// } + if (!$this->getRequest()->isXmlHttpRequest()) { + $this->redirect( + $this->getRoute( + 'admin', + array(), + Router::ABSOLUTE_URL + ) + ); + } /** @var ConstraintFactory $constraintFactory */ $constraintFactory = $this->container->get('thelia.constraint.factory'); $inputs = $constraintFactory->getInputs($ruleId); - if (!$inputs) { + if ($inputs === null) { return $this->pageNotFound(); } diff --git a/templates/admin/default/assets/img/ajax-loader.gif b/templates/admin/default/assets/img/ajax-loader.gif new file mode 100644 index 000000000..1321dd374 Binary files /dev/null and b/templates/admin/default/assets/img/ajax-loader.gif differ diff --git a/templates/admin/default/assets/less/thelia/thelia.less b/templates/admin/default/assets/less/thelia/thelia.less index 3883c7067..8576272bf 100644 --- a/templates/admin/default/assets/less/thelia/thelia.less +++ b/templates/admin/default/assets/less/thelia/thelia.less @@ -247,4 +247,10 @@ .ui-slider{ margin-top: 23px; +} + +.loading{ + background: url("@{imgDir}/ajax-loader.gif") no-repeat; + height: 24px; + width: 24px; } \ No newline at end of file diff --git a/templates/admin/default/coupon-update.html b/templates/admin/default/coupon-update.html index 108784996..425d9a7ac 100755 --- a/templates/admin/default/coupon-update.html +++ b/templates/admin/default/coupon-update.html @@ -43,6 +43,7 @@ }); $('#category-rule').on('change', function (e) { + $('#rule-add-operators-values').html('
'); var url = "{$urlAjaxGetRuleInput}"; url = url.replace('ruleId', $(this).val()) console.log(url); @@ -50,13 +51,13 @@ url: url, statusCode: { 404: function() { - alert("page not found"); + $('#rule-add-operators-values').html( + '{intl l='Please select another rule'}' + ); } - }, - context: document.body + } }).done(function(data) { - console.log(data); - $(this).addClass("done"); + $('#rule-add-operators-values').html(data); }); }); diff --git a/templates/admin/default/coupon/form.html b/templates/admin/default/coupon/form.html index e64ab037b..b092e30b1 100644 --- a/templates/admin/default/coupon/form.html +++ b/templates/admin/default/coupon/form.html @@ -194,8 +194,11 @@