Skip to content

Commit a939aa6

Browse files
authored
Merge pull request #569 from ProkopovVitaliy/563-category-attribute-generator
563 category attribute generator
2 parents 6a5541c + 6982520 commit a939aa6

File tree

32 files changed

+1914
-201
lines changed

32 files changed

+1914
-201
lines changed

resources/META-INF/plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878

7979
<!-- Eav Attribute generators -->
8080
<group id="NewEavAttributeGroup" class="com.magento.idea.magento2plugin.actions.groups.NewEavAttributeGroup" text="Magento 2 EAV Attribute" popup="true">
81-
<action id="NewEavAttribute" class="com.magento.idea.magento2plugin.actions.generation.eavattribute.NewProductEavAttributeAction" />
81+
<action id="NewProductEavAttribute" class="com.magento.idea.magento2plugin.actions.generation.eavattribute.NewProductEavAttributeAction" />
82+
<action id="NewCatalogEavAttribute" class="com.magento.idea.magento2plugin.actions.generation.eavattribute.NewCategoryEavAttributeAction" />
8283
<add-to-group group-id="MagentoNewModuleFileGroup" anchor="last"/>
8384
</group>
8485

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#if(${INCLUDE_FIELDSET})
2+
<fieldset name="${FIELDSET_NAME}">
3+
#end
4+
<field name="${FIELD_NAME}" sortOrder="${SORT_ORDER}" formElement="${FORM_ELEMENT}"/>
5+
#if(${INCLUDE_FIELDSET})
6+
</fieldset>
7+
#end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0"?>
2+
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
4+
</form>
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*
5+
*/
6+
7+
package com.magento.idea.magento2plugin.actions.generation.data;
8+
9+
import com.magento.idea.magento2plugin.magento.packages.eav.EavEntity;
10+
import java.util.Map;
11+
12+
@SuppressWarnings({"PMD.TooManyFields"})
13+
public class CategoryEntityData implements EavEntityDataInterface {
14+
private String group;
15+
private String code;
16+
private String type;
17+
private String label;
18+
private String input;
19+
private String source;
20+
private String scope;
21+
private String dataPatchName;
22+
private String namespace;
23+
private String directory;
24+
private String moduleName;
25+
private String backendModel;
26+
private int sortOrder;
27+
private boolean required;
28+
private boolean visible;
29+
private Map<Integer, String> options;
30+
private Map<Integer, String> optionsSortOrder;
31+
32+
@Override
33+
public void setCode(final String code) {
34+
this.code = code;
35+
}
36+
37+
@Override
38+
public void setType(final String type) {
39+
this.type = type;
40+
}
41+
42+
@Override
43+
public void setLabel(final String label) {
44+
this.label = label;
45+
}
46+
47+
@Override
48+
public void setInput(final String input) {
49+
this.input = input;
50+
}
51+
52+
@Override
53+
public void setNamespace(final String namespace) {
54+
this.namespace = namespace;
55+
}
56+
57+
@Override
58+
public void setModuleName(final String moduleName) {
59+
this.moduleName = moduleName;
60+
}
61+
62+
@Override
63+
public void setDirectory(final String directory) {
64+
this.directory = directory;
65+
}
66+
67+
@Override
68+
public void setDataPatchName(final String dataPatchName) {
69+
this.dataPatchName = dataPatchName;
70+
}
71+
72+
@Override
73+
public void setSource(final String source) {
74+
this.source = source;
75+
}
76+
77+
@Override
78+
public void setSortOrder(final int sortOrder) {
79+
this.sortOrder = sortOrder;
80+
}
81+
82+
@Override
83+
public void setOptions(final Map<Integer, String> options) {
84+
this.options = options;
85+
}
86+
87+
@Override
88+
public void setOptionsSortOrder(final Map<Integer, String> optionsSortOrder) {
89+
this.optionsSortOrder = optionsSortOrder;
90+
}
91+
92+
@Override
93+
public void setRequired(final boolean required) {
94+
this.required = required;
95+
}
96+
97+
@Override
98+
public void setVisible(final boolean visible) {
99+
this.visible = visible;
100+
}
101+
102+
@Override
103+
public void setBackendModel(final String model) {
104+
this.backendModel = model;
105+
}
106+
107+
public void setGroup(final String group) {
108+
this.group = group;
109+
}
110+
111+
public void setScope(final String scope) {
112+
this.scope = scope;
113+
}
114+
115+
@Override
116+
public String getCode() {
117+
return code;
118+
}
119+
120+
@Override
121+
public String getType() {
122+
return type;
123+
}
124+
125+
@Override
126+
public String getLabel() {
127+
return label;
128+
}
129+
130+
@Override
131+
public String getInput() {
132+
return input;
133+
}
134+
135+
@Override
136+
public String getNamespace() {
137+
return namespace;
138+
}
139+
140+
@Override
141+
public String getModuleName() {
142+
return moduleName;
143+
}
144+
145+
@Override
146+
public String getDirectory() {
147+
return directory;
148+
}
149+
150+
@Override
151+
public String getDataPatchName() {
152+
return dataPatchName;
153+
}
154+
155+
@Override
156+
public String getEntityClass() {
157+
return EavEntity.CATEGORY.getEntityClass();
158+
}
159+
160+
@Override
161+
public String getSource() {
162+
return source;
163+
}
164+
165+
@Override
166+
public String getBackendModel() {
167+
return backendModel;
168+
}
169+
170+
@Override
171+
public int getSortOrder() {
172+
return sortOrder;
173+
}
174+
175+
@Override
176+
public Map<Integer, String> getOptions() {
177+
return options;
178+
}
179+
180+
@Override
181+
public Map<Integer, String> getOptionsSortOrder() {
182+
return optionsSortOrder;
183+
}
184+
185+
@Override
186+
public boolean isRequired() {
187+
return this.required;
188+
}
189+
190+
@Override
191+
public boolean isVisible() {
192+
return this.visible;
193+
}
194+
195+
public String getGroup() {
196+
return group;
197+
}
198+
199+
public String getScope() {
200+
return scope;
201+
}
202+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*
5+
*/
6+
7+
package com.magento.idea.magento2plugin.actions.generation.data;
8+
9+
import org.jetbrains.annotations.NotNull;
10+
11+
public class CategoryFormXmlData {
12+
private final String fieldSetName;
13+
private final String fieldName;
14+
private final String attributeInput;
15+
private final int sortOrder;
16+
17+
public CategoryFormXmlData(
18+
@NotNull final String fieldSetName,
19+
@NotNull final String fieldName,
20+
@NotNull final String attributeInput,
21+
@NotNull final int sortOrder
22+
) {
23+
this.fieldSetName = convertGroupNameToFieldSet(fieldSetName);
24+
this.fieldName = fieldName;
25+
this.attributeInput = attributeInput;
26+
this.sortOrder = sortOrder;
27+
}
28+
29+
private String convertGroupNameToFieldSet(final String groupName) {
30+
final String[] nameParts = groupName.toLowerCase().split(" ");//NOPMD
31+
32+
return String.join("_", nameParts);
33+
}
34+
35+
public String getFieldSetName() {
36+
return fieldSetName;
37+
}
38+
39+
public String getFieldName() {
40+
return fieldName;
41+
}
42+
43+
public int getSortOrder() {
44+
return sortOrder;
45+
}
46+
47+
public String getAttributeInput() {
48+
return attributeInput;
49+
}
50+
}
Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,69 @@
11
package com.magento.idea.magento2plugin.actions.generation.data;
22

3+
import java.util.Map;
4+
35
@SuppressWarnings({"PMD.UnnecessaryModifier"})
46
public interface EavEntityDataInterface {
5-
public String getCode();
67

7-
public String getType();
8+
void setCode(final String code);
9+
10+
void setType(final String type);
11+
12+
void setLabel(final String label);
13+
14+
void setInput(final String input);
15+
16+
void setNamespace(final String namespace);
17+
18+
void setModuleName(final String moduleName);
19+
20+
void setDirectory(final String directory);
21+
22+
void setDataPatchName(final String dataPatchName);
23+
24+
void setSource(final String source);
25+
26+
void setSortOrder(final int sortOrder);
27+
28+
void setOptions(final Map<Integer, String> options);
29+
30+
void setOptionsSortOrder(final Map<Integer, String> optionsSortOrder);
31+
32+
void setRequired(final boolean required);
33+
34+
void setVisible(final boolean visible);
35+
36+
void setBackendModel(final String model);
37+
38+
String getCode();
39+
40+
String getType();
41+
42+
String getLabel();
43+
44+
String getInput();
45+
46+
String getNamespace();
47+
48+
String getModuleName();
49+
50+
String getDirectory();
51+
52+
String getDataPatchName();
853

9-
public String getLabel();
54+
String getEntityClass();
1055

11-
public String getInput();
56+
String getSource();
1257

13-
public String getNamespace();
58+
String getBackendModel();
1459

15-
public String getModuleName();
60+
int getSortOrder();
1661

17-
public String getDirectory();
62+
Map<Integer, String> getOptions();
1863

19-
public String getDataPatchName();
64+
Map<Integer, String> getOptionsSortOrder();
2065

21-
public String getEntityClass();
66+
boolean isRequired();
2267

23-
public String getSource();
68+
boolean isVisible();
2469
}

0 commit comments

Comments
 (0)