diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index 7081a5e93..26a132e23 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -221,7 +221,7 @@
-
+
diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml
index 94c5f3da6..ff0827c73 100755
--- a/core/lib/Thelia/Config/Resources/routing/admin.xml
+++ b/core/lib/Thelia/Config/Resources/routing/admin.xml
@@ -84,6 +84,9 @@
Thelia\Controller\Admin\CouponController::readAction
+
+ Thelia\Controller\Admin\CouponController::getRuleInputAction
+
diff --git a/core/lib/Thelia/Constraint/ConstraintFactory.php b/core/lib/Thelia/Constraint/ConstraintFactory.php
index 699459847..e96509172 100644
--- a/core/lib/Thelia/Constraint/ConstraintFactory.php
+++ b/core/lib/Thelia/Constraint/ConstraintFactory.php
@@ -140,4 +140,23 @@ class ConstraintFactory
return $rule;
}
+
+ /**
+ * Get Coupon Rule inputs from serviceId
+ *
+ * @param string $ruleServiceId Rule class name
+ *
+ * @return array Ready to be drawn rule inputs
+ */
+ public function getInputs($ruleServiceId)
+ {
+ if (!$this->container->has($ruleServiceId)) {
+ return false;
+ }
+
+ /** @var CouponRuleInterface $rule */
+ $rule = $this->container->get($ruleServiceId);
+
+ return $rule->getValidators();
+ }
}
\ No newline at end of file
diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php
index 758e0b616..769a8c406 100755
--- a/core/lib/Thelia/Controller/Admin/CouponController.php
+++ b/core/lib/Thelia/Controller/Admin/CouponController.php
@@ -24,6 +24,8 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Request;
+use Thelia\Constraint\ConstraintFactory;
+use Thelia\Constraint\ConstraintFactoryTest;
use Thelia\Constraint\Rule\AvailableForTotalAmount;
use Thelia\Constraint\Rule\CouponRuleInterface;
use Thelia\Constraint\Validator\PriceParam;
@@ -311,6 +313,39 @@ class CouponController extends BaseAdminController
return $this->render('coupon-read', array('couponId' => $couponId));
}
+ /**
+ * Manage Coupons read display
+ *
+ * @param int $couponId Coupon Id
+ *
+ * @return \Symfony\Component\HttpFoundation\Response
+ */
+ public function getRuleInputAction($ruleId)
+ {
+ $this->checkAuth('ADMIN', 'admin.coupon.read');
+
+ // @todo uncomment
+// if (!$this->getRequest()->isXmlHttpRequest()) {
+// $this->redirect('index');
+// }
+
+ /** @var ConstraintFactory $constraintFactory */
+ $constraintFactory = $this->container->get('thelia.constraint.factory');
+ $inputs = $constraintFactory->getInputs($ruleId);
+
+ if (!$inputs) {
+ return $this->pageNotFound();
+ }
+
+ return $this->render(
+ 'coupon/rule-input-ajax',
+ array(
+ 'ruleId' => $ruleId,
+ 'inputs' => $inputs
+ )
+ );
+ }
+
/**
* Build a Coupon from its form
*
diff --git a/templates/admin/default/coupon/rule-input-ajax.html b/templates/admin/default/coupon/rule-input-ajax.html
new file mode 100644
index 000000000..30d74d258
--- /dev/null
+++ b/templates/admin/default/coupon/rule-input-ajax.html
@@ -0,0 +1 @@
+test
\ No newline at end of file