-
Notifications
You must be signed in to change notification settings - Fork 125
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
NEW Nested gridfield #384
NEW Nested gridfield #384
Conversation
Added loading indicator while nested GridField is being fetched.
Thanks for this! I've added the pull request template to the PR description (did you remove that, or was it just not there when you started the PR?) and filled in some of it for you. I haven't looked at the code itself yet but I've added this to our review column. |
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.
I haven't done a comprehensive review of this, but here are some changes or questions I have so far:
- I think breadcrumbs in the GridField should include the parent record
- Search/filter functionality in nested gridfield doesn't seem to work
- Nested GridField state is not retained - e.g. if I apply a sort to the nested gridfield, click to edit a record, and then click back - the sort order is back to its default state.
- Seems to be no way to edit the nested GridField except through extensions
- The acceptance criterion "the configuration for the nested GridField can be customised by a developer if needed" it a bit vague but IMO it is important to be able to customise it for each
GridField
independently, not just as a global extension
- The acceptance criterion "the configuration for the nested GridField can be customised by a developer if needed" it a bit vague but IMO it is important to be able to customise it for each
- There's an acceptance criterion in the issue about an upper limit for recursion, but I can't find where that's implemented - has that been implemented?
- "When a record doesn't have any nested relations, nested gridfield can be configured not to show."
- Has this been implemented? If so please update the documentation to mention this.
- Similarly if there are other options that haven't been documented, please document them so that I can test them and other developers can make use of them.
- The approach of subclassing
GridFieldDetailForm
seems a bit unusual, it's definitely not what I was expecting. Can you please briefly explain the reasons behind that decision? - Please update the component list in the README.
I have been testing this by adding a nested gridfield to groups in SecurityAdmin
with this code:
<?php
namespace App\NestedExtensions;
use SilverStripe\Core\Extension;
use SilverStripe\Forms\GridField\GridFieldConfig;
use Symbiote\GridFieldExtensions\GridFieldNestedForm;
class NestedGroups extends Extension
{
public function updateGridFieldConfig(GridFieldConfig $config)
{
$config->addComponent(GridFieldNestedForm::create()->setRelationName('Members'));
}
}
SilverStripe\Admin\SecurityAdmin:
extensions:
- App\NestedExtensions\NestedGroups
Also added some php-docs for some public functions.
GridFieldDetailForm anymore. Also changed how Breadcrumbs work.
I now changed how Breadcrumbs work in nested GridFields. It now shows all the parent records, but the back link goes to the top-level instead of the parent record, since having to click back through all parent records to get back to the place you where is a bit confusing. The reason The reason the search component doesn't work is probably due to the fact that the name of the nested GridFields contain "[" and "]" characters. The reason for this is so that I will implement some more UnitTests still, and look at the missing things for the acceptance criterias. |
characters. This makes them work also with the search component.
I now changed the naming schema of the nested GridFields, to not include any "[" or "]" characters, since I got this schema to also work with
Also fixed some linting issues, so CI should now hopefully be green. |
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.
I haven't done a full thorough code review but I have taken a look and highlighted some areas that don't meet our coding standards or which seemed like they could be improved.
I've also done another in-browser test and these are the problems I encountered:
- There's some unexpected state conflict between the nested gridfield and the main gridfield. Steps to reproduce:
- Have at least two items in the main gridfield, both with nested gridfields
- expand both nested gridfields
- Filter the main gridfield (e.g. search for "author") so that there's only one item in the main gridfield.
- Filter the nested gridfield.
- Click on a record in the nested gridfield, then click the back arrow in the breadcrumbs
- Remove the filter on the main gridfield
- Click on a record in the nested gridfield, then click the back arrow in the breadcrumbs
- Notice that the filter (which you cleared just before) is back again.
- Calling
setMaxNestingLevel(3)
on the nested gridfield component doesn't seem to work - though changing the configuration does.- My guess is we need to pass the nesting level down recursively to all child nested gridfield components. We should also disallow developers setting the value in nested components directly, so we don't get a parent with a max nesting level of 3 and a child with a max nesting level of 10 (as a random example).
- I would have expected the nested gridfield settings to be inherited automatically, since this was tested with a
Hierarchy
object (using the example in the PR description). It looks like the reason this didn't happen is because the nested gridfield in this case is set up inGridFieldNestedFormItemRequest
as a fresh instance ofGridFieldNestedForm()
which doesn't look at the settings defined ingetCMSFields()
at all.
- When trying to use sort to move items between nested gridfields, I moved a child group to be a sibling to what was its parent group. This resulted in a popup that said "An error occured while fetching data from the server Please try again later." - and an error in the network tab of the developer console which said
ERROR [UNKNOWN TYPE, ERRNO 400]
. The full error with stack trace was:ERROR [UNKNOWN TYPE, ERRNO 400]: IN POST /admin/security/groups/EditForm/field/groups/nested/1/ItemEditForm/field/groups-GridFieldNestedForm-1/nested/3/ItemEditForm/field/groups-GridFieldNestedForm-1-GridFieldNestedForm-3/nested/5/ItemEditForm/field/groups-GridFieldNestedForm-1-GridFieldNestedForm-3-GridFieldNestedForm-5/reorder?gridState-groups-0=%7B%22GridFieldOrderableRows%22%3A%7B%22enabled%22%3Atrue%7D%2C%22GridFieldNestedForm%22%3A%7B%22SilverStripe-Security-Group-2-Children%22%3Anull%2C%22SilverStripe-Security-Group-1-Children%22%3A1%7D%7D&gridState-groups-GridFieldNestedForm-1-1=%7B%22GridFieldOrderableRows%22%3A%7B%22enabled%22%3Atrue%7D%2C%22GridFieldNestedForm%22%3A%7B%22SilverStripe-Security-Group-3-Children%22%3A1%7D%7D&gridState-groups-GridFieldNestedForm-1-GridFieldNestedForm-3-2=%7B%22GridFieldOrderableRows%22%3A%7B%22enabled%22%3Atrue%7D%2C%22GridFieldNestedForm%22%3A%7B%22SilverStripe-Security-Group-4-Children%22%3Anull%2C%22SilverStripe-Security-Group-5-Children%22%3A1%7D%7D Line in Trace ===== SilverStripe\Logging\DetailedErrorFormatter->output(400, , , , ) DetailedErrorFormatter.php:55 SilverStripe\Logging\DetailedErrorFormatter->format(Array) HTTPResponse.php:417 SilverStripe\Control\HTTPResponse->outputBody() HTTPResponse.php:346 SilverStripe\Control\HTTPResponse->output() index.php:25
- It's worth noting that the group did move to where it was meant to move to, despite the error.
Additionally, please do these actions I previously requested in #384 (review)
- Please add additional documentation so I know what needs to be manually tested and so that developers know what functionality this thing has.
- Please update the component list in the readme
nested gridfields.
Also don't assume the list is filterable.
for nested gridfields, doesn't seem to be needed anymore.
…butes, for better accessibility.
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.
Thank you for your patience and diligent effort on this so far, we're very close now.
Please avoid marking comments as "resolved" - I use them to know what changes I requested last time (and have verified changes were made) vs which changes have already been dealt with in previous reviews.
There's also a minor PHP linting issue to resolve.
In addition to the above, the following from #384 (review) haven't been resolved:
|
I've discovered that if you try to add two |
the same class as the parent record.
if no record is found.
I looked in to the state handling issues you described, and it does seem to me to be the default state handling logic which isn't really up to handling this. The |
There are still outstanding items I've requested above so I'll assume you're still working on this. |
To find it easier to find the requested changes that haven't been made yet:
|
Documentation and readme now updated. |
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.
LGTM, nothing stands out as being obvious wrong in the code and it works great locally.
Thanks for your efforts on this, it's a really fantastic contribution!
This feature will be included in the October minor release.
Description
Provides a
GridFieldComponent
for displaying a nestedGridField
, e.g. forhas_many
relations of the main record.Manual testing steps
Can be tested in a standard Silverstripe 5.1 installation in
SecurityAdmin
for editing groups, by adding the following extension to the project and adding it toSecurityAdmin
via yaml config:Issues
Pull request checklist