-
Notifications
You must be signed in to change notification settings - Fork 340
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
Make parent-template available in schema + pass it all the way to rou… #5337
base: 2.5
Are you sure you want to change the base?
Conversation
@danrot DefaultTemplate is now passed inside the form route attributes, if you have time could you have a look at how to reach the template dropdown? |
@cirykpopeye I just had a quick look at the code and it looks like the default templates are not needed in the frontend (anymore) to me 🙈 I think you can add the |
Thanks @cirykpopeye for picking this up again. When having a rather large website with a few templates this creates confusing with our customers :) |
@nnatter Actually @cirykpopeye has already suggested that to me, and I guess that would work. The reason I would like to try to avoid that, is that if we add the |
The only thing I could imagine is that we return a That would still mean some adjustments in the JS part, namely in the Alternatively we could follow up on the approach to implement getting the |
@danrot I don't directly see another use case for the default template instead of in pages or am I wrong? |
@cirykpopeye Currently there is no other use case in the core, but I don't want to exclude that possibility for anything custom built, therefore I would probably go with the approach also adding it to the metadata response. @sulu/core-team WDYT? |
I now added the defaultTemplate to the metadata request, it now returns that template if it exists and the page template is set. Open for comments :) |
@@ -159,7 +159,7 @@ public function configureViews(ViewCollection $viewCollection): void | |||
]; | |||
|
|||
$routerAttributesToFormRequest = ['parentId', 'webspace']; | |||
$routerAttributesToFormMetdata = ['webspace']; | |||
$routerAttributesToFormMetdata = ['webspace', 'defaultTemplate']; |
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.
This will fragment the cache far more than it is necessary, that is why I suggested in my comment to implement this in a different way. Here we will have a metadata request for every defaultTemplate
that is configured, whereby with the other solution it would always be just a single metadata request.
Any updates on this? We'd still love this functionality :) |
@jordygroote Not that I am aware of, since I haven't heard of @cirykpopeye since my last review, and I didn't have any time to dig into this... Would you like to take over? 🙂 |
@jordygroote @danrot I have no idea how to implement it Danrot's way, I'd still like to complete this as we're in need of this feature also but atm I can't research on how to do this due to lack of time. React is not really my area |
The change I've suggested is that the metadata always returns the same response, so that we don't have to add a query parameter to the URL. As explained above, the problem is that we would have to make the request for every single template then, while we currently have only one of those request during a user's session. That could be achieved by returning a @action handleSchemaTypeResponse = (schemaTypes: ?SchemaTypes) => {
const {
types = {},
defaultType,
defaultTypeByParentType
} = schemaTypes || {};
this.types = types;
this.typesLoading = false;
if (this.hasTypes) {
// this will set the correct type from the server response after it has been loaded
when(
() => !this.resourceStore.loading,
(): void => {
this.setType(this.resourceStore.data[TYPE] || defaultTypeByParentType(this.parentType) || defaultType || Object.keys(this.types)[0]);
}
);
} Mind the two appearances of |
What's in this PR?
Option to provide default template to children of a parent page.
Why?
An artists page should have artist as a default template, makes a lot more sense than always providing a default "Default".
To Do