Skip to content

Commit

Permalink
Improving code style.
Browse files Browse the repository at this point in the history
  • Loading branch information
milosh-96 committed Jan 16, 2025
1 parent 08d874f commit b9fd301
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
5 changes: 2 additions & 3 deletions Lombiq.UIKit.Widgets/Constants/ContentTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ namespace Lombiq.UIKit.Widgets.Constants;
public static class ContentTypes
{
public const string SlidePart = nameof(SlidePart);
public const string Slide = "Slide";
public const string CarouselWidgetPart = nameof(CarouselWidgetPart);
public const string CarouselWidget = "CarouselWidget";
public const string Slide = nameof(Slide);
public const string CarouselWidget = nameof(CarouselWidget);
}
10 changes: 0 additions & 10 deletions Lombiq.UIKit.Widgets/Handlers/SlidePartHandler.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Lombiq.UIKit.Widgets/Migrations/CarouselWidgetMigrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ await _contentDefinitionManager.AlterPartDefinitionAsync<SlidePart>(part => part
.WithPosition("0")
));

await _contentDefinitionManager.AlterPartDefinitionAsync(ContentTypes.CarouselWidgetPart, part => part
await _contentDefinitionManager.AlterPartDefinitionAsync(nameof(CarouselWidgetPart), part => part
.Attachable()
.WithSettings(new CarouselWidgetPartSettings())
);
Expand All @@ -42,7 +42,7 @@ await _contentDefinitionManager.AlterTypeDefinitionAsync(ContentTypes.Slide, typ

await _contentDefinitionManager.AlterTypeDefinitionAsync(ContentTypes.CarouselWidget, type => type
.Securable()
.WithPart(ContentTypes.CarouselWidgetPart, part => part.WithSettings(new CarouselWidgetPartSettings()))
.WithPart(nameof(CarouselWidgetPart), part => part.WithSettings(new CarouselWidgetPartSettings()))
.WithPart(nameof(BagPart), part => part.WithSettings(new BagPartSettings
{
ContainedContentTypes = [ContentTypes.Slide],
Expand Down
3 changes: 1 addition & 2 deletions Lombiq.UIKit.Widgets/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Lombiq.UIKit.Widgets.Handlers;
using Lombiq.UIKit.Widgets.Migrations;
using Lombiq.UIKit.Widgets.Models;
using Lombiq.UIKit.Widgets.Settings;
Expand All @@ -14,7 +13,7 @@ public sealed class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddContentPart<SlidePart>().AddHandler<SlidePartHandler>();
services.AddContentPart<SlidePart>();
services.AddContentPart<CarouselWidgetPart>();
services.AddScoped<IContentTypePartDefinitionDisplayDriver, CarouselWidgetPartSettingsDisplayDriver>();
services.AddScoped<IDataMigration, CarouselWidgetMigrations>();
Expand Down
5 changes: 3 additions & 2 deletions Lombiq.UIKit.Widgets/Views/Widget-CarouselWidget.cshtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using Lombiq.UIKit.Widgets.Constants
@using Lombiq.UIKit.Widgets.Models
@using Lombiq.UIKit.Widgets.Settings
@using OrchardCore.ContentManagement
Expand All @@ -8,7 +9,7 @@
@inject IContentDefinitionManager _contentDefinitionManager

@{
var typeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync("CarouselWidget");
var typeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(ContentTypes.CarouselWidget);
var part = typeDefinition.Parts.Where(part => part.Name == nameof(CarouselWidgetPart)).FirstOrDefault();
CarouselWidgetPartSettings settings = new CarouselWidgetPartSettings();
if(part != null)
Expand All @@ -22,7 +23,7 @@
var bagItems = ((ContentItem)Model.ContentItem).As<BagPart>().ContentItems.Select(contentItem => contentItem.As<SlidePart>());
var items = new List<IShape>();

bagItems.ForEach(async (slide) => items.Add(await New.Slide(Title: slide.ContentItem.Content.TitlePart.Text, Image: slide.Image.Paths[0])));
bagItems.ForEach(async (slide) => items.Add(await New.Slide(Title: slide.ContentItem.DisplayText, Image: slide.Image.Paths[0])));

var carouselSettings = settings.OptionsJsonSerialized;
}
Expand Down

0 comments on commit b9fd301

Please sign in to comment.