Skip to content

Commit ecf466f

Browse files
author
Melnikov, Igor(imelnikov)
committed
Merge pull request #363 from magento-extensibility/MAGETWO-43351-cart-price-rule-form
[Extensibility] Magetwo 43351 cart price rule form
2 parents 503245f + e396e03 commit ecf466f

File tree

61 files changed

+2150
-1035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2150
-1035
lines changed

app/code/Magento/Config/Model/Config/Backend/Encrypted.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public function beforeSave()
9393
$this->_dataSaveAllowed = true;
9494
$encrypted = $this->_encryptor->encrypt($value);
9595
$this->setValue($encrypted);
96+
} elseif (empty($value)) {
97+
$this->_dataSaveAllowed = true;
9698
}
9799
}
98100

app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ public function testProcessValue()
9292
*/
9393
public function testBeforeSave($value, $expectedValue, $encryptMethodCall)
9494
{
95-
$this->_resourceMock->expects($this->any())->method('addCommitCallback')->will($this->returnSelf());
96-
$this->_resourceMock->expects($this->any())->method('commit')->will($this->returnSelf());
9795
$this->_encryptorMock->expects($this->exactly($encryptMethodCall))
9896
->method('encrypt')
9997
->with($value)
@@ -113,4 +111,15 @@ public function beforeSaveDataProvider()
113111
{
114112
return [['someValue', 'encrypted', 1], ['****', '****', 0]];
115113
}
114+
115+
/**
116+
* @covers \Magento\Config\Model\Config\Backend\Encrypted::beforeSave
117+
*/
118+
public function testAllowEmptySave()
119+
{
120+
$this->_model->setValue('');
121+
$this->_model->setPath('some/path');
122+
$this->_model->beforeSave();
123+
$this->assertTrue($this->_model->isSaveAllowed());
124+
}
116125
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\OfflineShipping\Model\Source\SalesRule;
7+
8+
use Magento\Framework\Data\OptionSourceInterface;
9+
use Magento\OfflineShipping\Model\SalesRule\Rule;
10+
11+
class FreeShippingOptions implements OptionSourceInterface
12+
{
13+
/**
14+
* {@inheritdoc}
15+
* @codeCoverageIgnore
16+
*/
17+
public function toOptionArray()
18+
{
19+
return [
20+
[
21+
'value' => 0,
22+
'label' => __('No')
23+
],
24+
[
25+
'value' => Rule::FREE_SHIPPING_ITEM,
26+
'label' => __('For matching items only')
27+
],
28+
[
29+
'value' => Rule::FREE_SHIPPING_ADDRESS,
30+
'label' => __('For shipment with matching items')
31+
]
32+
];
33+
}
34+
}

app/code/Magento/OfflineShipping/Observer/SalesRule/ActionsTabPrepareFormObserver.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

app/code/Magento/OfflineShipping/Test/Unit/Observer/ActionsTabPrepareFormObserverTest.php

Lines changed: 0 additions & 70 deletions
This file was deleted.

app/code/Magento/OfflineShipping/etc/adminhtml/events.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
9+
<fieldset name="actions">
10+
<field name="simple_free_shipping">
11+
<argument name="data" xsi:type="array">
12+
<item name="options" xsi:type="object">Magento\OfflineShipping\Model\Source\SalesRule\FreeShippingOptions</item>
13+
<item name="config" xsi:type="array">
14+
<item name="dataType" xsi:type="string">text</item>
15+
<item name="label" xsi:type="string" translate="true">Free Shipping</item>
16+
<item name="formElement" xsi:type="string">select</item>
17+
<item name="dataScope" xsi:type="string">simple_free_shipping</item>
18+
<item name="caption" xsi:type="string" translate="true">-- Please Select --</item>
19+
</item>
20+
</argument>
21+
</field>
22+
</fieldset>
23+
</form>

app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit.php

Lines changed: 0 additions & 86 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit;
8+
9+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
10+
11+
/**
12+
* Class DeleteButton
13+
*/
14+
class DeleteButton extends GenericButton implements ButtonProviderInterface
15+
{
16+
/**
17+
* @return array
18+
*/
19+
public function getButtonData()
20+
{
21+
$data = [];
22+
$ruleId = $this->getRuleId();
23+
if ($ruleId && $this->canRender('delete')) {
24+
$data = [
25+
'label' => __('Delete'),
26+
'class' => 'delete',
27+
'on_click' => 'deleteConfirm(\'' . __(
28+
'Are you sure you want to delete this?'
29+
) . '\', \'' . $this->urlBuilder->getUrl('*/*/delete', ['id' => $ruleId]) . '\')',
30+
'sort_order' => 20,
31+
];
32+
}
33+
return $data;
34+
}
35+
}

app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Form.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)