collapsible-resource-manager icon indicating copy to clipboard operation
collapsible-resource-manager copied to clipboard

Group nested resources under another resource

Open likeadeckofcards opened this issue 2 years ago • 0 comments

I am looking to take a few related resources and place them in groups to better show the hierarchy of the resources. With this group, I would like to make the top most resource a link to that resource and then have nested resources in an expandable list under that resource. I have found 2 possible ways to come close to this but both seem to lack something the other has.

Option 1 (Use top level resource):

TopLevelResource::make([
    'label' => 'Resource 1',
    'linkTo' => Resource1::class,
    'expanded' => false,
    'resources' => [
        Resource2::class,
    ]
]),

I will probably use this option for the time being. However, when using this option this has to be in the top level list. This is conceivably fine, except you lose the capability to expand or collapse the list.

Option 2 (Use group):

TopLevelResource::make([
    'label' => 'Resources',
    'resources' => [
        OtherResource::class,
        Group::make([
            'linkTo' => Resource1::class,
            'expanded' => true,
            'resources' => [
                Resource2::class,
            ]
        ]),
    ]
]),

Using this option comes closer but has a bigger drawback. This will create the expand and collapse feature that I am looking for with the next data but the Group heading is no longer a link so I would have to duplicate resource1 in the list just to make it so the user can click on it. Also, you lose the plus/minus symbol to denote the expanded/collapsed status.

likeadeckofcards avatar Dec 27 '21 16:12 likeadeckofcards