-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add embedded relations #3543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add embedded relations #3543
Conversation
|
I would like to add a way to further customize the view (e.g. change columns, different default sort, page size), but all customization options should be part of the Edit |
|
Filters are not yet working correctly, their code is even more complicated to make "reusable". I might end up just having to extract all these "inline" scripts to proper functions that get called in any view where they are required, but that will be a bigger change than what I originally intended (and I might do that separately, before finishing up this PR). Edit |
|
Should we add an item create button? (Action::NEW) |
|
@seb-jean I‘m not sure yet how exactly I want to handle Actions in general here - maybe something like #3519, and by default render the actions defined for the index view (which in most cases is NEW). My end goal is a kind of fully integrated experience, which probably will involve AJAX modals for create (and possibly edit), amongst other things - but I will try to get the basic functionality in before that 🙂 |
|
Okay, great :). I wish you good luck @lukasluecke. |
This PR was merged into the 3.0.x-dev branch. Discussion ---------- Extract ControllerFactory service This is a pre-requisite for EasyCorp#3476 (MR EasyCorp#3551) and EasyCorp#3352 (see EasyCorp#3543 (comment) for details). Also deduplicated a bit of the shared logic between CrudController and DashboardController creation. Commits ------- ed63197 Extract ControllerFactory service
|
Can this pr be merged into the master? |
|
I hope this feature will be merged soon 💯 |
|
Wow this feature is exactly what i want 😍. |
|
Thanks for this very useful feature ! Hope it will be merged soon !
|
bfavrel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code enable custom switches for BooleanField in list.
| if(searchQuery) { | ||
| $(embedContent).find('table tbody td:not(.actions)').highlight($.merge([searchQuery], searchQuery.split(' '))); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // custom switches | |
| const customSwitches = document.querySelectorAll('td.field-boolean .custom-control.custom-switch input[type="checkbox"]'); | |
| for (i = 0; i < customSwitches.length; i++) { | |
| customSwitches[i].addEventListener('change', function () { | |
| const customSwitch = this; | |
| const newValue = this.checked; | |
| const oldValue = !newValue; | |
| const fieldName = this.closest('.custom-switch').dataset.fieldname; | |
| const target = "{{ ea_url() | |
| .unset('entityId') | |
| .unset('referrer') | |
| .unset('menuIndex') | |
| .unset('submenuIndex') | |
| .setCrudId(crud_id) | |
| .setAction('edit')|raw }}"; | |
| const toggleUrl = target | |
| + "&entityId=" + this.closest('[data-id]').dataset.id | |
| + "&fieldName=" + fieldName | |
| + "&newValue=" + newValue.toString(); | |
| let toggleRequest = $.ajax({ type: "GET", url: toggleUrl, data: {} }); | |
| toggleRequest.done(function(result) {}); | |
| toggleRequest.fail(function() { | |
| // in case of error, restore the original value and disable the toggle | |
| customSwitch.checked = oldValue; | |
| customSwitch.disabled = true; | |
| customSwitch.closest('.custom-switch').classList.add('disabled'); | |
| }); | |
| }); | |
| } | |
|
Thanks for your feedback and contribution. I'm currently very busy in another project which does not use EasyAdmin, but hope that I can find some time to finish this PR and some others around christmas time 🤞 If anyone else wants to pick this up in the meantime feel free to take this over in a new PR as well 🙂 |
|
Hmm patch needs reroll for EA 3.2 it seems. |
2c8d296 to
1c030e2
Compare
|
I would like to add a list of this type for a collection, does it work in easyadmin 4? |
|
does it work in easyadmin 4? this is great |
|
Can this please be implemented? To provide you with a use case for this it's when you need to display a complex entity with one to many relationships in a tab. Say a Subscription being the primary entity and so you create a tab that has Members (OneToMany). Some subscription records for example have 1000s of records and doing CollectionField::new('members') simple does not work due to the volume of fields it has to display. |
|
I'd be willing to invest into this and port this for EA 4 but I have concerns about the acceptance of PRs in general atm. Would that change get accepted or would it be better to create a bundle containing this feature? |
|
Are there any news on this topic? |
|
I can confirm that this one does not work on EA4 and needs updates quite a bit. |
|
I've made a new PR because changes to this for 4.x are extensive and I had to redo some things, there's a lot more work to be done, so I do not see a point keeping this one open any more. 4.x series has a lot more complicated interactions and way it is doing things. |
#3352
It supports most of the functionality, including async initial load, sort, pagination, search and actions (with a custom referrer that redirects you straight back to the embed field).
Currently the "reverse" relation field is automatically removed, if it was part of the target index view (because all values would be the current detail view entity).