Skip to content

Commit

Permalink
Merge pull request #633 from magento-firedrakes/MAGETWO-43157
Browse files Browse the repository at this point in the history
[Merchant Beta][Firedrakes] Bugfixes
  • Loading branch information
Logvin, Michael(mlogvin) committed Sep 28, 2015
2 parents 0861545 + 04c0db9 commit ff41dac
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ protected function _prepareForm()
$this->setChild(
'form_after',
$this->getLayout()->createBlock(
'Magento\Backend\Block\Widget\Form\Element\Dependence'
'Magento\SalesRule\Block\Widget\Form\Element\Dependence'
)->addFieldMap(
$couponTypeFiled->getHtmlId(),
$couponTypeFiled->getName()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\SalesRule\Block\Widget\Form\Element;

/**
* Form element dependencies mapper
* Assumes that one element may depend on other element values.
* Will toggle as "enabled" only if all elements it depends from toggle as true.
*/
class Dependence extends \Magento\Backend\Block\Widget\Form\Element\Dependence
{
/**
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
* @param \Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Context $context,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
\Magento\Config\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory,
array $data = []
) {
parent::__construct($context, $jsonEncoder, $fieldFactory, $data);
}

/**
* {@inheritdoc}
*/
protected function _toHtml()
{
if (!$this->_depends) {
return '';
}

return '<script>
require(["uiRegistry", "mage/adminhtml/form"], function(registry) {
var controller = new FormElementDependenceController(' .
$this->_getDependsJson() .
($this->_configOptions ? ', ' .
$this->_jsonEncoder->encode(
$this->_configOptions
) : '') . ');
registry.set("formDependenceController", controller);
});</script>';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
?>
<script>
require(['jquery', "prototype"], function(jQuery){
require(["jquery", "uiRegistry", "prototype"], function(jQuery, registry){

//<![CDATA[
var couponTypeSpecific = '<?php echo \Magento\SalesRule\Model\Rule::COUPON_TYPE_SPECIFIC ?>',
Expand Down Expand Up @@ -107,7 +107,7 @@ window.handleCouponTypeChange = handleCouponTypeChange;
window.handleCouponsTabContentActivity = handleCouponsTabContentActivity;
window.disableEnableCouponsTabContent = disableEnableCouponsTabContent;

jQuery(window).load(function(){
registry.get('formDependenceController', function() {
handleCouponsTabContentActivity();
handleCouponTypeChange();
});
Expand Down

0 comments on commit ff41dac

Please sign in to comment.