Skip to content

Commit ac78a60

Browse files
committed
Merge remote-tracking branch 'origin/develop' into PR-copy1
2 parents 4502701 + 432b39b commit ac78a60

File tree

175 files changed

+10194
-925
lines changed

Some content is hidden

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

175 files changed

+10194
-925
lines changed

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ public function modifyMeta(array $meta)
9797
'buttons' => [
9898
[
9999
'text' => __('Cancel'),
100-
'class' => 'action-secondary',
101100
'actions' => ['closeModal'],
102101
],
103102
[
@@ -456,8 +455,13 @@ protected function getOptionInfo()
456455
'dataType' => Form\Element\DataType\Text::NAME,
457456
'formElement' => Form\Element\Select::NAME,
458457
'componentType' => Form\Field::NAME,
458+
'component' => 'Magento_Bundle/js/components/bundle-input-type',
459+
'parentContainer' => 'product_bundle_container',
460+
'selections' => 'bundle_selections',
461+
'targetIndex' => 'is_default',
459462
'dataScope' => 'type',
460463
'label' => __('Input Type'),
464+
'sortOrder' => 20,
461465
'options' => [
462466
[
463467
'label' => __('Drop-down'),
@@ -476,7 +480,12 @@ protected function getOptionInfo()
476480
'value' => 'multi'
477481
]
478482
],
479-
'sortOrder' => 20,
483+
'typeMap' => [
484+
'select' => 'radio',
485+
'radio' => 'radio',
486+
'checkbox' => 'checkbox',
487+
'multi' => 'checkbox'
488+
]
480489
],
481490
],
482491
],
@@ -533,15 +542,22 @@ protected function getBundleSelections()
533542
'arguments' => [
534543
'data' => [
535544
'config' => [
536-
'component' => 'Magento_Bundle/js/components/bundle-checkbox',
545+
'formElement' => Form\Element\Checkbox::NAME,
537546
'componentType' => Form\Field::NAME,
547+
'component' => 'Magento_Bundle/js/components/bundle-checkbox',
548+
'parentContainer' => 'product_bundle_container',
549+
'parentSelections' => 'bundle_selections',
550+
'changer' => 'option_info.type',
538551
'dataType' => Form\Element\DataType\Boolean::NAME,
539-
'formElement' => Form\Element\Checkbox::NAME,
540552
'label' => __('Default'),
541553
'dataScope' => 'is_default',
542554
'prefer' => 'radio',
543-
'value' => '1',
555+
'value' => '0',
544556
'sortOrder' => 50,
557+
'valueMap' => [
558+
'false' => '0',
559+
'true' => '1'
560+
]
545561
],
546562
],
547563
],

app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-checkbox.js

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ define([
1212
return Checkbox.extend({
1313
defaults: {
1414
clearing: false,
15-
parentContainer: 'product_bundle_container',
16-
parentSelections: 'bundle_selections',
17-
changer: 'option_info.type'
15+
parentContainer: '',
16+
parentSelections: '',
17+
changer: ''
1818
},
1919

2020
/**
@@ -32,7 +32,7 @@ define([
3232
*/
3333
initConfig: function () {
3434
this._super();
35-
this.imports.changeType = this.getParentName(this.parentContainer) + '.' + this.changer + ':value';
35+
this.imports.changeType = this.retrieveParentName(this.parentContainer) + '.' + this.changer + ':value';
3636

3737
return this;
3838
},
@@ -41,59 +41,52 @@ define([
4141
* @inheritdoc
4242
*/
4343
onUpdate: function () {
44-
if (this.prefer === 'radio' && !this.clearing) {
44+
if (this.prefer === 'radio' && this.checked() && !this.clearing) {
4545
this.clearValues();
46-
} else if (this.prefer === 'radio') {
47-
this.clearing = false;
4846
}
4947

5048
this._super();
5149
},
5250

53-
/**
54-
* Getter for parent name. Split string by provided parent name.
55-
*
56-
* @param {String} parent - parent name.
57-
* @returns {String}
58-
*/
59-
getParentName: function (parent) {
60-
return this.name.split(parent)[0] + parent;
61-
},
62-
6351
/**
6452
* Checkbox to radio type changer.
6553
*
6654
* @param {String} type - type to change.
6755
*/
6856
changeType: function (type) {
69-
if (type === 'select') {
70-
type = 'radio';
71-
} else if (type === 'multi') {
72-
type = 'checkbox';
73-
}
57+
var typeMap = registry.get(this.retrieveParentName(this.parentContainer) + '.' + this.changer).typeMap;
7458

75-
this.prefer = type;
76-
this.clear();
77-
this.elementTmpl(this.templates[type]);
78-
this.clearing = false;
59+
this.prefer = typeMap[type];
60+
this.elementTmpl(this.templates[typeMap[type]]);
7961
},
8062

8163
/**
8264
* Clears values in components like this.
8365
*/
8466
clearValues: function () {
85-
var records = registry.get(this.getParentName(this.parentSelections)),
67+
var records = registry.get(this.retrieveParentName(this.parentSelections)),
8668
index = this.index,
8769
uid = this.uid;
8870

89-
this.clearing = true;
9071
records.elems.each(function (record) {
9172
record.elems.filter(function (comp) {
9273
return comp.index === index && comp.uid !== uid;
9374
}).each(function (comp) {
75+
comp.clearing = true;
9476
comp.clear();
77+
comp.clearing = false;
9578
});
9679
});
80+
},
81+
82+
/**
83+
* Retrieve name for the most global parent with provided index.
84+
*
85+
* @param {String} parent - parent name.
86+
* @returns {String}
87+
*/
88+
retrieveParentName: function (parent) {
89+
return this.name.replace(new RegExp('^(.+?\\.)?' + parent + '\\..+'), '$1' + parent);
9790
}
9891
});
9992
});
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'Magento_Ui/js/form/element/select',
8+
'uiRegistry'
9+
], function (Select, registry) {
10+
'use strict';
11+
12+
return Select.extend({
13+
defaults: {
14+
previousType: '',
15+
parentContainer: '',
16+
selections: '',
17+
targetIndex: '',
18+
typeMap: {}
19+
},
20+
21+
/**
22+
* @inheritdoc
23+
*/
24+
onUpdate: function () {
25+
var type = this.typeMap[this.value()];
26+
27+
if (type !== this.previousType) {
28+
this.previousType = type;
29+
30+
if (type === 'radio') {
31+
this.clearValues();
32+
}
33+
}
34+
35+
this._super();
36+
},
37+
38+
/**
39+
* Clears values in components like this.
40+
*/
41+
clearValues: function () {
42+
var records = registry.get(this.retrieveParentName(this.parentContainer) + '.' + this.selections),
43+
checkedFound = false;
44+
45+
records.elems.each(function (record) {
46+
record.elems.filter(function (comp) {
47+
return comp.index === this.targetIndex;
48+
}, this).each(function (comp) {
49+
if (comp.checked()) {
50+
if (checkedFound) {
51+
comp.clearing = true;
52+
comp.clear();
53+
comp.clearing = false;
54+
}
55+
56+
checkedFound = true;
57+
}
58+
});
59+
}, this);
60+
},
61+
62+
/**
63+
* Retrieve name for the most global parent with provided index.
64+
*
65+
* @param {String} parent - parent name.
66+
* @returns {String}
67+
*/
68+
retrieveParentName: function (parent) {
69+
return this.name.replace(new RegExp('^(.+?\\.)?' + parent + '\\..+'), '$1' + parent);
70+
}
71+
});
72+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Button;
7+
8+
/**
9+
* Class Cancel
10+
*/
11+
class Cancel extends Generic
12+
{
13+
/**
14+
* Get button data
15+
*
16+
* @return array
17+
*/
18+
public function getButtonData()
19+
{
20+
return [
21+
'label' => __('Cancel'),
22+
'data_attribute' => [
23+
'mage-init' => [
24+
'Magento_Ui/js/form/button-adapter' => [
25+
'actions' => [
26+
[
27+
'targetName' => 'product_form.product_form.add_attribute_modal'
28+
. '.create_new_attribute_modal',
29+
'actionName' => 'toggleModal'
30+
]
31+
]
32+
]
33+
]
34+
],
35+
'on_click' => ''
36+
];
37+
}
38+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Button;
7+
8+
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Framework\Registry;
10+
use Magento\Framework\View\Element\UiComponent\Context;
11+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
12+
13+
/**
14+
* Class Generic
15+
*/
16+
class Generic implements ButtonProviderInterface
17+
{
18+
/**
19+
* Url Builder
20+
*
21+
* @var Context
22+
*/
23+
protected $context;
24+
25+
/**
26+
* Registry
27+
*
28+
* @var Registry
29+
*/
30+
protected $registry;
31+
32+
/**
33+
* Generic constructor
34+
*
35+
* @param Context $context
36+
* @param Registry $registry
37+
*/
38+
public function __construct(
39+
Context $context,
40+
Registry $registry
41+
) {
42+
$this->context = $context;
43+
$this->registry = $registry;
44+
}
45+
46+
/**
47+
* Generate url by route and parameters
48+
*
49+
* @param string $route
50+
* @param array $params
51+
* @return string
52+
*/
53+
public function getUrl($route = '', $params = [])
54+
{
55+
return $this->context->getUrl($route, $params);
56+
}
57+
58+
/**
59+
* {@inheritdoc}
60+
*/
61+
public function getButtonData()
62+
{
63+
return [];
64+
}
65+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Button;
7+
8+
class Save extends Generic
9+
{
10+
/**
11+
* Get button data
12+
*
13+
* @return array
14+
*/
15+
public function getButtonData()
16+
{
17+
return [
18+
'label' => __('Save Attribute'),
19+
'class' => 'save primary',
20+
'data_attribute' => [
21+
'mage-init' => ['button' => ['event' => 'save']],
22+
'form-role' => 'save',
23+
]
24+
];
25+
}
26+
}

0 commit comments

Comments
 (0)