Skip to content

Commit b1b05c8

Browse files
committed
Merge pull request #345 from magento-south/MAGETWO-43824
[South+Vanilla+WebDev] CMS UI
2 parents 6ce74b2 + 7af7519 commit b1b05c8

File tree

117 files changed

+4281
-972
lines changed

Some content is hidden

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

117 files changed

+4281
-972
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@
134134
<argument name="storage" xsi:type="object">Magento\Backend\Model\Session\Storage</argument>
135135
</arguments>
136136
</type>
137+
<type name="Magento\Framework\App\Request\DataPersistor">
138+
<arguments>
139+
<argument name="session" xsi:type="object">Magento\Backend\Model\Session</argument>
140+
</arguments>
141+
</type>
137142
<virtualType name="Magento\Backend\Model\Session\Quote\Storage" type="Magento\Framework\Session\Storage">
138143
<arguments>
139144
<argument name="namespace" xsi:type="string">adminhtml_quote</argument>

app/code/Magento/Catalog/Model/Category/DataProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Eav\Model\Entity\Type;
1313
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
1414
use Magento\Store\Model\StoreManagerInterface;
15+
use Magento\Ui\Component\Form\Field;
1516
use Magento\Ui\DataProvider\EavValidationRules;
1617

1718
/**
@@ -168,7 +169,7 @@ private function prepareFieldsMeta($fieldsMap, $fieldsMeta)
168169
foreach ($fieldsMap as $fieldSet => $fields) {
169170
foreach ($fields as $field) {
170171
if (isset($fieldsMeta[$field])) {
171-
$result[$fieldSet]['fields'][$field] = $fieldsMeta[$field];
172+
$result[$fieldSet]['children'][$field]['arguments']['data']['config'] = $fieldsMeta[$field];
172173
}
173174
}
174175
}
@@ -237,6 +238,7 @@ public function getAttributesMeta(Type $entityType)
237238
}
238239

239240
$meta[$code]['scope_label'] = $this->getScopeLabel($attribute);
241+
$meta[$code]['componentType'] = Field::NAME;
240242
}
241243

242244
$result = [];

app/code/Magento/Catalog/Ui/Component/Category/Form/Element/Wysiwyg.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
use Magento\Backend\Helper\Data as DataHelper;
1010
use Magento\Catalog\Api\CategoryAttributeRepositoryInterface;
1111
use Magento\Catalog\Model\Category;
12-
use Magento\Framework\Data\Form;
13-
use Magento\Framework\Data\Form\Element\Editor as EditorElement;
12+
use Magento\Framework\Data\FormFactory;
1413
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1514
use Magento\Ui\Component\Wysiwyg\ConfigInterface;
1615
use Magento\Framework\View\LayoutInterface;
@@ -31,10 +30,8 @@ class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
3130
protected $layout;
3231

3332
/**
34-
* Wysiwyg constructor.
3533
* @param ContextInterface $context
36-
* @param Form $form
37-
* @param EditorElement $editorElement
34+
* @param FormFactory $formFactory
3835
* @param ConfigInterface $wysiwygConfig
3936
* @param LayoutInterface $layout
4037
* @param DataHelper $backendHelper
@@ -47,8 +44,7 @@ class Wysiwyg extends \Magento\Ui\Component\Form\Element\Wysiwyg
4744
*/
4845
public function __construct(
4946
ContextInterface $context,
50-
Form $form,
51-
EditorElement $editorElement,
47+
FormFactory $formFactory,
5248
ConfigInterface $wysiwygConfig,
5349
LayoutInterface $layout,
5450
DataHelper $backendHelper,
@@ -60,8 +56,8 @@ public function __construct(
6056
$this->layout = $layout;
6157
$this->backendHelper = $backendHelper;
6258

63-
$editorElement->setData('wysiwyg', (bool)$attrRepository->get($data['name'])->getIsWysiwygEnabled());
64-
parent::__construct($context, $form, $editorElement, $wysiwygConfig, $components, $data, $config);
59+
$config['wysiwyg'] = (bool)$attrRepository->get($data['name'])->getIsWysiwygEnabled();
60+
parent::__construct($context, $formFactory, $wysiwygConfig, $components, $data, $config);
6561
$this->setData($this->prepareData($this->getData()));
6662
}
6763

@@ -73,7 +69,7 @@ public function __construct(
7369
*/
7470
private function prepareData($data)
7571
{
76-
if ($this->editorElement->isEnabled()) {
72+
if ($this->editor->isEnabled()) {
7773
$data['config']['content'] .= $this->getWysiwygButtonHtml();
7874
}
7975
return $data;
@@ -96,7 +92,7 @@ private function getWysiwygButtonHtml()
9692
'class' => 'action-wysiwyg',
9793
'onclick' => 'catalogWysiwygEditor.open(\'' . $this->backendHelper->getUrl(
9894
'catalog/product/wysiwyg'
99-
) . '\', \'' . $this->editorElement->getHtmlId() . '\')',
95+
) . '\', \'' . $this->editor->getHtmlId() . '\')',
10096
]
10197
]
10298
)->toHtml();

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 91 additions & 73 deletions
Large diffs are not rendered by default.

app/code/Magento/CatalogRule/Model/Rule/DataProvider.php

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,31 +100,61 @@ protected function initMeta()
100100

101101
$this->meta = [
102102
'rule_information' => [
103-
'fields' => [
103+
'children' => [
104104
'website_ids' => [
105-
'options' => $this->store->getWebsiteValuesForForm()
105+
'arguments' => [
106+
'data' => [
107+
'config' => [
108+
'options' => $this->store->getWebsiteValuesForForm(),
109+
],
110+
],
111+
],
106112
],
107113
'is_active' => [
108-
'options' => [
109-
['label' => __('Active'), 'value' => '1'],
110-
['label' => __('Inactive'), 'value' => '0']
111-
]
114+
'arguments' => [
115+
'data' => [
116+
'config' => [
117+
'options' => [
118+
['label' => __('Active'), 'value' => '1'],
119+
['label' => __('Inactive'), 'value' => '0']
120+
],
121+
],
122+
],
123+
],
112124
],
113125
'customer_group_ids' => [
114-
'options' => $this->objectConverter->toOptionArray($customerGroups, 'id', 'code')
126+
'arguments' => [
127+
'data' => [
128+
'config' => [
129+
'options' => $this->objectConverter->toOptionArray($customerGroups, 'id', 'code'),
130+
],
131+
],
132+
],
115133
]
116134
]
117135
],
118136
'actions' => [
119-
'fields' => [
137+
'children' => [
120138
'simple_action' => [
121-
'options' => $applyOptions
139+
'arguments' => [
140+
'data' => [
141+
'config' => [
142+
'options' => $applyOptions
143+
],
144+
],
145+
],
122146
],
123147
'stop_rules_processing' => [
124-
'options' => [
125-
['label' => __('Yes'), 'value' => '1'],
126-
['label' => __('No'), 'value' => '0']
127-
]
148+
'arguments' => [
149+
'data' => [
150+
'config' => [
151+
'options' => [
152+
['label' => __('Yes'), 'value' => '1'],
153+
['label' => __('No'), 'value' => '0']
154+
]
155+
],
156+
],
157+
],
128158
],
129159
]
130160
]

app/code/Magento/CatalogUrlRewrite/Plugin/Catalog/Block/Adminhtml/Category/Tab/Attributes.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public function afterGetAttributesMeta(
2525
if (isset($result['url_key'])) {
2626
if ($category && $category->getId()) {
2727
if ($category->getLevel() == 1) {
28-
$result['url_key']['visible'] = false;
29-
$result['url_key_create_redirect']['visible'] = false;
30-
$result['url_key_group']['componentDisabled'] = true;
28+
$result['url_key']['arguments']['data']['config']['visible'] = false;
29+
$result['url_key_create_redirect']['arguments']['data']['config']['visible'] = false;
30+
$result['url_key_group']['arguments']['data']['disabled'] = true;
3131
} else {
32-
$result['url_key_create_redirect']['value'] = $category->getUrlKey();
33-
$result['url_key_create_redirect']['disabled'] = true;
32+
$result['url_key_create_redirect']['arguments']['data']['config']['value'] = $category->getUrlKey();
33+
$result['url_key_create_redirect']['arguments']['data']['config']['disabled'] = true;
3434
}
3535
} else {
36-
$result['url_key_create_redirect']['visible'] = false;
36+
$result['url_key_create_redirect']['arguments']['data']['config']['visible'] = false;
3737
}
3838
}
3939
return $result;

app/code/Magento/CatalogUrlRewrite/view/adminhtml/ui_component/category_form.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
<field name="url_key_create_redirect">
1313
<argument name="data" xsi:type="array">
1414
<item name="config" xsi:type="array">
15-
<item name="label" xsi:type="string" translate="true">Create Permanent Redirect for old URL</item>
15+
<item name="description" xsi:type="string" translate="true">Create Permanent Redirect for old URL</item>
1616
<item name="dataType" xsi:type="string">boolean</item>
1717
<item name="formElement" xsi:type="string">checkbox</item>
18-
<item name="imports" xsi:type="array">
19-
<item name="handleChanges" xsi:type="string">${ $.provider }:data.url_key</item>
20-
</item>
21-
<item name="component" xsi:type="string">Magento_Catalog/js/components/url-key-handle-changes</item>
18+
<item name="disabled" xsi:type="boolean">true</item>
2219
<item name="sortOrder" xsi:type="number">15</item>
2320
</item>
2421
</argument>

app/code/Magento/Cms/Block/Adminhtml/Block/Edit/DeleteButton.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DeleteButton extends GenericButton implements ButtonProviderInterface
1919
public function getButtonData()
2020
{
2121
$data = [];
22-
if ($this->getPageId()) {
22+
if ($this->getBlockId()) {
2323
$data = [
2424
'label' => __('Delete Block'),
2525
'class' => 'delete',
@@ -37,6 +37,6 @@ public function getButtonData()
3737
*/
3838
public function getDeleteUrl()
3939
{
40-
return $this->getUrl('*/*/delete', ['block_id' => $this->getPageId()]);
40+
return $this->getUrl('*/*/delete', ['block_id' => $this->getBlockId()]);
4141
}
4242
}

app/code/Magento/Cms/Block/Adminhtml/Block/Edit/GenericButton.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,51 @@
55
*/
66
namespace Magento\Cms\Block\Adminhtml\Block\Edit;
77

8-
use Magento\Cms\Controller\RegistryConstants;
8+
use Magento\Backend\Block\Widget\Context;
9+
use Magento\Cms\Api\BlockRepositoryInterface;
10+
use Magento\Framework\Exception\NoSuchEntityException;
911

1012
/**
1113
* Class GenericButton
1214
*/
1315
class GenericButton
1416
{
1517
/**
16-
* Url Builder
17-
*
18-
* @var \Magento\Framework\UrlInterface
18+
* @var Context
1919
*/
20-
protected $urlBuilder;
20+
protected $context;
2121

2222
/**
23-
* Registry
24-
*
25-
* @var \Magento\Framework\Registry
23+
* @var BlockRepositoryInterface
2624
*/
27-
protected $registry;
25+
protected $blockRepository;
2826

2927
/**
30-
* Constructor
31-
*
32-
* @param \Magento\Backend\Block\Widget\Context $context
33-
* @param \Magento\Framework\Registry $registry
28+
* @param Context $context
29+
* @param BlockRepositoryInterface $blockRepository
3430
*/
3531
public function __construct(
36-
\Magento\Backend\Block\Widget\Context $context,
37-
\Magento\Framework\Registry $registry
32+
Context $context,
33+
BlockRepositoryInterface $blockRepository
3834
) {
39-
$this->urlBuilder = $context->getUrlBuilder();
40-
$this->registry = $registry;
35+
$this->context = $context;
36+
$this->blockRepository = $blockRepository;
4137
}
4238

4339
/**
44-
* Return the cms page Id.
40+
* Return CMS block ID
4541
*
4642
* @return int|null
4743
*/
48-
public function getPageId()
44+
public function getBlockId()
4945
{
50-
$cmsBlock = $this->registry->registry(RegistryConstants::CMS_BLOCK);
51-
return $cmsBlock ? $cmsBlock->getId() : null;
46+
try {
47+
return $this->blockRepository->getById(
48+
$this->context->getRequest()->getParam('block_id')
49+
)->getId();
50+
} catch (NoSuchEntityException $e) {
51+
}
52+
return null;
5253
}
5354

5455
/**
@@ -60,6 +61,6 @@ public function getPageId()
6061
*/
6162
public function getUrl($route = '', $params = [])
6263
{
63-
return $this->urlBuilder->getUrl($route, $params);
64+
return $this->context->getUrlBuilder()->getUrl($route, $params);
6465
}
6566
}

app/code/Magento/Cms/Block/Adminhtml/Page/Edit/GenericButton.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,51 @@
55
*/
66
namespace Magento\Cms\Block\Adminhtml\Page\Edit;
77

8-
use Magento\Cms\Controller\RegistryConstants;
8+
use Magento\Backend\Block\Widget\Context;
9+
use Magento\Cms\Api\PageRepositoryInterface;
10+
use Magento\Framework\Exception\NoSuchEntityException;
911

1012
/**
1113
* Class GenericButton
1214
*/
1315
class GenericButton
1416
{
1517
/**
16-
* Url Builder
17-
*
18-
* @var \Magento\Framework\UrlInterface
18+
* @var Context
1919
*/
20-
protected $urlBuilder;
20+
protected $context;
2121

2222
/**
23-
* Registry
24-
*
25-
* @var \Magento\Framework\Registry
23+
* @var PageRepositoryInterface
2624
*/
27-
protected $registry;
25+
protected $pageRepository;
2826

2927
/**
30-
* Constructor
31-
*
32-
* @param \Magento\Backend\Block\Widget\Context $context
33-
* @param \Magento\Framework\Registry $registry
28+
* @param Context $context
29+
* @param PageRepositoryInterface $pageRepository
3430
*/
3531
public function __construct(
36-
\Magento\Backend\Block\Widget\Context $context,
37-
\Magento\Framework\Registry $registry
32+
Context $context,
33+
PageRepositoryInterface $pageRepository
3834
) {
39-
$this->urlBuilder = $context->getUrlBuilder();
40-
$this->registry = $registry;
35+
$this->context = $context;
36+
$this->pageRepository = $pageRepository;
4137
}
4238

4339
/**
44-
* Return the cms page Id.
40+
* Return CMS page ID
4541
*
4642
* @return int|null
4743
*/
4844
public function getPageId()
4945
{
50-
$cmsPage = $this->registry->registry(RegistryConstants::CMS_PAGE);
51-
return $cmsPage ? $cmsPage->getId() : null;
46+
try {
47+
return $this->pageRepository->getById(
48+
$this->context->getRequest()->getParam('page_id')
49+
)->getId();
50+
} catch (NoSuchEntityException $e) {
51+
}
52+
return null;
5253
}
5354

5455
/**
@@ -60,6 +61,6 @@ public function getPageId()
6061
*/
6162
public function getUrl($route = '', $params = [])
6263
{
63-
return $this->urlBuilder->getUrl($route, $params);
64+
return $this->context->getUrlBuilder()->getUrl($route, $params);
6465
}
6566
}

0 commit comments

Comments
 (0)