-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add "block.admin_preview" block #7033
Conversation
In order to avoid the workaround near the datagrid sorting, we should find a way to provide this parameter to the admin or the datagrid out of a request context. SonataAdminBundle/src/Admin/AbstractAdmin.php Lines 796 to 806 in 50038ed
SonataAdminBundle/src/Datagrid/Datagrid.php Lines 223 to 229 in 50038ed
|
I don't know, but 👍 to add a way to configure it out of a request context. |
Can you please add a screenshot how this would look like |
Done. |
{% for field_description in admin.list.elements %} | ||
{% if field_description.option('code') == '_select' %} | ||
{# NEXT_MAJOR: Replace the previous condition with the following one #} | ||
{#{% if field_description.option('code') == constant('Sonata\\AdminBundle\\Datagrid\\ListMapper::NAME_SELECT') %}#} |
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.
You mean field_description.name == constant('Sonata\AdminBundle\Datagrid\ListMapper::NAME_SELECT') ?
I think you can already use this condition
<thead> | ||
<tr class="sonata-ba-list-field-header"> | ||
{% for field_description in admin.list.elements %} | ||
{% if field_description.option('code') == constant('Sonata\\AdminBundle\\Datagrid\\ListMapper::NAME_SELECT') %} |
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.
{% if field_description.option('code') == constant('Sonata\\AdminBundle\\Datagrid\\ListMapper::NAME_SELECT') %} | |
{% if field_description.name == constant('Sonata\\AdminBundle\\Datagrid\\ListMapper::NAME_SELECT') %} |
// Setting a request to the admin is a workaround since the admin only | ||
// can handle the "_sort_by" parameter from the query string. | ||
$request = new Request(['filter' => $sortFilters]); | ||
$request->setSession(new Session()); |
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.
Do we really need a session here?
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.
Yes, I'm afraid:
SonataAdminBundle/src/Admin/AbstractAdmin.php
Lines 2695 to 2702 in f9fbd32
public function getListMode() | |
{ | |
if (!$this->hasRequest()) { | |
return 'list'; | |
} | |
return $this->getRequest()->getSession()->get(sprintf('%s.list_mode', $this->getCode()), 'list'); | |
} |
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.
Does the request has a hasSession or something? We could add a check to the code
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.
Sure, I was thinking the same.
Let me check and I'll update the PR if possible.
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.
Here you are: #7080.
771cd83
to
48d4494
Compare
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.
I've rebased and push with --force-with-lease
to use the DatagridInterface
constants.
Thanks ! |
Add "block.admin_preview" block in order to show a preview for admin lists in dashboard
I am targeting this branch, because this feature respects BC.
Rebase from #5530.
This is an example of how this block looks like:
Changelog
To do