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

Access to dynamic Reusable part. #4192

Merged
merged 3 commits into from Sep 9, 2019
Merged

Access to dynamic Reusable part. #4192

merged 3 commits into from Sep 9, 2019

Conversation

jtkech
Copy link
Member

@jtkech jtkech commented Sep 8, 2019

Fixes #4161, so that you can use Model.Content.Named("Reusable1").

  • It was working if the reusable part is created by code but not if created through the admin.

  • When created by code the differentiator is set to partName or {partName}-{shapeType} but when created dynamically it was partTypeName (here the shapeType being ContentPart).

  • So here, for a dynamic part i set the differentiator to partName.

  • Then i added some alternates, e.g based on the contentType => Article-Reusable1.

{
var shapeType = context.DisplayType != "Detail" ? "ContentPart_" + context.DisplayType : "ContentPart";

var shapeResult = new ShapeResult(shapeType, ctx => ctx.ShapeFactory.CreateAsync(shapeType, () => Task.FromResult<IShape>(new ZoneHolding(() => ctx.ShapeFactory.CreateAsync("Zone", Arguments.Empty)))));
shapeResult.Differentiator(contentTypePartDefinition.PartDefinition.Name);
shapeResult.Differentiator(partName);
shapeResult.Location("Content");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @jtkech
For info @jptissot this shapeResult.Location("Content"); is why it's also showing up in SummaryAdmin - this will make it show everywhere, always. For laters when we know what is the best idea for hiding this, we could do another pr to match whatever is decided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean we should do a shapeResult.Location("DetailsAdmin", "-"); too here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's ok here, a dynamic part is composed of fields, so the rendering depends on the field drivers where most of them are not rendered in SummaryAdmin.

E.g if a blog post has a dyn part, when displaying the blog in DetailAdmin, the related list part will be rendered in DetailAdmin but each blogpost will be rendered in SummaryAdmin.

The "problem" is when the blog itself has an additional field / part (dynamic or not), it will be rendered when displaying the blog in DetailAdmin. But i think that there is nothing to do here, this seems to be only due to the field drivers.

Most of the field drivers already do

.Location("SummaryAdmin", "")

Maybe we could add

.Location("DetailAdmin", "")

@sebastienros sebastienros merged commit 74830db into dev Sep 9, 2019
@sebastienros sebastienros deleted the jtkech/reusable branch September 9, 2019 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamically created reusable parts not accessible by name
3 participants