-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Replace dynamic ContentCard shapes with strongly typed shapes #18642
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
base: main
Are you sure you want to change the base?
Conversation
…to use them Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
…ting Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
|
@copilot there is an error when trying to add a widget to the FlowPart: |
…ties in ContentCardShapes Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
... Fixed in commit adfa0f5. The issue was that |
|
Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
|
... Fixed in commit 6af2cb8. The issue was that the |
|
I'd someone else to try this as I haven't used these two parts in a while. /cc @buzznick |
| @model BagPartEditViewModel | ||
| @inject IContentManager ContentManager | ||
| @inject OrchardCore.ContentManagement.Display.IContentItemDisplayManager ContentItemDisplayManager | ||
| @inject OrchardCore.DisplayManagement.IShapeFactory ShapeFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shape factory is already available in the Factory property of the base class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot The shape factory is already available in the Factory property of the base class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit ba14487. Removed @inject IShapeFactory ShapeFactory from all views and now using the Factory property that's available in the RazorPage base class.
| <ProjectReference Include="..\..\OrchardCore\OrchardCore.Liquid.Abstractions\OrchardCore.Liquid.Abstractions.csproj" /> | ||
| <ProjectReference Include="..\..\OrchardCore\OrchardCore.Module.Targets\OrchardCore.Module.Targets.csproj" /> | ||
| <ProjectReference Include="..\..\OrchardCore\OrchardCore.ResourceManagement\OrchardCore.ResourceManagement.csproj" /> | ||
| <ProjectReference Include="..\OrchardCore.Widgets\OrchardCore.Widgets.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module to Module references should not be done. The shape classes need to go to a common 'Core' or 'Abstractions' project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Module to Module references should not be done. The shape classes need to go to a common 'Core' or 'Abstractions' project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit ba14487. Moved the ContentCard shape classes from OrchardCore.Widgets/Models to OrchardCore.Flows.Core/Models. Removed the module-to-module reference from Flows to Widgets. Both modules now reference the shared OrchardCore.Flows.Core project.
… from base class Co-authored-by: sebastienros <1165805+sebastienros@users.noreply.github.com>
|
@gvkries should the shapes not be in Flow but in a new Widgets.Core intead? |
Conceptually yes, but adding another project? IMHO, we already have too many projects, maybe we should consolidate those types into a single assembly. What about |


Description
Dynamic shape creation using
_shapeFactory.New.ContentCard(...)has been replaced with strongly typed shapes usingCreateAsync<T>for better performance and type safety.Changes
New shape classes in
OrchardCore.Flows.Core/Models:ContentCardShape- encapsulates all ContentCard properties includingCanInsertContentCardFieldsEditShape- for ContentCard_Fields_Edit shapeContentCardFrameShape- for ContentCard_Frame wrapper shapeUpdated shape creation pattern:
Controllers:
Views:
Shape handler updates:
ContentCardShapes.csto properly access strongly typed shape properties by casting to the shape class first (e.g.,(shape as ContentCardShape)?.Property) with fallback toGetPropertyfor backward compatibilityBug fixes:
GetPropertyCanInsertproperty toContentCardShapeclass (defaults totrue) - required byContentCard-FlowPart.Edit.cshtmlandContentCard-WidgetsListPart.Edit.cshtmlviewsArchitecture improvements:
OrchardCore.Widgets/ModelstoOrchardCore.Flows.Core/Modelsto follow proper architecture pattern where module-to-module references are not allowedOrchardCore.Widgetsreference fromOrchardCore.Flowsmodule. Both modules now properly reference the sharedOrchardCore.Flows.Coreproject@inject IShapeFactory ShapeFactorydeclarations from all views and use theFactoryproperty available in theRazorPagebase class insteadOrchardCore.Flows.Coreproject (ContentTypes.Abstractions, DisplayManagement.Abstractions)using OrchardCore.DisplayManagement;to ViewImports for extension method resolutionModules affected
OrchardCore.Flows.Core(new shape classes)OrchardCore.Flows(1 controller, 2 views, project references)OrchardCore.Widgets(1 controller, 3 views, shape handler, project references)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.