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

Feature : Define placement in admin #6503

Closed
TFleury opened this issue Jun 24, 2020 · 17 comments · Fixed by #7483
Closed

Feature : Define placement in admin #6503

TFleury opened this issue Jun 24, 2020 · 17 comments · Fixed by #7483
Milestone

Comments

@TFleury
Copy link
Contributor

TFleury commented Jun 24, 2020

We can do quite everything without creating any module or theme, but it's not possible to override default placement.

It could be helpfull to have an UI where you can easily define placement rules.

Either we can add this to Part/Field settings or add a distinct UI (like "Templates" one) where we can define a list of placement rules.

@agriffard
Copy link
Member

@deanmarcussen made a demo yesterday during the meeting to show some improvements to admin placement to use cards and tabs.

It reminded me that, in O1, there is a feature that allows you to edit the placement of each field/part editor by drag and drop.

That would be the kind of UI that I would like to use.

@TFleury
Copy link
Contributor Author

TFleury commented Jun 24, 2020

@agriffard thank you for your answer. I watched the demo and it's nice but still relies on placement file.
How can we take advantage of Tabs, Sidebar or Cards in admin without a placement file ?
I think drag and drop would be too limited compared to what's possible with placement file.

We need to be able to define different placements for editor and for each display type, and maybe to define alternates, wrappers or shape substitutions.

I'm much more to add placement rules to ContentDefinition.

@remesq
Copy link

remesq commented Jun 24, 2020

+1 for something that allows working with "placement" directly in the Admin UI. Maybe something that can open up a text-editor specific to the content type with a preview of how things would look, and then the ability to fiddle around with it and save it.

For example, Lombiq created a ContentTypeMigrations extension in their Lombiq.HelpfulExtensions module that shows a Content Types migration code right in the UI.

Something like that for placement would probably be better as a community module, but would still work to allow for generating proper placement code. So here's to hoping someone can cook something up. :)

@ns8482e
Copy link
Contributor

ns8482e commented Jun 25, 2020

@TFleury It's technically possible. Currently I am using Placement event for certain shapes to change it's placement dynamically based on some condition.

@TFleury TFleury mentioned this issue Jul 6, 2020
1 task
@TFleury
Copy link
Contributor Author

TFleury commented Jul 9, 2020

It's technically possible. Currently I am using Placement event for certain shapes to change it's placement dynamically based on some condition.

@ns8482e I did not find the Placement event. Could you tell me how you dynamically change the placement ?

@sebastienros sebastienros added this to the 1.0.x milestone Jul 9, 2020
@ns8482e
Copy link
Contributor

ns8482e commented Jul 13, 2020

@TFleury ShapeAlterationBuilder has Placement event

public ShapeAlterationBuilder Placement(Func<ShapePlacementContext, PlacementInfo> action)

@ns8482e
Copy link
Contributor

ns8482e commented Jul 13, 2020

@TFleury All I was doing is defining IShapeTableProvider and calling as following,

builder.Describe("My_Shape").
            .Placement( ctx =>
                    {
                        // Get placement override
                        var placement = placementService.GetPlacement(ctx);
                        // if null, then it will use default placement.
                        return placement;
                    });

@TFleury
Copy link
Contributor Author

TFleury commented Jul 21, 2020

@ns8482e Thank you. So, it also relies on IShapeTableProvider and requires to rebuild ShapeTable if we want to add alteration to new shape, unless we add alteration for each possible shape.

@deanmarcussen
Copy link
Member

@TFleury Yes, this is why I wondered on your pr if having something IPlacementResolvers in the FindPlacementDelegate might be an idea, rather than having to rebuild the shape table

Did you look at the way the templates feature is working with the IShapeBindingResolver ?

@TFleury
Copy link
Contributor Author

TFleury commented Jul 21, 2020

I wondered on your pr if having something IPlacementResolvers in the FindPlacementDelegate might be an idea, rather than having to rebuild the shape table

Yes, that's what I was searching for before creating ITenantShapeTableProvider. It seems to be a better way as it don't interfer with ShapeTable and could also allow some Preview (I think it's not possible with IShapeTableProvider).

@ns8482e
Copy link
Contributor

ns8482e commented Jul 21, 2020

@deanmarcussen @TFleury But what stops you using IShapeTableProvider?

@TFleury
Copy link
Contributor Author

TFleury commented Jul 21, 2020

@ns8482e Using IShapeTableProvider requires to rebuild ShapeTable (which is cached per tenant and theme) each time you add or remove a shape alteration, and there is currently no way to expire this cache and rebuild ShapeTable at runtime.

@ns8482e
Copy link
Contributor

ns8482e commented Jul 21, 2020

@TFleury @deanmarcussen May be I am not following you a bit, But I guess this feature is for placement for shapes that are already harvested and available in ShapeTable cache - I guess you are not rebuilding the shape table here.

@TFleury
Copy link
Contributor Author

TFleury commented Jul 21, 2020

@ns8482e Assume that we are on a running tenant and the ShapeTable was already built.
An admin user adds a rule to hide TitlePart (Location="-")

How do you add this rule without rebuilding the ShapeTable ?

It's not possible unless you have already registered a ShapeAlteration on the "TitlePart" (or I missed something).
So, if you want to be able to alter any shape location at runtime - without rebuilding ShapeTable - you need an IShapeTableProvider that registers a conditional ShapeAlteration for every possible shape type.

@ns8482e
Copy link
Contributor

ns8482e commented Jul 21, 2020

How do you add this rule without rebuilding the ShapeTable ?

Correct, I guess you don't need to rebuild the ShapeTable for every dynamic shape added in admin. All we need to do is to register a Function to handle Placement event, Same function for all shapes.

@ns8482e
Copy link
Contributor

ns8482e commented Jul 21, 2020

Another option is have some kind of event hook when BindPlacementAsync is called from BaseDisplayManager which returns Placement either from event handler -or from ShapeTable descriptor.

@jtkech
Copy link
Member

jtkech commented Jul 22, 2020

@ns8482e Yes i think this is the right place to start, then i would say, as @deanmarcussen suggested, by using maybe IPlacementInfoResolver in FindPlacementImpl() used to build the FindPlacementDelegate.

Then a custom resolver using a placement manager service returning placement infos built from a db document, the db document would be cached and invalidated by a signal token as done for the templates manager, when placement infos are built they would be also cached and invalidated by the same token, and so on, as we do for other services.

Note: Then we will have to adapt this service in the distributedCache branch where we have a generic IDocumentManager<> to keep in sync persistent / volatile (only in memory but may be built from other db data) documents / states with a multi level cache including an IDistributedCache, and whithout using a signal token based on a message bus.

Note: Yes a shape table is per theme and per tenant but the shape descriptors are shared across tenants, when a tenant has more features we only build the missing descriptors.

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 a pull request may close this issue.

7 participants