Skip to content

Commit d8f5cb3

Browse files
Mixin for CMS Form #11377
1 parent a8979b8 commit d8f5cb3

File tree

122 files changed

+1149
-1341
lines changed

Some content is hidden

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

122 files changed

+1149
-1341
lines changed

modules/app/app-system/src/main/resources/i18n/phrases.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ media.unknown.displayName=Unknown
6767
media.default.media.label=Media
6868
media.default.tags.label=Tags
6969
#
70-
# Image mixins
70+
# Image form fragments
7171
#
7272
media.imageInfo.displayName=Properties
7373
media.imageInfo.pixelSize.label=Size (px)
@@ -99,7 +99,7 @@ media.cameraInfo.exposureMode.label=Exposure Mode
9999
media.cameraInfo.focusDistance.label=Focus Distance
100100
media.cameraInfo.orientation.label=Orientation
101101
#
102-
# Base mixins
102+
# Base form fragments
103103
#
104104
base.gpsInfo.displayName=Location
105105
base.gpsInfo.geoPoint.label=Geo Point

modules/core/core-api/src/main/java/com/enonic/xp/app/ApplicationRelativeResolver.java

Lines changed: 0 additions & 79 deletions
This file was deleted.

modules/core/core-api/src/main/java/com/enonic/xp/form/Form.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public Input getInput( final String path )
4040
return formItems.getInput( FormItemPath.from( path ) );
4141
}
4242

43-
public InlineMixin getInlineMixin( final String path )
43+
public FormFragment getFormFragment( final String path )
4444
{
45-
return formItems.getInlineMixin( FormItemPath.from( path ) );
45+
return formItems.getFormFragment( FormItemPath.from( path ) );
4646
}
4747

4848
public FormOptionSet getOptionSet( final String path )
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package com.enonic.xp.form;
2+
3+
4+
import java.util.Objects;
5+
6+
import com.enonic.xp.annotation.PublicApi;
7+
import com.enonic.xp.schema.formfragment.FormFragmentDescriptor;
8+
import com.enonic.xp.schema.formfragment.FormFragmentName;
9+
10+
@PublicApi
11+
public final class FormFragment
12+
extends FormItem
13+
{
14+
private final FormFragmentName formFragmentName;
15+
16+
private FormFragment( Builder builder )
17+
{
18+
super();
19+
20+
Objects.requireNonNull( builder.formFragmentName, "formFragmentName is required" );
21+
this.formFragmentName = builder.formFragmentName;
22+
}
23+
24+
@Override
25+
public FormItemType getType()
26+
{
27+
return FormItemType.FORM_FRAGMENT;
28+
}
29+
30+
public FormFragmentName getFormFragmentName()
31+
{
32+
return formFragmentName;
33+
}
34+
35+
@Override
36+
public String getName()
37+
{
38+
return formFragmentName.getLocalName();
39+
}
40+
41+
@Override
42+
public boolean equals( final Object o )
43+
{
44+
if ( this == o )
45+
{
46+
return true;
47+
}
48+
if ( o == null || getClass() != o.getClass() )
49+
{
50+
return false;
51+
}
52+
53+
final FormFragment that = (FormFragment) o;
54+
return super.equals( o ) && Objects.equals( this.formFragmentName, that.formFragmentName );
55+
}
56+
57+
@Override
58+
public int hashCode()
59+
{
60+
return Objects.hash( super.hashCode(), this.formFragmentName );
61+
}
62+
63+
public static Builder create()
64+
{
65+
return new Builder();
66+
}
67+
68+
@Override
69+
public FormFragment copy()
70+
{
71+
return create( this ).build();
72+
}
73+
74+
public static Builder create( final FormFragmentDescriptor descriptor )
75+
{
76+
return new Builder( descriptor );
77+
}
78+
79+
public static Builder create( final FormFragment inline )
80+
{
81+
return new Builder( inline );
82+
}
83+
84+
public static final class Builder
85+
{
86+
private FormFragmentName formFragmentName;
87+
88+
private Builder()
89+
{
90+
}
91+
92+
private Builder( FormFragment source )
93+
{
94+
this.formFragmentName = source.formFragmentName;
95+
}
96+
97+
private Builder( final FormFragmentDescriptor descriptor )
98+
{
99+
this.formFragmentName = descriptor.getName();
100+
}
101+
102+
public Builder formFragment( final FormFragmentDescriptor descriptor )
103+
{
104+
this.formFragmentName = descriptor.getName();
105+
return this;
106+
}
107+
108+
public Builder formFragment( final String name )
109+
{
110+
this.formFragmentName = FormFragmentName.from( name );
111+
return this;
112+
}
113+
114+
public Builder formFragment( final FormFragmentName formFragmentName )
115+
{
116+
this.formFragmentName = formFragmentName;
117+
return this;
118+
}
119+
120+
public FormFragment build()
121+
{
122+
return new FormFragment( this );
123+
}
124+
}
125+
126+
127+
}

modules/core/core-api/src/main/java/com/enonic/xp/form/FormItem.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public Input toInput()
5757
return (Input) this;
5858
}
5959

60-
public InlineMixin toInlineMixin()
60+
public FormFragment toFormFragment()
6161
{
62-
if ( !( this instanceof InlineMixin ) )
62+
if ( !( this instanceof FormFragment ) )
6363
{
6464
throw new IllegalArgumentException(
65-
"This FormItem [" + getName() + "] is not an InlineMixin: " + this.getClass().getSimpleName() );
65+
"This FormItem [" + getName() + "] is not an FormFragment: " + this.getClass().getSimpleName() );
6666
}
67-
return (InlineMixin) this;
67+
return (FormFragment) this;
6868
}
6969

7070
public FormItemSet toFormItemSet()

modules/core/core-api/src/main/java/com/enonic/xp/form/FormItemSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ public Input getInput( final String path )
186186
return formItems.getInput( FormItemPath.from( path ) );
187187
}
188188

189-
public InlineMixin getInlineMixin( final String name )
189+
public FormFragment getFormFragment( final String name )
190190
{
191-
return formItems.getInlineMixin( FormItemPath.from( name ) );
191+
return formItems.getFormFragment( FormItemPath.from( name ) );
192192
}
193193

194194
public static Builder create()

modules/core/core-api/src/main/java/com/enonic/xp/form/FormItemType.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public enum FormItemType
99
INPUT,
1010
FORM_ITEM_SET,
1111
LAYOUT,
12-
MIXIN_REFERENCE,
12+
FORM_FRAGMENT,
1313
FORM_OPTION_SET,
1414
FORM_OPTION_SET_OPTION;
1515

@@ -27,9 +27,9 @@ else if ( FieldSet.class.getSimpleName().equals( value ) )
2727
{
2828
return LAYOUT;
2929
}
30-
else if ( InlineMixin.class.getSimpleName().equals( value ) )
30+
else if ( FormFragment.class.getSimpleName().equals( value ) )
3131
{
32-
return MIXIN_REFERENCE;
32+
return FORM_FRAGMENT;
3333
}
3434
else if ( FormOptionSetOption.class.getSimpleName().equals( value ) )
3535
{

modules/core/core-api/src/main/java/com/enonic/xp/form/FormItems.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ else if ( foundFormItem instanceof final FormOptionSetOption formOptionSetOption
8484
{
8585
return formOptionSetOption.getFormItem( path.asNewWithoutFirstPathElement() );
8686
}
87-
else if ( foundFormItem instanceof InlineMixin )
87+
else if ( foundFormItem instanceof FormFragment )
8888
{
89-
throw new IllegalArgumentException( "Cannot get formItem [" + path + "] because it's past a InlineMixin [" + foundFormItem +
90-
"], resolve the InlineMixin first." );
89+
throw new IllegalArgumentException( "Cannot get formItem [" + path + "] because it's past a FormFragment [" + foundFormItem +
90+
"], resolve the FormFragment first." );
9191
}
9292
else
9393
{
@@ -117,9 +117,9 @@ FormItemSet getFormItemSet( final FormItemPath path )
117117
return typeCast( getFormItem( path ), FormItemSet.class );
118118
}
119119

120-
InlineMixin getInlineMixin( final FormItemPath path )
120+
FormFragment getFormFragment( final FormItemPath path )
121121
{
122-
return typeCast( getFormItem( path ), InlineMixin.class );
122+
return typeCast( getFormItem( path ), FormFragment.class );
123123
}
124124

125125
FormOptionSet getOptionSet( final FormItemPath path )

modules/core/core-api/src/main/java/com/enonic/xp/form/FormValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private static void validateFormItems( final Iterable<FormItem> formItems, Map<F
1818
switch ( item.getType() )
1919
{
2020
case INPUT:
21-
case MIXIN_REFERENCE:
21+
case FORM_FRAGMENT:
2222
case FORM_OPTION_SET_OPTION:
2323
if ( items.containsKey( item.getPath() ) )
2424
{

0 commit comments

Comments
 (0)