sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Own type in configure(Show/List/Export) like in Edit - concept for discussion #6080

Closed wbloszyk closed 4 years ago

wbloszyk commented 4 years ago

Feature Request

When I read https://github.com/sonata-project/SonataAdminBundle/issues/5854#issuecomment-618113138 I got some IDEA. We can allow use Sonata/Bundle/AdminBundle/CRUD/ListType or something like it.

public function configureExportFields(ExportMapper $exportMapper)
    {
        $exportMapper->add('foo', CustomListType::class, [
            'custom_param' => ['param1' => 'test' ]
        ]);
        $exportMapper->add('bar', 'trans');
        $exportMapper->add('baz', null, ['label' => 'special_label']);
    }

User could create own type to generate own field (in list type some params like all records, current record should be return. Return will be html or response (to support ajax). User could create diagrams, statistics or whatever want.

VincentLanglet commented 4 years ago

ExportMapper should be a nice feature. There another comment talking about this: https://github.com/sonata-project/exporter/issues/31#issuecomment-621515615

The main difficulty IMHO would be to implement this in a BC way.

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

VincentLanglet commented 4 years ago

@wbloszyk For show and list, you can provide a custom type foo and then change the following config https://sonata-project.org/bundles/doctrine-orm-admin/3-x/doc/reference/templates.html

To add

sonata_doctrine_orm_admin:
    templates:
        types:
            list:
                foo: 'my_template.html.twig'

So the feature already exists.

For export, I think we can keep only one issue: https://github.com/sonata-project/SonataAdminBundle/issues/5854 I tried some things previously https://github.com/sonata-project/exporter/pull/341, but prefer to delay this to Milestone 5.0

So if it's ok for you I'll close this.

wbloszyk commented 4 years ago

@VincentLanglet I want create reusable Types (sum of some column, count, progres bar etc.). In some of this Type reference to orm/odm is not require and they dont have to override templates. IMO it is work for 5.0 milestone or even later. Lets keep this close for now.