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

[3.x] Flexible table columns #1632

Merged
merged 15 commits into from
May 23, 2022
Merged

[3.x] Flexible table columns #1632

merged 15 commits into from
May 23, 2022

Conversation

haringsrob
Copy link
Contributor

@haringsrob haringsrob commented May 4, 2022

Description

This pr introduces a new way to build custom tables in your modules.

class BlogController extends BaseModuleController
{
    protected $moduleName = 'blogs';

    public function getIndexColumns(): TableColumns
    {
        return TableColumns::make([
            PublishStatus::make(),
            Image::make()
                ->field('thumbnail')
                ->role('cover')
                ->rounded(),
            Text::make()
                ->field('title')
                ->linkCell(function (Model $model) {
                    if ($this->getIndexOption('edit', $model)) {
                        return $this->getModuleRoute($model->id, 'edit');
                    }
                }),
            Text::make()
                ->field('description')
                ->renderHtml()
                ->customRender(function (Blog $model) {
                    return 'Description: <strong>' . $model->description . '</strong>';
                })
                ->optional(),
            Text::make()->field('created_at'),
            Languages::make(),
        ]);
    }
}

Result:

Screenshot 2022-05-04 at 10 35 48

TODO

  • Nested columns
  • Relation fields
  • Browser fields
  • Presenter fields
  • Docs
  • Tests

@haringsrob haringsrob force-pushed the flexible-table-columns branch from 2d45abd to 83cf0da Compare May 10, 2022 07:35
@codecov
Copy link

codecov bot commented May 10, 2022

Codecov Report

Merging #1632 (8b8771d) into 3.x (29c6e29) will increase coverage by 0.01%.
The diff coverage is 65.99%.

@@             Coverage Diff              @@
##                3.x    #1632      +/-   ##
============================================
+ Coverage     58.60%   58.62%   +0.01%     
- Complexity     2773     2824      +51     
============================================
  Files           176      188      +12     
  Lines          8423     8671     +248     
============================================
+ Hits           4936     5083     +147     
- Misses         3487     3588     +101     
Impacted Files Coverage Δ
src/Helpers/helpers.php 77.14% <ø> (ø)
src/Http/Controllers/Admin/GroupController.php 77.41% <ø> (ø)
src/Http/Controllers/Admin/RoleController.php 100.00% <ø> (ø)
src/Http/Controllers/Admin/UserController.php 88.98% <ø> (ø)
src/Models/Feature.php 0.00% <0.00%> (ø)
src/Models/User.php 77.45% <ø> (ø)
src/Services/Listings/Columns/Boolean.php 0.00% <0.00%> (ø)
src/Services/Listings/Columns/Browser.php 0.00% <0.00%> (ø)
src/Services/Listings/Columns/NestedData.php 0.00% <0.00%> (ø)
src/Services/Listings/Columns/Presenter.php 0.00% <0.00%> (ø)
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29c6e29...8b8771d. Read the comment docs.

@haringsrob haringsrob changed the title [3.x][WIP] Flexible table columns [3.x] Flexible table columns May 10, 2022
@haringsrob
Copy link
Contributor Author

Only the docs are left.

@haringsrob haringsrob marked this pull request as ready for review May 10, 2022 13:31
@haringsrob haringsrob merged commit fc0ae37 into 3.x May 23, 2022
@haringsrob haringsrob deleted the flexible-table-columns branch May 23, 2022 06:23
@haringsrob haringsrob mentioned this pull request May 23, 2022
@haringsrob haringsrob added this to the 3.x initial release milestone May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant