Conversation
…ropriate props passed into it).
|
Look great! Thanks for taking the time to implement this and submit it! For what it's worth it's a thumbs up from me :) I've tested it out in the playground and it works flawlessly for me. I love the refactor of ArrayField itself. I'd love to go one little step further and rename the existing ArrayField class to something like ArrayFieldBase and create a new ArrayField class with just the two default render methods. It would make it really easy to create a Custom Array Control with different defaults ... just derive from ArrayFieldBase and set the default render methods and your good to go. Just another way of creating your end result, but this time through a custom widget. It means you can override the default ArrayField easily for your entire schema. So even if other people don't want to extend the public interface (via ui:options) the refactor itself to me means the overall patch is great, and you can still achieve the result you want via a Custom Widget. Here is my quick and dirty proof of concept (this ArrayFieldBase.js file is basically the old ArrayField.js file, and the changes to it should be pretty obvious ... set the renders ... change the export and change ArrayField to ArrayFieldBase everywhere): |
|
Good work! Your pull request is a good refactor which allows customizing ArrayFields, which is probably needed by many users. I agree that using the Also, if a user wants to implement a global rendering function for each A template function would solve this. A template function can be build later on on top of the rendering methods that you have provided, or you could implement it in this pull request. If you are willing to polish your pull request further, you could make the ArrayField use a template function. This way there would be a unified way of providing templates functions. The There is already a template field for This is not so important though - the point is that the template would be passed to Like I said earlier - a template field could be implemented later on and your work doesn't conflict with what I have described in #354 (though the code base would look a bit weird with both the |
Update fork.
Reasons for making this change
Currently, with rendering arrays, you're pretty much stuck with the way that the plus, trash, and reorder icons are rendered. With this change, you can pass:
renderandrenderItemto arrays throughui:options. These functions are used to construct the root array and each individual array item. The props passed to the functions contain attributes to reorder elements, add new elements, etc.Let me know your thoughts and feedback! If you'd like any changes, let me know! I made sure that by default, the existing HTML is what's generated.
Checklist
Edit: With this change, I've been able to implement drag and drop for items using
react-dndvery easily. If interested in seeing this written out, let me know! 😁