maxime-rainville / silverstripe-anyfield

A Silverstripe CMS field that can be used to manage any relation.
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Make the AnyField rendering customisable #15

Open maxime-rainville opened 1 year ago

maxime-rainville commented 1 year ago

We could make the AnyField customsible by allowing people to inject their own component in there.

e.g.: Let's say you use the AnyField and to manage Slides. It would be pretty cool if the AnyField could show the SlideThumbnail.

mfendeksilverstripe commented 10 months ago

@maxime-rainville Adding a note here that it would be great to not only make it injectable but also provide a good default and extensibility options. I suggest to use similar approach as the Summary component of the Elemental module. This allows the display of a single image and a single line of text. This should be enough to easily identify the managed items.

Screenshot 2023-12-13 at 8 55 05 AM

This is the React component Summary

Screenshot 2023-12-13 at 8 56 29 AM

I also suggest to add some interfaces for easy integration with the component. We've done this for elemental but this is custom code as the elemental module doesn't provide this. This is a much cleaner and easier way to managed React properties compared to just passing it via updateBlockSchema() as a array property.

Screenshot 2023-12-13 at 8 56 53 AM

Screenshot 2023-12-13 at 8 57 02 AM

maxime-rainville commented 9 months ago

Yeah I could imagine scenarios where you maybe want to add more esoteric actions that could be performed on an item in the AnyField. Or maybe there's a better way to communicate the information to the user.

Looking at the upload field, if the primary purpose of a specific AnyField is to manage an object tied to an image, displaying a thumbnail of the image would be a big plus.

image

At the same time, I'm not 100% sure if this is a "must have" or a really nice advanced feature we might want to consider. It might be that AnyField provides a generic implementation and if you want to have a custom layout, you have to subclass AnyField to create your own implementation.