Skip to content

Commit 5712d36

Browse files
committed
Merge pull request #375 from magento-vanilla/PR
[Vanilla] Bugsfixes + Ui Grid improvements
2 parents 163044a + 873a2a0 commit 5712d36

File tree

64 files changed

+2544
-682
lines changed

Some content is hidden

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

64 files changed

+2544
-682
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function getAfterElementHtml()
132132
'id' => 'add_category_button',
133133
'label' => $newCategoryCaption,
134134
'title' => $newCategoryCaption,
135-
'onclick' => 'jQuery("#new-category").trigger("openModal")',
135+
'onclick' => 'jQuery("#new-category").modal("openModal")',
136136
'disabled' => $this->getDisabled(),
137137
]
138138
);

app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ define([
111111
$('#new_category_name, #new_category_parent-suggest').val('');
112112
$suggest.val('');
113113
clearParentCategory();
114-
widget.element.trigger('closeModal');
114+
$(widget.element).modal('closeModal');
115115
} else {
116116
$('#new_category_messages').html(data.messages);
117117
}

app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,84 @@
55
*/
66
namespace Magento\Cms\Test\Unit\Ui\Component\Listing\Column;
77

8+
use Magento\Cms\Ui\Component\Listing\Column\PageActions;
9+
810
class PageActionsTest extends \PHPUnit_Framework_TestCase
911
{
1012
public function testPrepareItemsByPageId()
1113
{
14+
$pageId = 1;
1215
// Create Mocks and SUT
1316
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
1417
/** @var \PHPUnit_Framework_MockObject_MockObject $urlBuilderMock */
1518
$urlBuilderMock = $this->getMockBuilder('Magento\Framework\UrlInterface')
1619
->disableOriginalConstructor()
1720
->getMock();
18-
$inputUrl = 'href/url/for/edit/action';
1921

2022
/** @var \Magento\Cms\Ui\Component\Listing\Column\PageActions $model */
2123
$model = $objectManager->getObject(
2224
'Magento\Cms\Ui\Component\Listing\Column\PageActions',
2325
[
2426
'urlBuilder' => $urlBuilderMock,
25-
'url' => $inputUrl
2627
]
2728
);
2829

2930
// Define test input and expectations
30-
$items = ['data' => ['items' => [['page_id' => 1]]]];
31-
$fullUrl = 'full-url-including-base.com/href/url/for/edit/action';
32-
$name = 'item_name';
33-
34-
$editArray = [
35-
'href' => $fullUrl,
36-
'label' => __('Edit'),
37-
'hidden' => true
31+
$items = [
32+
'data' => [
33+
'items' => [
34+
[
35+
'page_id' => $pageId
36+
]
37+
]
38+
]
3839
];
40+
$name = 'item_name';
3941
$expectedItems = [
4042
[
41-
'page_id' => 1,
42-
$name => ['edit' => $editArray]
43+
'page_id' => $pageId,
44+
$name => [
45+
'edit' => [
46+
'href' => 'test/url/edit',
47+
'label' => __('Edit'),
48+
],
49+
'delete' => [
50+
'href' => 'test/url/delete',
51+
'label' => __('Delete'),
52+
'confirm' => [
53+
'title' => __('Delete "${ $.$data.title }"'),
54+
'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?')
55+
],
56+
]
57+
],
4358
]
4459
];
4560

4661
// Configure mocks and object data
47-
$urlBuilderMock->expects($this->once())
62+
$urlBuilderMock->expects($this->any())
4863
->method('getUrl')
49-
->with($inputUrl, ['page_id' => 1])
50-
->willReturn($fullUrl);
64+
->willReturnMap(
65+
[
66+
[
67+
PageActions::CMS_URL_PATH_EDIT,
68+
[
69+
'page_id' => $pageId
70+
],
71+
'test/url/edit',
72+
],
73+
[
74+
PageActions::CMS_URL_PATH_DELETE,
75+
[
76+
'page_id' => $pageId
77+
],
78+
'test/url/delete',
79+
],
80+
]
81+
);
5182

5283
$model->setName($name);
5384
$model->prepareDataSource($items);
5485
// Run test
55-
$this->assertEquals(
56-
$expectedItems,
57-
$items['data']['items']
58-
);
86+
$this->assertEquals($expectedItems, $items['data']['items']);
5987
}
6088
}

app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class BlockActions extends Column
1818
/**
1919
* Url path
2020
*/
21-
const URL_PATH = 'cms/block/edit';
21+
const URL_PATH_EDIT = 'cms/block/edit';
22+
const URL_PATH_DELETE = 'cms/block/delete';
23+
const URL_PATH_DETAILS = 'cms/block/details';
2224

2325
/**
2426
* @var UrlInterface
@@ -45,6 +47,10 @@ public function __construct(
4547
parent::__construct($context, $uiComponentFactory, $components, $data);
4648
}
4749

50+
/**
51+
* @param array $items
52+
* @return array
53+
*/
4854
/**
4955
* Prepare Data Source
5056
*
@@ -58,8 +64,35 @@ public function prepareDataSource(array & $dataSource)
5864
if (isset($item['block_id'])) {
5965
$item[$this->getData('name')] = [
6066
'edit' => [
61-
'href' => $this->urlBuilder->getUrl(static::URL_PATH, ['block_id' => $item['block_id']]),
62-
'label' => __('Edit'),
67+
'href' => $this->urlBuilder->getUrl(
68+
static::URL_PATH_EDIT,
69+
[
70+
'block_id' => $item['block_id']
71+
]
72+
),
73+
'label' => __('Edit')
74+
],
75+
'details' => [
76+
'href' => $this->urlBuilder->getUrl(
77+
static::URL_PATH_DETAILS,
78+
[
79+
'block_id' => $item['block_id']
80+
]
81+
),
82+
'label' => __('Details')
83+
],
84+
'delete' => [
85+
'href' => $this->urlBuilder->getUrl(
86+
static::URL_PATH_DELETE,
87+
[
88+
'block_id' => $item['block_id']
89+
]
90+
),
91+
'label' => __('Delete'),
92+
'confirm' => [
93+
'title' => __('Delete "${ $.$data.title }"'),
94+
'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?')
95+
]
6396
]
6497
];
6598
}

app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,33 @@
1717
class PageActions extends Column
1818
{
1919
/** Url path */
20-
const CMS_URL_PATH = 'cms/page/edit';
20+
const CMS_URL_PATH_EDIT = 'cms/page/edit';
21+
const CMS_URL_PATH_DELETE = 'cms/page/delete';
2122

2223
/** @var UrlBuilder */
2324
protected $actionUrlBuilder;
2425

2526
/** @var UrlInterface */
2627
protected $urlBuilder;
2728

28-
/** @var string */
29-
private $url;
30-
31-
3229
/**
3330
* @param ContextInterface $context
3431
* @param UiComponentFactory $uiComponentFactory
3532
* @param UrlBuilder $actionUrlBuilder
3633
* @param UrlInterface $urlBuilder
3734
* @param array $components
3835
* @param array $data
39-
* @param string $url
4036
*/
4137
public function __construct(
4238
ContextInterface $context,
4339
UiComponentFactory $uiComponentFactory,
4440
UrlBuilder $actionUrlBuilder,
4541
UrlInterface $urlBuilder,
4642
array $components = [],
47-
array $data = [],
48-
$url = self::CMS_URL_PATH
43+
array $data = []
4944
) {
5045
$this->urlBuilder = $urlBuilder;
5146
$this->actionUrlBuilder = $actionUrlBuilder;
52-
$this->url = $url;
5347
parent::__construct($context, $uiComponentFactory, $components, $data);
5448
}
5549

@@ -63,15 +57,23 @@ public function prepareDataSource(array & $dataSource)
6357
{
6458
if (isset($dataSource['data']['items'])) {
6559
foreach ($dataSource['data']['items'] as & $item) {
60+
$name = $this->getData('name');
6661
if (isset($item['page_id'])) {
67-
$item[$this->getData('name')]['edit'] = [
68-
'href' => $this->urlBuilder->getUrl($this->url, ['page_id' => $item['page_id']]),
69-
'label' => __('Edit'),
70-
'hidden' => true
62+
$item[$name]['edit'] = [
63+
'href' => $this->urlBuilder->getUrl(self::CMS_URL_PATH_EDIT, ['page_id' => $item['page_id']]),
64+
'label' => __('Edit')
65+
];
66+
$item[$name]['delete'] = [
67+
'href' => $this->urlBuilder->getUrl(self::CMS_URL_PATH_DELETE, ['page_id' => $item['page_id']]),
68+
'label' => __('Delete'),
69+
'confirm' => [
70+
'title' => __('Delete "${ $.$data.title }"'),
71+
'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?')
72+
]
7173
];
7274
}
7375
if (isset($item['identifier'])) {
74-
$item[$this->getData('name')]['preview'] = [
76+
$item[$name]['preview'] = [
7577
'href' => $this->actionUrlBuilder->getUrl(
7678
$item['identifier'],
7779
isset($item['_first_store_id']) ? $item['_first_store_id'] : null,

app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
<container name="columns_controls">
6262
<argument name="data" xsi:type="array">
6363
<item name="config" xsi:type="array">
64+
<item name="columnsData" xsi:type="array">
65+
<item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns</item>
66+
</item>
6467
<item name="component" xsi:type="string">Magento_Ui/js/grid/controls/columns</item>
6568
<item name="displayArea" xsi:type="string">dataGridActions</item>
6669
</item>
@@ -225,13 +228,17 @@
225228
<massaction name="listing_massaction">
226229
<argument name="data" xsi:type="array">
227230
<item name="config" xsi:type="array">
231+
<item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item>
228232
<item name="displayArea" xsi:type="string">bottom</item>
229233
<item name="actions" xsi:type="array">
230234
<item name="delete" xsi:type="array">
231-
<item name="confirm" xsi:type="string" translate="true">Are you sure you want to perform this action?</item>
232235
<item name="type" xsi:type="string">delete</item>
233236
<item name="label" xsi:type="string" translate="true">Delete</item>
234237
<item name="url" xsi:type="string">cms/block/massDelete</item>
238+
<item name="confirm" xsi:type="array">
239+
<item name="title" xsi:type="string" translate="true">Delete items</item>
240+
<item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item>
241+
</item>
235242
</item>
236243
</item>
237244
<item name="indexField" xsi:type="string">block_id</item>
@@ -245,6 +252,7 @@
245252
<item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks</item>
246253
<item name="namespace" xsi:type="string">current.paging</item>
247254
</item>
255+
<item name="selectProvider" xsi:type="string">cms_block_listing.cms_block_listing.cms_block_columns.ids</item>
248256
<item name="displayArea" xsi:type="string">bottom</item>
249257
<item name="options" xsi:type="array">
250258
<item name="20" xsi:type="array">
@@ -275,10 +283,14 @@
275283
<columns name="cms_block_columns">
276284
<argument name="data" xsi:type="array">
277285
<item name="config" xsi:type="array">
286+
<item name="storageConfig" xsi:type="array">
287+
<item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks</item>
288+
<item name="namespace" xsi:type="string">current</item>
289+
</item>
278290
<item name="childDefaults" xsi:type="array">
291+
<item name="controlVisibility" xsi:type="boolean">true</item>
279292
<item name="actionField" xsi:type="string">actions</item>
280293
<item name="clickAction" xsi:type="string">edit</item>
281-
<item name="appendTo" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.columns_controls</item>
282294
<item name="storageConfig" xsi:type="array">
283295
<item name="provider" xsi:type="string">cms_block_listing.cms_block_listing.listing_top.bookmarks</item>
284296
<item name="root" xsi:type="string">columns.${ $.index }</item>
@@ -294,14 +306,14 @@
294306
</item>
295307
<item name="config" xsi:type="array">
296308
<item name="indexField" xsi:type="string">block_id</item>
297-
<item name="appendTo" xsi:type="boolean">false</item>
309+
<item name="controlVisibility" xsi:type="boolean">false</item>
298310
</item>
299311
</argument>
300312
</column>
301313
<column name="block_id">
302314
<argument name="data" xsi:type="array">
303315
<item name="js_config" xsi:type="array">
304-
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item>
316+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>
305317
</item>
306318
<item name="config" xsi:type="array">
307319
<item name="dataType" xsi:type="string">text</item>
@@ -314,7 +326,7 @@
314326
<column name="title">
315327
<argument name="data" xsi:type="array">
316328
<item name="js_config" xsi:type="array">
317-
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item>
329+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>
318330
</item>
319331
<item name="config" xsi:type="array">
320332
<item name="dataType" xsi:type="string">text</item>
@@ -326,7 +338,7 @@
326338
<column name="identifier">
327339
<argument name="data" xsi:type="array">
328340
<item name="js_config" xsi:type="array">
329-
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/sortable</item>
341+
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/column</item>
330342
</item>
331343
<item name="config" xsi:type="array">
332344
<item name="dataType" xsi:type="string">text</item>
@@ -397,7 +409,9 @@
397409
<column name="actions" class="Magento\Cms\Ui\Component\Listing\Column\BlockActions">
398410
<argument name="data" xsi:type="array">
399411
<item name="config" xsi:type="array">
412+
<item name="draggable" xsi:type="boolean">false</item>
400413
<item name="dataType" xsi:type="string">actions</item>
414+
<item name="indexField" xsi:type="string">block_id</item>
401415
<item name="align" xsi:type="string">left</item>
402416
<item name="label" xsi:type="string" translate="true">Action</item>
403417
<item name="data_type" xsi:type="string">actions</item>

0 commit comments

Comments
 (0)