Skip to content

Commit 8804389

Browse files
committed
Merge remote-tracking branch 'upstream/2.0.0-develop' into 272-fix-error-create-module
2 parents 77eb68f + 4e9ca38 commit 8804389

27 files changed

+2560
-1
lines changed

resources/META-INF/plugin.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<action id="MagentoCreateAViewModel" class="com.magento.idea.magento2plugin.actions.generation.NewViewModelAction" />
6565
<action id="MagentoCreateAGraphQlResolver" class="com.magento.idea.magento2plugin.actions.generation.NewGraphQlResolverAction" />
6666
<action id="MagentoCreateCLICommand" class="com.magento.idea.magento2plugin.actions.generation.NewCLICommandAction" />
67+
<action id="MagentoCreateUiComponentGrid" class="com.magento.idea.magento2plugin.actions.generation.NewUiComponentGridAction" />
6768
<add-to-group group-id="NewGroup" anchor="last"/>
6869
</group>
6970

@@ -195,6 +196,9 @@
195196
<internalFileTemplate name="Magento Module Controller Backend Class"/>
196197
<internalFileTemplate name="Magento Module Controller Frontend Class"/>
197198
<internalFileTemplate name="Magento Module Cron Groups Xml"/>
199+
<internalFileTemplate name="Magento Module UI Component Grid Xml"/>
200+
<internalFileTemplate name="Magento Module Ui Grid Collection Data Provider Php"/>
201+
<internalFileTemplate name="Magento Module Ui Grid Custom Data Provider Php"/>
198202

199203
<postStartupActivity implementation="com.magento.idea.magento2plugin.project.startup.CheckIfMagentoPathIsValidActivity"/>
200204
</extensions>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0"?>
2+
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
3+
<argument name="data" xsi:type="array">
4+
<item name="js_config" xsi:type="array">
5+
<item name="provider" xsi:type="string">${NAME}.${NAME}_data_source</item>
6+
<item name="deps" xsi:type="string">${NAME}.${NAME}_data_source</item>
7+
</item>
8+
</argument>
9+
<settings>
10+
<spinner>${NAME}_columns</spinner>
11+
<deps>
12+
<dep>${NAME}.${NAME}_data_source</dep>
13+
</deps>
14+
</settings>
15+
<dataSource name="${NAME}_data_source" component="Magento_Ui/js/grid/provider">
16+
<settings>
17+
<storageConfig>
18+
<param name="indexField" xsi:type="string">${ID_FIELD_NAME}</param>
19+
</storageConfig>
20+
<updateUrl path="mui/index/render"/>
21+
</settings>
22+
#if (${ACL})
23+
<aclResource>${ACL}</aclResource>
24+
#end
25+
<dataProvider class="${PROVIDER_CLASS}" name="${NAME}_data_source">
26+
<settings>
27+
<requestFieldName>${ID_FIELD_NAME}</requestFieldName>
28+
<primaryFieldName>${ID_FIELD_NAME}</primaryFieldName>
29+
</settings>
30+
</dataProvider>
31+
</dataSource>
32+
#if (${TOOLBAR})
33+
<listingToolbar name="listing_top">
34+
#if (${BOOKMARKS})
35+
<bookmark name="bookmarks"/>
36+
#end
37+
#if (${COLUMNS_CONTROLS})
38+
<columnsControls name="columns_controls"/>
39+
#end
40+
#if (${FULLTEXT_SEARCH})
41+
<filterSearch name="fulltext"/>
42+
#end
43+
#if (${LISTING_FILTERS})
44+
<filters name="listing_filters"/>
45+
#end
46+
#if (${LISTING_PAGING})
47+
<paging name="listing_paging"/>
48+
#end
49+
</listingToolbar>
50+
#end
51+
<columns name="${NAME}_columns">
52+
<column name="${ID_FIELD_NAME}">
53+
<settings>
54+
<filter>textRange</filter>
55+
<label translate="true">ID</label>
56+
<sorting>desc</sorting>
57+
</settings>
58+
</column>
59+
</columns>
60+
</listing>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html lang="en">
8+
<body>
9+
<p face="verdana" size="-1">
10+
The <a href="https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-listing-grid.html">Listing (Grid) component</a> configuration with filtering, pagination, sorting, and other features.
11+
</p>
12+
13+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
14+
<tr>
15+
<td colspan="3"><font face="verdana" size="-1">Template's predefined variables:</font></td>
16+
</tr>
17+
<tr>
18+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAME}</b></font></nobr></td>
19+
<td width="10">&nbsp;</td>
20+
<td width="100%" valign="top"><font face="verdana" size="-1">The name of the component.</font></td>
21+
</tr>
22+
<tr>
23+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${ID_FIELD_NAME}</b></font></nobr></td>
24+
<td width="10">&nbsp;</td>
25+
<td width="100%" valign="top"><font face="verdana" size="-1">The identifier field name.</font></td>
26+
</tr>
27+
<tr>
28+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${ACL}</b></font></nobr></td>
29+
<td width="10">&nbsp;</td>
30+
<td width="100%" valign="top"><font face="verdana" size="-1">The name of ACL resource that allows to restrict an access to the listing view.</font></td>
31+
</tr>
32+
<tr>
33+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${PROVIDER_CLASS}</b></font></nobr></td>
34+
<td width="10">&nbsp;</td>
35+
<td width="100%" valign="top"><font face="verdana" size="-1">The data provider class name.</font></td>
36+
</tr>
37+
<tr>
38+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${TOOLBAR}</b></font></nobr></td>
39+
<td width="10">&nbsp;</td>
40+
<td width="100%" valign="top"><font face="verdana" size="-1">Adding the <a href="https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-toolbar.html">Toolbar component</a> configuration.</font></td>
41+
</tr>
42+
<tr>
43+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${BOOKMARKS}</b></font></nobr></td>
44+
<td width="10">&nbsp;</td>
45+
<td width="100%" valign="top"><font face="verdana" size="-1">Adding the <a href="https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-bookmarks.html">Bookmarks component</a> configuration.</font></td>
46+
</tr>
47+
<tr>
48+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${COLUMNS_CONTROLS}</b></font></nobr></td>
49+
<td width="10">&nbsp;</td>
50+
<td width="100%" valign="top"><font face="verdana" size="-1">Adding the <a href="https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-columnscontrols.html">Columns Controls component</a> configuration.</font></td>
51+
</tr>
52+
<tr>
53+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${FULLTEXT_SEARCH}</b></font></nobr></td>
54+
<td width="10">&nbsp;</td>
55+
<td width="100%" valign="top"><font face="verdana" size="-1">Adding the Full Search component configuration.</font></td>
56+
</tr>
57+
<tr>
58+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${LISTING_FILTERS}</b></font></nobr></td>
59+
<td width="10">&nbsp;</td>
60+
<td width="100%" valign="top"><font face="verdana" size="-1">Adding the <a href="https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-filters.html">Listing Filters component</a> configuration.</font></td>
61+
</tr>
62+
<tr>
63+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${LISTING_PAGING}</b></font></nobr></td>
64+
<td width="10">&nbsp;</td>
65+
<td width="100%" valign="top"><font face="verdana" size="-1">Adding the <a href="https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-paging.html">Paging component</a> configuration.</font></td>
66+
</tr>
67+
</table>
68+
</body>
69+
</html>
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
#if (${NAMESPACE})
4+
5+
namespace ${NAMESPACE};
6+
#end
7+
8+
use Magento\Framework\Api\FilterBuilder;
9+
use Magento\Framework\Api\Search\ReportingInterface;
10+
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
11+
use Magento\Framework\Api\Search\SearchResultInterface;
12+
use Magento\Framework\Api\Search\SearchResultInterfaceFactory;
13+
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
14+
use Magento\Framework\App\RequestInterface;
15+
use ${COLLECTION_CLASS_FQN};
16+
use ${COLLECTION_CLASS_FQN}Factory;
17+
use Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider;
18+
19+
class ${CLASS_NAME} extends DataProvider
20+
{
21+
/**
22+
* @var ${COLLECTION_CLASS_NAME}Factory
23+
*/
24+
private $collectionFactory;
25+
26+
/**
27+
* @var CollectionProcessorInterface
28+
*/
29+
private $collectionProcessor;
30+
31+
/**
32+
* @var SearchResultInterfaceFactory
33+
*/
34+
private $searchResultFactory;
35+
36+
/**
37+
* ${CLASS_NAME} constructor.
38+
*
39+
* @param string $name
40+
* @param string $primaryFieldName
41+
* @param string $requestFieldName
42+
* @param ReportingInterface $reporting
43+
* @param SearchCriteriaBuilder $searchCriteriaBuilder
44+
* @param RequestInterface $request
45+
* @param FilterBuilder $filterBuilder
46+
* @param ${COLLECTION_CLASS_NAME}Factory $collectionFactory
47+
* @param CollectionProcessorInterface $collectionProcessor
48+
* @param SearchResultInterfaceFactory $searchResultFactory
49+
* @param array $meta
50+
* @param array $data
51+
*/
52+
public function __construct(
53+
string $name = '',
54+
string $primaryFieldName = '',
55+
string $requestFieldName = '',
56+
ReportingInterface $reporting,
57+
SearchCriteriaBuilder $searchCriteriaBuilder,
58+
RequestInterface $request,
59+
FilterBuilder $filterBuilder,
60+
${COLLECTION_CLASS_NAME}Factory $collectionFactory,
61+
CollectionProcessorInterface $collectionProcessor,
62+
SearchResultInterfaceFactory $searchResultFactory,
63+
array $meta = [],
64+
array $data = []
65+
) {
66+
parent::__construct(
67+
$name,
68+
$primaryFieldName,
69+
$requestFieldName,
70+
$reporting,
71+
$searchCriteriaBuilder,
72+
$request,
73+
$filterBuilder,
74+
$meta,
75+
$data
76+
);
77+
78+
$this->collectionFactory = $collectionFactory;
79+
$this->collectionProcessor = $collectionProcessor;
80+
$this->searchResultFactory = $searchResultFactory;
81+
}
82+
83+
/**
84+
* Get search result
85+
*
86+
* @return SearchResultInterface
87+
*/
88+
public function getSearchResult()
89+
{
90+
/** @var SearchResultInterface $searchResults */
91+
$searchResults = $this->searchResultFactory->create();
92+
$searchCriteria = $this->getSearchCriteria();
93+
/** @var ${COLLECTION_CLASS_NAME} $collection */
94+
$collection = $this->collectionFactory->create();
95+
$this->collectionProcessor->process($this->getSearchCriteria(), $collection);
96+
$items = $collection->getItems();
97+
$searchResults->setItems($items);
98+
$searchResults->setTotalCount($collection->getSize());
99+
$searchResults->setSearchCriteria($searchCriteria);
100+
101+
return $searchResults;
102+
}
103+
104+
/**
105+
* Search result to output
106+
*
107+
* @param SearchResultInterface $searchResult
108+
*
109+
* @return array
110+
*/
111+
public function searchResultToOutput(SearchResultInterface $searchResult)
112+
{
113+
$result = ['items' => []];
114+
$items = $searchResult->getItems();
115+
116+
if (!$items || !count($items)) {
117+
$result['totalRecords'] = 0;
118+
119+
return $result;
120+
}
121+
122+
foreach ($items as $index => $item) {
123+
$result['items'][$index] = $item->getData();
124+
}
125+
126+
$result['totalRecords'] = $searchResult->getTotalCount();
127+
128+
return $result;
129+
}
130+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!--
2+
/*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
10+
<tr>
11+
<td>
12+
<font face="verdana" size="-1">
13+
The Grid data provider class should inherit the <a href="https://github.com/magento/magento2/blob/2.3/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</a> class.
14+
The collection type of data provider allows us to create already implemented data provider that process the search criteria based on the provided collection class.
15+
</font><br>
16+
</td>
17+
</tr>
18+
</table>
19+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
20+
<tr>
21+
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
22+
</tr>
23+
<tr>
24+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
25+
<td width="10">&nbsp;</td>
26+
<td width="100%" valign="top"><font face="verdana" size="-1">Created PHP Data Provider class namespace.</font></td>
27+
</tr>
28+
<tr>
29+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAME}</b></font></nobr></td>
30+
<td width="10">&nbsp;</td>
31+
<td width="100%" valign="top"><font face="verdana" size="-1">PHP class for the Data Provider.</font></td>
32+
</tr>
33+
<tr>
34+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${COLLECTION_CLASS_FQN}</b></font></nobr></td>
35+
<td width="10">&nbsp;</td>
36+
<td width="100%" valign="top"><font face="verdana" size="-1">Name of PHP full qualified class name that extends the <a href="https://github.com/magento/magento2/blob/2.3/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php">Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection</a> class.</font></td>
37+
</tr>
38+
</table>
39+
</body>
40+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
#if (${NAMESPACE})
4+
5+
namespace ${NAMESPACE};
6+
#end
7+
8+
use Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider;
9+
10+
class ${CLASS_NAME} extends DataProvider
11+
{
12+
/**
13+
* @inheritDoc
14+
*/
15+
public function getData()
16+
{
17+
// todo: implement data retrieving here based on search criteria
18+
return parent::getData();
19+
}
20+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!--
2+
/*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
10+
<tr>
11+
<td>
12+
<font face="verdana" size="-1">
13+
The Grid data provider class should inherit the <a href="https://github.com/magento/magento2/blob/2.3/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</a> class.
14+
</font><br>
15+
</td>
16+
</tr>
17+
</table>
18+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
19+
<tr>
20+
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
21+
</tr>
22+
<tr>
23+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
24+
<td width="10">&nbsp;</td>
25+
<td width="100%" valign="top"><font face="verdana" size="-1">Created PHP Data Provider class namespace.</font></td>
26+
</tr>
27+
<tr>
28+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${CLASS_NAME}</b></font></nobr></td>
29+
<td width="10">&nbsp;</td>
30+
<td width="100%" valign="top"><font face="verdana" size="-1">PHP class for the Data Provider.</font></td>
31+
</tr>
32+
</table>
33+
</body>
34+
</html>

resources/magento2/common.properties

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@ common.cronGroup.description.scheduleLifetime=Window of time (in minutes) that c
5151
common.cronGroup.description.historyCleanupEvery=Time (in minutes) that cron history is kept in the database.
5252
common.cronGroup.description.historySuccessLifetime=Time (in minutes) that the record of successfully completed cron jobs are kept in the database.
5353
common.cronGroup.description.historyFailureLifetime=Time (in minutes) that the record of failed cron jobs are kept in the database.
54-
common.cronGroup.description.useSeparateProcess=Run this crongroup’s jobs in a separate php process.
54+
common.cronGroup.description.useSeparateProcess=Run this crongroup’s jobs in a separate php process.
55+
common.dataProviderType=Data Provider Type
56+
common.dataProviderCollection=Data Provider Collection
57+
common.dataProviderClass=Data Provider Class
58+
common.entityIdField=Entity ID Field
59+
common.addToolbar=Add Toolbar
60+
common.addToolbarListingPaging=Add Toolbar Listing Paging
61+
common.addToolbarListingFilters=Add Toolbar Listing Filters
62+
common.addToolbarFullTextSearch=Add Toolbar Full Text Search
63+
common.addToolbarColumnsControl=Add Toolbar Columns Control
64+
common.addToolbarBookmarks=Add Toolbar Bookmarks

0 commit comments

Comments
 (0)