Skip to content

Commit 68d2137

Browse files
Merge pull request #4928 from magento-engcom/2.3-develop-prs
[Magento Community Engineering] Community Contributions - 2.3-develop
2 parents 5e07374 + 37b2ab5 commit 68d2137

File tree

30 files changed

+748
-161
lines changed

30 files changed

+748
-161
lines changed

app/code/Magento/Backend/Block/Store/Switcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ public function getHintHtml()
592592
'What is this?'
593593
) . '"' . ' class="admin__field-tooltip-action action-help"><span>' . __(
594594
'What is this?'
595-
) . '</span></a></span>' . ' </div>';
595+
) . '</span></a>' . ' </div>';
596596
}
597597
return $html;
598598
}

app/code/Magento/CardinalCommerce/etc/adminhtml/system.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,41 @@
1919
<label>Environment</label>
2020
<source_model>Magento\CardinalCommerce\Model\Adminhtml\Source\Environment</source_model>
2121
<config_path>three_d_secure/cardinal/environment</config_path>
22+
<depends>
23+
<field id="enabled_authorize">1</field>
24+
</depends>
2225
</field>
2326
<field id="org_unit_id" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
2427
<label>Org Unit Id</label>
2528
<config_path>three_d_secure/cardinal/org_unit_id</config_path>
2629
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
30+
<depends>
31+
<field id="enabled_authorize">1</field>
32+
</depends>
2733
</field>
2834
<field id="api_key" translate="label" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
2935
<label>API Key</label>
3036
<config_path>three_d_secure/cardinal/api_key</config_path>
3137
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
38+
<depends>
39+
<field id="enabled_authorize">1</field>
40+
</depends>
3241
</field>
3342
<field id="api_identifier" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
3443
<label>API Identifier</label>
3544
<config_path>three_d_secure/cardinal/api_identifier</config_path>
3645
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
46+
<depends>
47+
<field id="enabled_authorize">1</field>
48+
</depends>
3749
</field>
3850
<field id="debug" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
3951
<label>Debug</label>
4052
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
4153
<config_path>three_d_secure/cardinal/debug</config_path>
54+
<depends>
55+
<field id="enabled_authorize">1</field>
56+
</depends>
4257
</field>
4358
</group>
4459
</group>

app/code/Magento/Catalog/Model/Product/Option.php

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory;
1212
use Magento\Catalog\Api\Data\ProductInterface;
1313
use Magento\Catalog\Model\Product;
14+
use Magento\Catalog\Model\Product\Option\Type\Date;
15+
use Magento\Catalog\Model\Product\Option\Type\DefaultType;
16+
use Magento\Catalog\Model\Product\Option\Type\File;
17+
use Magento\Catalog\Model\Product\Option\Type\Select;
18+
use Magento\Catalog\Model\Product\Option\Type\Text;
1419
use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection;
1520
use Magento\Catalog\Pricing\Price\BasePrice;
1621
use Magento\Framework\EntityManager\MetadataPool;
@@ -98,6 +103,16 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
98103
*/
99104
protected $validatorPool;
100105

106+
/**
107+
* @var string[]
108+
*/
109+
private $optionGroups;
110+
111+
/**
112+
* @var string[]
113+
*/
114+
private $optionTypesToGroups;
115+
101116
/**
102117
* @var MetadataPool
103118
*/
@@ -121,6 +136,8 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
121136
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
122137
* @param array $data
123138
* @param ProductCustomOptionValuesInterfaceFactory|null $customOptionValuesFactory
139+
* @param array $optionGroups
140+
* @param array $optionTypesToGroups
124141
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
125142
*/
126143
public function __construct(
@@ -135,14 +152,34 @@ public function __construct(
135152
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
136153
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
137154
array $data = [],
138-
ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory = null
155+
ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory = null,
156+
array $optionGroups = [],
157+
array $optionTypesToGroups = []
139158
) {
140159
$this->productOptionValue = $productOptionValue;
141160
$this->optionTypeFactory = $optionFactory;
142-
$this->validatorPool = $validatorPool;
143161
$this->string = $string;
162+
$this->validatorPool = $validatorPool;
144163
$this->customOptionValuesFactory = $customOptionValuesFactory ?:
145164
\Magento\Framework\App\ObjectManager::getInstance()->get(ProductCustomOptionValuesInterfaceFactory::class);
165+
$this->optionGroups = $optionGroups ?: [
166+
self::OPTION_GROUP_DATE => Date::class,
167+
self::OPTION_GROUP_FILE => File::class,
168+
self::OPTION_GROUP_SELECT => Select::class,
169+
self::OPTION_GROUP_TEXT => Text::class,
170+
];
171+
$this->optionTypesToGroups = $optionTypesToGroups ?: [
172+
self::OPTION_TYPE_FIELD => self::OPTION_GROUP_TEXT,
173+
self::OPTION_TYPE_AREA => self::OPTION_GROUP_TEXT,
174+
self::OPTION_TYPE_FILE => self::OPTION_GROUP_FILE,
175+
self::OPTION_TYPE_DROP_DOWN => self::OPTION_GROUP_SELECT,
176+
self::OPTION_TYPE_RADIO => self::OPTION_GROUP_SELECT,
177+
self::OPTION_TYPE_CHECKBOX => self::OPTION_GROUP_SELECT,
178+
self::OPTION_TYPE_MULTIPLE => self::OPTION_GROUP_SELECT,
179+
self::OPTION_TYPE_DATE => self::OPTION_GROUP_DATE,
180+
self::OPTION_TYPE_DATE_TIME => self::OPTION_GROUP_DATE,
181+
self::OPTION_TYPE_TIME => self::OPTION_GROUP_DATE,
182+
];
146183

147184
parent::__construct(
148185
$context,
@@ -314,36 +351,22 @@ public function getGroupByType($type = null)
314351
if ($type === null) {
315352
$type = $this->getType();
316353
}
317-
$optionGroupsToTypes = [
318-
self::OPTION_TYPE_FIELD => self::OPTION_GROUP_TEXT,
319-
self::OPTION_TYPE_AREA => self::OPTION_GROUP_TEXT,
320-
self::OPTION_TYPE_FILE => self::OPTION_GROUP_FILE,
321-
self::OPTION_TYPE_DROP_DOWN => self::OPTION_GROUP_SELECT,
322-
self::OPTION_TYPE_RADIO => self::OPTION_GROUP_SELECT,
323-
self::OPTION_TYPE_CHECKBOX => self::OPTION_GROUP_SELECT,
324-
self::OPTION_TYPE_MULTIPLE => self::OPTION_GROUP_SELECT,
325-
self::OPTION_TYPE_DATE => self::OPTION_GROUP_DATE,
326-
self::OPTION_TYPE_DATE_TIME => self::OPTION_GROUP_DATE,
327-
self::OPTION_TYPE_TIME => self::OPTION_GROUP_DATE,
328-
];
329354

330-
return $optionGroupsToTypes[$type] ?? '';
355+
return $this->optionTypesToGroups[$type] ?? '';
331356
}
332357

333358
/**
334359
* Group model factory
335360
*
336361
* @param string $type Option type
337-
* @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
362+
* @return DefaultType
338363
* @throws LocalizedException
339364
*/
340365
public function groupFactory($type)
341366
{
342367
$group = $this->getGroupByType($type);
343-
if (!empty($group)) {
344-
return $this->optionTypeFactory->create(
345-
'Magento\Catalog\Model\Product\Option\Type\\' . $this->string->upperCaseWords($group)
346-
);
368+
if (!empty($group) && isset($this->optionGroups[$group])) {
369+
return $this->optionTypeFactory->create($this->optionGroups[$group]);
347370
}
348371
throw new LocalizedException(__('The option type to get group instance is incorrect.'));
349372
}

app/code/Magento/Catalog/etc/di.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,28 @@
411411
</argument>
412412
</arguments>
413413
</type>
414+
<type name="Magento\Catalog\Model\Product\Option">
415+
<arguments>
416+
<argument name="optionGroups" xsi:type="array">
417+
<item name="date" xsi:type="string">Magento\Catalog\Model\Product\Option\Type\Date</item>
418+
<item name="file" xsi:type="string">Magento\Catalog\Model\Product\Option\Type\File</item>
419+
<item name="select" xsi:type="string">Magento\Catalog\Model\Product\Option\Type\Select</item>
420+
<item name="text" xsi:type="string">Magento\Catalog\Model\Product\Option\Type\Text</item>
421+
</argument>
422+
<argument name="optionTypesToGroups" xsi:type="array">
423+
<item name="field" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_TEXT</item>
424+
<item name="area" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_TEXT</item>
425+
<item name="file" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_FILE</item>
426+
<item name="drop_down" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT</item>
427+
<item name="radio" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT</item>
428+
<item name="checkbox" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT</item>
429+
<item name="multiple" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT</item>
430+
<item name="date" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_DATE</item>
431+
<item name="date_time" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_DATE</item>
432+
<item name="time" xsi:type="const">Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_DATE</item>
433+
</argument>
434+
</arguments>
435+
</type>
414436
<type name="Magento\Catalog\Model\Product\Option\Validator\Pool">
415437
<arguments>
416438
<argument name="validators" xsi:type="array">

app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ protected function getAgreementsConfig()
102102
: nl2br($this->escaper->escapeHtml($agreement->getContent())),
103103
'checkboxText' => $this->escaper->escapeHtml($agreement->getCheckboxText()),
104104
'mode' => $agreement->getMode(),
105-
'agreementId' => $agreement->getAgreementId()
105+
'agreementId' => $agreement->getAgreementId(),
106+
'contentHeight' => $agreement->getContentHeight()
106107
];
107108
}
108109

app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public function testGetConfigIfContentIsHtml()
7777
$escapedCheckboxText = 'escaped_checkbox_text';
7878
$mode = \Magento\CheckoutAgreements\Model\AgreementModeOptions::MODE_AUTO;
7979
$agreementId = 100;
80+
$contentHeight = '100px';
8081
$expectedResult = [
8182
'checkoutAgreements' => [
8283
'isEnabled' => 1,
@@ -86,6 +87,7 @@ public function testGetConfigIfContentIsHtml()
8687
'checkboxText' => $escapedCheckboxText,
8788
'mode' => $mode,
8889
'agreementId' => $agreementId,
90+
'contentHeight' => $contentHeight
8991
],
9092
],
9193
],
@@ -116,6 +118,7 @@ public function testGetConfigIfContentIsHtml()
116118
$agreement->expects($this->once())->method('getCheckboxText')->willReturn($checkboxText);
117119
$agreement->expects($this->once())->method('getMode')->willReturn($mode);
118120
$agreement->expects($this->once())->method('getAgreementId')->willReturn($agreementId);
121+
$agreement->expects($this->once())->method('getContentHeight')->willReturn($contentHeight);
119122

120123
$this->assertEquals($expectedResult, $this->model->getConfig());
121124
}
@@ -133,6 +136,7 @@ public function testGetConfigIfContentIsNotHtml()
133136
$escapedCheckboxText = 'escaped_checkbox_text';
134137
$mode = \Magento\CheckoutAgreements\Model\AgreementModeOptions::MODE_AUTO;
135138
$agreementId = 100;
139+
$contentHeight = '100px';
136140
$expectedResult = [
137141
'checkoutAgreements' => [
138142
'isEnabled' => 1,
@@ -142,6 +146,7 @@ public function testGetConfigIfContentIsNotHtml()
142146
'checkboxText' => $escapedCheckboxText,
143147
'mode' => $mode,
144148
'agreementId' => $agreementId,
149+
'contentHeight' => $contentHeight
145150
],
146151
],
147152
],
@@ -172,6 +177,7 @@ public function testGetConfigIfContentIsNotHtml()
172177
$agreement->expects($this->once())->method('getCheckboxText')->willReturn($checkboxText);
173178
$agreement->expects($this->once())->method('getMode')->willReturn($mode);
174179
$agreement->expects($this->once())->method('getAgreementId')->willReturn($agreementId);
180+
$agreement->expects($this->once())->method('getContentHeight')->willReturn($contentHeight);
175181

176182
$this->assertEquals($expectedResult, $this->model->getConfig());
177183
}

app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ define([
2323
agreements: agreementsConfig.agreements,
2424
modalTitle: ko.observable(null),
2525
modalContent: ko.observable(null),
26+
contentHeight: ko.observable(null),
2627
modalWindow: null,
2728

2829
/**
@@ -42,6 +43,7 @@ define([
4243
showContent: function (element) {
4344
this.modalTitle(element.checkboxText);
4445
this.modalContent(element.content);
46+
this.contentHeight(element.contentHeight ? element.contentHeight : 'auto');
4547
agreementsModal.showModal();
4648
},
4749

app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<!-- /ko -->
3636
<!-- /ko -->
3737
<div id="checkout-agreements-modal" data-bind="afterRender: initModal" style="display: none">
38-
<div class="checkout-agreements-item-content" data-bind="html: modalContent"></div>
38+
<div class="checkout-agreements-item-content" data-bind="html: modalContent, style: {height: contentHeight, overflow:'auto' }"></div>
3939
</div>
4040
</div>
4141
</div>

0 commit comments

Comments
 (0)