Closed webdevilopers closed 8 years ago
Also interested.
Is mosaic disabled global option already present for now? And per class?
For the moment, I found an ugly (for my opinion) method to disable mosoaic on one admin class:
/**
* @param ListMapper $listMapper
*/
protected function configureListFields(ListMapper $listMapper)
{
unset($this->listModes['mosaic']);
$listMapper
// [...]
;
}
But I have 49 admin's classes on my project, It will be very painful to add this on each class.
@rande mentioned it on the 2.4 wish list under "Mozaic view list" https://github.com/sonata-project/SonataAdminBundle/issues/2406 @pulzarraider has tagged this issue for that milestone.
Not sure if this means that a configurable option will be available.
But there were some changes on the layout: https://github.com/sonata-project/SonataAdminBundle/issues/1723
i added a custom BaseAdmin and added this method:
{
/**
* @param ListMapper $listMapper
*/
protected function configureListFields(ListMapper $listMapper)
{
unset($this->listModes['mosaic']);
}
and in my Admin:
/**
* @param ListMapper $listMapper
*/
protected function configureListFields(ListMapper $listMapper)
{
parent::configureListFields($listMapper);
// ...
}
but if you manipulate the url... you are allowed to visit the mosaic view...
Any update on this? Manipulating the URL still works.
Again.... Any update?
For now, i have a javascript extending standard_layout.html.twig with:
$(".fa.fa-th-large.fa-fw").parent().parent().remove();
But please, any better solution?
I think
$this->setListMode('list');
could be a temporary solution. This disables any other mode(like tree) or custom ones, if you've made any. How's that?
@OskarStark or you can do it right in the constructor of BaseAdmin:
public function __construct($code, $class, $baseControllerName)
{
parent::__construct($code, $class, $baseControllerName);
// Disable mosaic list mode
unset($this->listModes['mosaic']);
}
this is a better solution by far @kriodev 👍
but anyway we should add a configuration option, maybe it would be better to deactivate it and make it opt-in
@OskarStark or you can do it right in the constructor of BaseAdmin:
@kriodev Maybe something can be done on the AdminExtension too.
@OskarStark configuration option would be perfect indeed!
@Soullivaneuh BaseAdmin is part of my bundle and it extends \Sonata\AdminBundle\Admin\Admin if that is what you meant.
@kriodev No I'm just saying that you may do something on class extending AdminExtension
to avoid repetition.
@OskarStark @Soullivaneuh I just realized that visibility of listModes property is set to protected, so there is even more elegant solution for BaseAdmin class without extending the constructor:
use Sonata\AdminBundle\Admin\Admin;
class BaseAdmin extends Admin
{
protected $listModes = [
'list' => array(
'class' => 'fa fa-list fa-fw',
),
];
}
@Soullivaneuh @OskarStark hello. I created a small PR #3822 to add parameter in configuration file to show/hide mosaic button.
Related to my question here: https://github.com/sonata-project/SonataAdminBundle/issues/2461#issuecomment-60731284
there seems to be no option (at least not documented yet in http://www.sonata-project.org/bundles/admin/master/doc/cookbook/recipe_customizing_a_mosaic_list.html) to disable the
mosaic list
view globally (except overriding the template) or oer Admin Class.Are these options of interest?