Skip to content
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

feature: Advanced distant relationships for the table builder #5359

Merged
merged 59 commits into from
Jan 6, 2023

Conversation

danharrin
Copy link
Member

Replaces #5075.

@danharrin danharrin added the bug Something isn't working label Dec 29, 2022
@danharrin danharrin changed the base branch from 2.x to 3.x December 29, 2022 14:24
@what-the-diff
Copy link
Contributor

what-the-diff bot commented Dec 29, 2022

  • Added a new column type: ListColumn
  • Updated the documentation for all columns to reflect this change
  • Renamed some of the existing docs files so that they are in order by name (this is purely cosmetic)
  • Added support for grouped summaries.
  • Fixed a bug where the state of columns with relationships was not being updated correctly when updating multiple records at once (e.g., using bulk actions).
  • Changed getFormattedState() to formatState(mixed $state). This is because it's more descriptive and also allows us to pass in additional parameters, such as the record itself or other states from related models that may be needed by some formatters/summarizers (such as those used on pivot tables).
  • Added a new column type called ListColumn.
  • Changed the Average summarizer to use an alias for its select statement, so that it can be used in conjunction with other summarizers on the same table column without causing conflicts (e.g., when using both average and sum).
  • Moved formatState() from Concerns/CanFormatState into Summarizer class itself, since all of our current summarizers are formatting their state anyway; this also allows us to remove some unnecessary code duplication between CanFormatState and InteractsWithTableQuery traits where we were evaluating $this->formatUsing(). This change is backwards compatible because any custom classes extending Summarizer will still have access to formatState(), but they'll need to call parent::format($state) if they want formatted output instead of raw data returned by getSelectedValue().
  • Added getSelectStatements method to summarizers.
  • Added selectedState method to summarizers, which allows you to set the selected state of a filter/summarizer manually (for example when using server-side pagination).
  • Changed how relationships are joined in filters and summaries so that they can be nested more than one level deep now (e.g.: user->posts->comments)
  • Added a new method to the Group class called groupQueryUsing.
  • Changed getTitleFromRecordUsing from protected to public in the Column class and added an example of how it can be used in documentation for that same method.
  • Fixed bug where formatted state was not being set correctly on table columns when using formatState(). This is because we were comparing against $column->getFormattedState() instead of $column->formatState($column->getState()) which would always return null since there's no way for us to know what record should be passed into formatColumnValue(). We now pass an empty array as this argument so that if you're using something like Carbon, then calling ->diffForHumans() will work properly without having any errors thrown about missing arguments or anything else weird happening with your formatting logic (which could happen depending on how you have things setup).
  • Updated tests accordingly by adding assertions around these changes and fixing some other minor issues I found while working through all of this stuff related to summaries/groups/etc...

@danharrin danharrin mentioned this pull request Dec 29, 2022
@zepfietje zepfietje added enhancement New feature or request and removed bug Something isn't working labels Jan 2, 2023
@danharrin danharrin merged commit 87f51bc into 3.x Jan 6, 2023
@danharrin danharrin deleted the feat/advanced-distant-relationships branch January 6, 2023 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants