Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Form Migrations Create() #14272

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 58 additions & 12 deletions src/OrchardCore.Modules/OrchardCore.Forms/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public int Create()
_contentDefinitionManager.AlterPartDefinition("FormElementPart", part => part
.WithDescription("Provides attributes common to all form elements."));

_contentDefinitionManager.AlterPartDefinition("FormElementLabelPart", part => part
.Attachable()
.WithDescription("Provides a way to capture element's label.")
);

_contentDefinitionManager.AlterPartDefinition("FormElementValidationPart", part => part
.Attachable()
.WithDescription("Provides validation options to form elements.")
);

// FormInputElement
_contentDefinitionManager.AlterPartDefinition("FormInputElementPart", part => part
.WithDescription("Provides attributes common to all input form elements."));
Expand All @@ -58,29 +68,65 @@ public int Create()
.WithDescription("Provides input field properties."));

_contentDefinitionManager.AlterTypeDefinition("Input", type => type
.WithPart("FormInputElementPart")
.WithPart("FormElementPart")
.WithPart("InputPart")
.WithPart("FormInputElementPart", part => part
.WithPosition("1")
)
.WithPart("FormElementPart", part => part
.WithPosition("2")
)
.WithPart("FormElementLabelPart", part => part
.WithPosition("3")
)
.WithPart("InputPart", part => part
.WithPosition("4")
)
.WithPart("FormElementValidationPart", part => part
.WithPosition("5")
)
.Stereotype("Widget"));

// TextArea
_contentDefinitionManager.AlterPartDefinition("TextAreaPart", part => part
.WithDescription("Provides text area properties."));

_contentDefinitionManager.AlterTypeDefinition("TextArea", type => type
.WithPart("FormInputElementPart")
.WithPart("FormElementPart")
.WithPart("TextAreaPart")
.WithPart("FormInputElementPart", part => part
.WithPosition("1")
)
.WithPart("FormElementPart", part => part
.WithPosition("2")
)
.WithPart("FormElementLabelPart", part => part
.WithPosition("3")
)
.WithPart("TextAreaPart", part => part
.WithPosition("4")
)
.WithPart("FormElementValidationPart", part => part
.WithPosition("5")
)
.Stereotype("Widget"));

// Select
_contentDefinitionManager.AlterPartDefinition("SelectPart", part => part
.WithDescription("Provides select field properties."));

_contentDefinitionManager.AlterTypeDefinition("Select", type => type
.WithPart("FormInputElementPart")
.WithPart("FormElementPart")
.WithPart("SelectPart")
.WithPart("FormInputElementPart", part => part
.WithPosition("1")
)
.WithPart("FormElementPart", part => part
.WithPosition("2")
)
.WithPart("FormElementLabelPart", part => part
.WithPosition("3")
)
.WithPart("SelectPart", part => part
.WithPosition("4")
)
.WithPart("FormElementValidationPart", part => part
.WithPosition("5")
)
.Stereotype("Widget"));

// Button
Expand Down Expand Up @@ -110,7 +156,7 @@ public int Create()
.Stereotype("Widget"));

// Shortcut other migration steps on new content definition schemas.
return 3;
return 4;
}

// This code can be removed in a later version.
Expand Down Expand Up @@ -142,17 +188,17 @@ public int UpdateFrom2()
return 3;
}

// This code can be removed in a later version.
public int UpdateFrom3()
{
_contentDefinitionManager.AlterPartDefinition("FormElementLabelPart", part => part
.Attachable()
.WithDisplayName("Form Element Label Part")
.WithDescription("Provides a way to capture element's label.")
);

_contentDefinitionManager.AlterPartDefinition("FormElementValidationPart", part => part
.Attachable()
.WithDisplayName("Form Element Validation Part")
.WithDescription("Provides validation options to form elements.")
);

_contentDefinitionManager.AlterTypeDefinition("Select", type => type
Expand Down