Skip to content

Commit

Permalink
Removing field.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psichorex committed Jan 29, 2024
1 parent 480e3dc commit 8c35cf6
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions Lombiq.HelpfulExtensions/Extensions/Widgets/Migrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ namespace Lombiq.HelpfulExtensions.Extensions.Widgets;

public class Migrations(IContentDefinitionManager contentDefinitionManager) : DataMigration
{
private readonly IContentDefinitionManager _contentDefinitionManager = contentDefinitionManager;

public async Task<int> CreateAsync()
{
await _contentDefinitionManager.AlterTypeDefinitionAsync(ContainerWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(ContainerWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
.WithPart("TitlePart", part => part.WithPosition("0"))
.WithPart("FlowPart", part => part.WithPosition("1"))
);

await _contentDefinitionManager.AlterTypeDefinitionAsync(HtmlWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(HtmlWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
.WithPart("HtmlBodyPart", part => part
Expand All @@ -34,28 +32,28 @@ await _contentDefinitionManager.AlterTypeDefinitionAsync(HtmlWidget, builder =>
)
);

await _contentDefinitionManager.AlterTypeDefinitionAsync(LiquidWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(LiquidWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
.WithPart("LiquidPart", part => part
.WithDisplayName("Liquid Part")
)
);

await _contentDefinitionManager.AlterTypeDefinitionAsync(MenuWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(MenuWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
);

await _contentDefinitionManager.AlterTypeDefinitionAsync(MarkdownWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(MarkdownWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
.WithPart("MarkdownBodyPart", part => part
.WithDisplayName("Markdown Part")
)
);

var contentItemWidgetPartName = await _contentDefinitionManager.AlterPartDefinitionAsync<ContentItemWidget>(builder => builder
var contentItemWidgetPartName = await contentDefinitionManager.AlterPartDefinitionAsync<ContentItemWidget>(builder => builder
.WithField(part => part.ContentToDisplay, field => field
.WithDisplayName("Content to display")
.WithSettings(new ContentPickerFieldSettings
Expand All @@ -67,7 +65,7 @@ await _contentDefinitionManager.AlterTypeDefinitionAsync(MarkdownWidget, builder
.WithField(part => part.GroupId, field => field.WithDisplayName("Group ID"))
);

await _contentDefinitionManager.AlterTypeDefinitionAsync(WidgetTypes.ContentItemWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(WidgetTypes.ContentItemWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
.WithPart(contentItemWidgetPartName)
Expand All @@ -78,7 +76,7 @@ await _contentDefinitionManager.AlterTypeDefinitionAsync(WidgetTypes.ContentItem

public async Task<int> UpdateFrom1Async()
{
await _contentDefinitionManager.AlterTypeDefinitionAsync(ContainerWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(ContainerWidget, builder => builder
.WithPart("TitlePart", part => part.WithPosition("0"))
.WithPart("FlowPart", part => part.WithPosition("1"))
);
Expand All @@ -88,7 +86,7 @@ await _contentDefinitionManager.AlterTypeDefinitionAsync(ContainerWidget, builde

public async Task<int> UpdateFrom2Async()
{
await _contentDefinitionManager.AlterTypeDefinitionAsync(MenuWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(MenuWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
);
Expand All @@ -98,7 +96,7 @@ await _contentDefinitionManager.AlterTypeDefinitionAsync(MenuWidget, builder =>

public async Task<int> UpdateFrom3Async()
{
await _contentDefinitionManager.AlterTypeDefinitionAsync(MarkdownWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(MarkdownWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
.WithPart("MarkdownBodyPart", part => part
Expand All @@ -111,13 +109,13 @@ await _contentDefinitionManager.AlterTypeDefinitionAsync(MarkdownWidget, builder

public async Task<int> UpdateFrom4Async()
{
var contentItemWidgetPartName = await _contentDefinitionManager.AlterPartDefinitionAsync<ContentItemWidget>(builder => builder
var contentItemWidgetPartName = await contentDefinitionManager.AlterPartDefinitionAsync<ContentItemWidget>(builder => builder
.WithField(part => part.ContentToDisplay, field => field.WithDisplayName("Content to display"))
.WithField(part => part.DisplayType, field => field.WithDisplayName("Display type"))
.WithField(part => part.GroupId, field => field.WithDisplayName("Group ID"))
);

await _contentDefinitionManager.AlterTypeDefinitionAsync(WidgetTypes.ContentItemWidget, builder => builder
await contentDefinitionManager.AlterTypeDefinitionAsync(WidgetTypes.ContentItemWidget, builder => builder
.Securable()
.Stereotype(CommonStereotypes.Widget)
.WithPart(contentItemWidgetPartName)
Expand Down

0 comments on commit 8c35cf6

Please sign in to comment.