Skip to content

Commit ca7f84c

Browse files
authored
Merge pull request #490 from anzin/ui-form-field-adjustments
Changed boolean field view on the form, converted labels for fields
2 parents 191788c + 813aed5 commit ca7f84c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,17 @@
99
<label translate="true">${LABEL}</label>
1010
<dataScope>${NAME}</dataScope>
1111
</settings>
12+
#if(${FORM_ELEMENT} == 'checkbox')
13+
<formElements>
14+
<checkbox>
15+
<settings>
16+
<valueMap>
17+
<map name="false" xsi:type="number">0</map>
18+
<map name="true" xsi:type="number">1</map>
19+
</valueMap>
20+
<prefer>toggle</prefer>
21+
</settings>
22+
</checkbox>
23+
</formElements>
24+
#end
1225
</field>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ public void windowClosing(final WindowEvent event) {
271271
);
272272

273273
entityName.getDocument().addDocumentListener(new DocumentAdapter() {
274+
@SuppressWarnings("PMD.AccessorMethodGeneration")
274275
@Override
275276
protected void textChanged(final @NotNull DocumentEvent event) {
276277
autoCompleteIdentifiers();
@@ -805,7 +806,10 @@ public List<UiComponentFormFieldData> getFields() {
805806
final String name = model.getValueAt(count, 0).toString();
806807
final String dataType = model.getValueAt(count, 1).toString();
807808

808-
final String label = model.getValueAt(count, 0).toString(); //todo: convert
809+
final String label = Arrays.stream(name.split("_")).map(
810+
string -> string.substring(0, 1).toUpperCase(Locale.getDefault())
811+
+ string.substring(1)).collect(Collectors.joining(" ")
812+
);
809813
final String sortOrder = String.valueOf(count).concat("0");
810814
final String fieldset = "general";
811815

src/com/magento/idea/magento2plugin/magento/packages/uiComponent/FormElementType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static FormElementType getDefaultForProperty(final @NotNull PropertiesTyp
7878
case STRING:
7979
return FormElementType.INPUT;
8080
case BOOL:
81-
return FormElementType.BOOLEAN;
81+
return FormElementType.CHECKBOX;
8282
case FLOAT:
8383
return FormElementType.PRICE;
8484
default:

0 commit comments

Comments
 (0)