Skip to content

Commit ec99e3e

Browse files
author
Vitaliy Boyko
committed
89: added routes xml
1 parent bd02ec1 commit ec99e3e

16 files changed

+387
-27
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<field name="${NAME}" sortOrder="${SORT_ORDER}" formElement="${FORM_ELEMENT}">
2+
<argument name="data" xsi:type="array">
3+
<item name="config" xsi:type="array">
4+
<item name="source" xsi:type="string">${SOURCE}</item>
5+
</item>
6+
</argument>
7+
<settings>
8+
<dataType>${DATA_TYPE}</dataType>
9+
<label translate="true">${LABEL}</label>
10+
<dataScope>${NAME}</dataScope>
11+
</settings>
12+
</field>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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">Form component</a> configuration.
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+
</table>
18+
</body>
19+
</html>

resources/fileTemplates/internal/Magento Module UI Component Form Xml.xml.ft

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@
2222
</settings>
2323
<dataProvider class="Atwix\CustomerQuotes\Ui\Component\CustomerQuoteVersion\Form\DataProvider\CustomerQuoteVersionDataProvider" name="${NAME}_data_source"/>
2424
</dataSource>
25-
2625
</form>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
3+
<router id="${ROUTER_ID}">
4+
</router>
5+
</config>

resources/fileTemplates/internal/Magento Routes Xml.xml.html

Whitespace-only changes.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.generation.data;
7+
8+
import com.jetbrains.php.lang.psi.elements.PhpClass;
9+
10+
public class RoutesXmlData {
11+
private String area;
12+
private String routerId;
13+
private String route;
14+
private boolean isAdminhtml;
15+
16+
/**
17+
* Routes XML Data.
18+
*
19+
* @param area String
20+
* @param routerId String
21+
* @param route String
22+
* @param isAdminhtml boolean
23+
*/
24+
public RoutesXmlData(
25+
String area,
26+
String routerId,
27+
String route,
28+
boolean isAdminhtml
29+
) {
30+
this.area = area;
31+
this.routerId = routerId;
32+
this.route = route;
33+
this.isAdminhtml = isAdminhtml;
34+
}
35+
36+
public String getArea() {
37+
return area;
38+
}
39+
40+
public String getRouterId() {
41+
return routerId;
42+
}
43+
44+
public String getRoute() {
45+
return route;
46+
}
47+
48+
public boolean isAdminhtml() {
49+
return isAdminhtml;
50+
}
51+
}

src/com/magento/idea/magento2plugin/actions/generation/data/UiComponentFormFileData.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class UiComponentFormFileData {
1616
private final ArrayList<UiComponentFormButtonData> buttons;
1717
private final ArrayList<UiComponentFormFieldsetData> fieldsets;
1818
private final ArrayList<UiComponentFormFieldData> fields;
19+
private String route;
1920

2021
/**
2122
* UI Form data file constructor.
@@ -34,7 +35,8 @@ public UiComponentFormFileData(
3435
final String label,
3536
final ArrayList<UiComponentFormButtonData> buttons,
3637
final ArrayList<UiComponentFormFieldsetData> fieldsets,
37-
final ArrayList<UiComponentFormFieldData> fields
38+
final ArrayList<UiComponentFormFieldData> fields,
39+
final String route
3840
) {
3941
this.formName = formName;
4042
this.formArea = formArea;
@@ -43,6 +45,7 @@ public UiComponentFormFileData(
4345
this.buttons = buttons;
4446
this.fieldsets = fieldsets;
4547
this.fields = fields;
48+
this.route = route;
4649
}
4750

4851
/**
@@ -107,4 +110,8 @@ public ArrayList<UiComponentFormFieldsetData> getFieldsets() {
107110
public ArrayList<UiComponentFormFieldData> getFields() {
108111
return fields;
109112
}
113+
114+
public String getRoute() {
115+
return route;
116+
}
110117
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.form

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.magento.idea.magento2plugin.actions.generation.dialog.NewUiComponentFormDialog">
3-
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="13" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
3+
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="14" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
6-
<xy x="48" y="54" width="454" height="469"/>
6+
<xy x="48" y="54" width="454" height="543"/>
77
</constraints>
88
<properties>
99
<preferredSize width="300" height="300"/>
@@ -13,7 +13,7 @@
1313
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1414
<margin top="0" left="0" bottom="0" right="0"/>
1515
<constraints>
16-
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
16+
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
1717
</constraints>
1818
<properties/>
1919
<border type="none"/>
@@ -116,7 +116,7 @@
116116
</grid>
117117
<scrollpane id="1b574">
118118
<constraints>
119-
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
119+
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
120120
</constraints>
121121
<properties/>
122122
<border type="none"/>
@@ -134,23 +134,23 @@
134134
</scrollpane>
135135
<component id="1c67f" class="javax.swing.JLabel" binding="formButtonsLabel">
136136
<constraints>
137-
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
137+
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
138138
</constraints>
139139
<properties>
140140
<text value="Buttons"/>
141141
</properties>
142142
</component>
143143
<component id="1a18" class="javax.swing.JButton" binding="addButton">
144144
<constraints>
145-
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
145+
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
146146
</constraints>
147147
<properties>
148148
<text value="Add Button"/>
149149
</properties>
150150
</component>
151151
<scrollpane id="85dca">
152152
<constraints>
153-
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
153+
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
154154
</constraints>
155155
<properties/>
156156
<border type="none"/>
@@ -166,23 +166,23 @@
166166
</scrollpane>
167167
<component id="e6bc9" class="javax.swing.JLabel" binding="fieldsetsLabel">
168168
<constraints>
169-
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
169+
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
170170
</constraints>
171171
<properties>
172172
<text value="Fieldsets"/>
173173
</properties>
174174
</component>
175175
<component id="95f6d" class="javax.swing.JLabel" binding="fieldsLabel">
176176
<constraints>
177-
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
177+
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
178178
</constraints>
179179
<properties>
180180
<text value="Fields"/>
181181
</properties>
182182
</component>
183183
<scrollpane id="fb563">
184184
<constraints>
185-
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
185+
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
186186
</constraints>
187187
<properties/>
188188
<border type="none"/>
@@ -198,20 +198,48 @@
198198
</scrollpane>
199199
<component id="ee355" class="javax.swing.JButton" binding="addFieldset">
200200
<constraints>
201-
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
201+
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
202202
</constraints>
203203
<properties>
204204
<text value="Add Fieldset"/>
205205
</properties>
206206
</component>
207207
<component id="e07ce" class="javax.swing.JButton" binding="addField">
208208
<constraints>
209-
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
209+
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
210210
</constraints>
211211
<properties>
212212
<text value="Add Field"/>
213213
</properties>
214214
</component>
215+
<grid id="e3241" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
216+
<margin top="0" left="0" bottom="0" right="0"/>
217+
<constraints>
218+
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
219+
</constraints>
220+
<properties/>
221+
<border type="none"/>
222+
<children>
223+
<component id="9bed8" class="javax.swing.JLabel" binding="routeLabel">
224+
<constraints>
225+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
226+
</constraints>
227+
<properties>
228+
<text value="Route"/>
229+
</properties>
230+
</component>
231+
<component id="d41b5" class="javax.swing.JTextField" binding="route">
232+
<constraints>
233+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
234+
<preferred-size width="150" height="-1"/>
235+
</grid>
236+
</constraints>
237+
<properties>
238+
<text value=""/>
239+
</properties>
240+
</component>
241+
</children>
242+
</grid>
215243
</children>
216244
</grid>
217245
</form>

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import com.magento.idea.magento2plugin.actions.generation.data.UiComponentFormFieldData;
1515
import com.magento.idea.magento2plugin.actions.generation.data.UiComponentFormFieldsetData;
1616
import com.magento.idea.magento2plugin.actions.generation.data.UiComponentFormFileData;
17-
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.NewUiFormValidator;
17+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.NewUiComponentFormValidator;
1818
import com.magento.idea.magento2plugin.actions.generation.generator.UiComponentFormGenerator;
1919
import com.magento.idea.magento2plugin.actions.generation.generator.util.NamespaceBuilder;
2020
import com.magento.idea.magento2plugin.magento.files.FormButtonBlockPhp;
@@ -41,7 +41,7 @@
4141
"PMD.ConstructorCallsOverridableMethod"
4242
})
4343
public class NewUiComponentFormDialog extends AbstractDialog {
44-
private final NewUiFormValidator validator;
44+
private final NewUiComponentFormValidator validator;
4545
private final Project project;
4646
private final String moduleName;
4747
private JPanel contentPane;
@@ -61,6 +61,8 @@ public class NewUiComponentFormDialog extends AbstractDialog {
6161
private JTable fields;
6262
private JButton addFieldset;
6363
private JButton addField;
64+
private JTextField route;
65+
private JLabel routeLabel;
6466

6567
/**
6668
* Open new dialog for adding new controller.
@@ -71,7 +73,7 @@ public class NewUiComponentFormDialog extends AbstractDialog {
7173
public NewUiComponentFormDialog(final Project project, final PsiDirectory directory) {
7274
super();
7375
this.project = project;
74-
this.validator = new NewUiFormValidator(this);
76+
this.validator = new NewUiComponentFormValidator(this);
7577
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
7678

7779
setContentPane(contentPane);
@@ -283,7 +285,8 @@ private PsiFile generateFile() {
283285
getFormLabel(),
284286
getButtons(),
285287
getFieldsets(),
286-
getFields()
288+
getFields(),
289+
getRoute()
287290
), project).generate(NewUiComponentFormAction.ACTION_NAME, true);
288291
}
289292

@@ -295,8 +298,7 @@ private List<String> getAreaList() {
295298
return new ArrayList<>(
296299
Arrays.asList(
297300
Areas.adminhtml.toString(),
298-
Areas.frontend.toString(),
299-
Areas.base.toString()
301+
Areas.frontend.toString()
300302
)
301303
);
302304
}
@@ -406,4 +408,8 @@ protected DefaultTableModel getFieldsetsModel() {
406408
protected DefaultTableModel getFieldsModel() {
407409
return (DefaultTableModel) fields.getModel();
408410
}
411+
412+
public String getRoute() {
413+
return route.getText().trim();
414+
}
409415
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewUiFormValidator.java renamed to src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewUiComponentFormValidator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package com.magento.idea.magento2plugin.actions.generation.dialog.validator;
77

8-
import com.intellij.openapi.util.Pair;
98
import com.jetbrains.php.refactoring.PhpNameUtil;
109
import com.magento.idea.magento2plugin.actions.generation.data.UiComponentFormButtonData;
1110
import com.magento.idea.magento2plugin.actions.generation.dialog.NewUiComponentFormDialog;
@@ -16,7 +15,7 @@
1615
import java.util.Iterator;
1716
import javax.swing.JOptionPane;
1817

19-
public class NewUiFormValidator {
18+
public class NewUiComponentFormValidator {
2019
private static final String NOT_EMPTY = "validator.notEmpty";
2120
private static final String BUTTON_CLASS_NAME = "Button ClassName";
2221
private static final String BUTTON_DIRECTORY = "Button Directory";
@@ -27,7 +26,7 @@ public class NewUiFormValidator {
2726
/**
2827
* New UI form validator constructor.
2928
*/
30-
public NewUiFormValidator(final NewUiComponentFormDialog dialog) {
29+
public NewUiComponentFormValidator(final NewUiComponentFormDialog dialog) {
3130
this.validatorBundle = new ValidatorBundle();
3231
this.commonBundle = new CommonBundle();
3332
this.dialog = dialog;

0 commit comments

Comments
 (0)