Skip to content

Commit

Permalink
Merge pull request #713 from rappasoft/develop
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
rappasoft authored Apr 12, 2022
2 parents ee303cd + 24e21fb commit 2788f4a
Show file tree
Hide file tree
Showing 38 changed files with 390 additions and 253 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to `laravel-livewire-tables` will be documented in this file

## [Unreleased]

## [2.1.0] - 2022-04-12

### Added

- Turkish Translation - https://github.com/rappasoft/laravel-livewire-tables/pull/686
- Added missing table row click functionality
- Added ability to mark column as unclickable if you need a cell to have another clickable element with clickable rows turned on.

### Changed

- Update filter docs - https://github.com/rappasoft/laravel-livewire-tables/pull/691
- Update getTdAttributes to take 4th missing argument
- Add filters in the config section - https://github.com/rappasoft/laravel-livewire-tables/pull/709
- Update some docs formatting

## [2.0.0] - 2022-03-30

Ground Up Rebuild
Expand Down Expand Up @@ -578,7 +593,8 @@ Ground Up Rebuild

- Initial release

[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.0.0...development
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.1.0...development
[2.1.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.0.0...v2.1.0
[2.0.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.20.1...v2.0.0
[1.21.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.20.1...v1.21.0
[1.20.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.20.0...v1.20.1
Expand Down
2 changes: 1 addition & 1 deletion docs/bulk-actions/_index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Bulk Actions
weight: 8
weight: 9
---
85 changes: 48 additions & 37 deletions docs/columns/available-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ To enable sorting you can chain the `sortable` method on your column:

```php
Column::make('Name')
->sortable()
->sortable(),
```

If you would like more control over the sort behavior of a specific column, you may pass a closure:

```php
Column::make(__('Address'))
->sortable(function(Builder $query, string $direction) {
return $query->orderBy()...
})
->sortable(
fn(Builder $query, string $direction) => $query->orderBy()
),
```

### [Multi-column sorting](../sorting/available-methods#setsinglesortingstatus)
Expand Down Expand Up @@ -55,16 +55,16 @@ To enable searching you can chain the `searchable` method on your column:

```php
Column::make('Name')
->searchable()
->searchable(),
```

You can override the default search query using a closure:

```php
Column::make('Name')
->searchable(function (Builder $query, $searchTerm) {
$query->orWhere(...);
}),
->searchable(
fn(Builder $query, $searchTerm) => $query->orWhere()
),
```

## Formatting
Expand All @@ -79,9 +79,9 @@ If you would like to modify the value of the column, you can chain the `format`

```php
Column::make('Name')
->format(function($value, $row, Column $column) {
return $row->first_name . ' ' . $row->last_name;
})
->format(
fn($value, $row, Column $column) => $row->first_name . ' ' . $row->last_name
),
```

### Rendering HTML
Expand All @@ -90,10 +90,10 @@ If you would like to return HTML from the format method you may:

```php
Column::make('Name')
->format(function($value, $row, Column $column) {
return '<strong>'.$row->first_name . ' ' . $row->last_name.'</strong>';
})
->html()
->format(
fn($value, $row, Column $column) => '<strong>'.$row->first_name . ' ' . $row->last_name.'</strong>'
)
->html(),
```

### Using a view
Expand All @@ -102,16 +102,16 @@ If you would like to render a view for the cell:

```php
Column::make('Name')
->format(function($value, $row, Column $column) {
return view('my.custom.view')->withValue($value);
})
->format(
fn($value, $row, Column $column) => view('my.custom.view')->withValue($value)
),
```

As a shorthand you can use the following:

```php
Column::make('Name')
->view('my.custom.view')
->view('my.custom.view'),
```

You will have access to `$row`, `$value`, and `$column` from within your view.
Expand All @@ -122,29 +122,29 @@ If you have a column that is not associated with a database column, you can chai

```php
Column::make('My one off column')
->label(function($row, Column $column) {
return $this->getSomeOtherValue($row, $column);
})
->label(
fn($row, Column $column) => $this->getSomeOtherValue($row, $column)
),
```

You can return HTML:

```php
Column::make('My one off column')
->label(function($row, Column $column) {
return '<strong>'.$row->this_other_column.'</strong>';
})
->html()
->label(
fn($row, Column $column) => '<strong>'.$row->this_other_column.'</strong>'
)
->html(),
```

You can also return a view:

```php
Column::make('My one off column')
// Note: The view() method is reserved for columns that have a field
->label(function($row, Column $column) {
return view('my.other.view')->withRow($row);
})
->label(
fn($row, Column $column) => view('my.other.view')->withRow($row)
),
```

## Collapsing
Expand All @@ -159,7 +159,7 @@ Collapse on tablet:

```php
Column::make('Name')
->collapseOnTablet()
->collapseOnTablet(),
```

The columns will collapse on tablet and mobile.
Expand All @@ -168,7 +168,7 @@ Collapse on mobile:

```php
Column::make('Name')
->collapseOnMobile()
->collapseOnMobile(),
```

The column will collapse on mobile only.
Expand All @@ -183,7 +183,7 @@ You can customize the name on the pill for the specific column that's being sort

```php
Column::make('Name')
->setSortingPillTitle('Full Name')
->setSortingPillTitle('Full Name'),
```

### Customizing sorting pill directions
Expand All @@ -193,7 +193,7 @@ You can customize the directions on the pill for the specific column that's bein
```php
Column::make('Name')
// Instead of Name: A-Z it will say Name: Asc
->setSortingPillDirections('Asc', 'Desc')
->setSortingPillDirections('Asc', 'Desc'),
```

## Misc.
Expand All @@ -204,7 +204,7 @@ If you need the access the relationships on the model from a format call or some

```php
Column::make('Address', 'address.address')
->eagerLoadRelations() // Adds with('address') to the query
->eagerLoadRelations(), // Adds with('address') to the query
```

### Conditionally Hiding Columns
Expand All @@ -213,10 +213,10 @@ Sometimes you may want to hide columns based on certain conditions. You can use

```php
Column::make('Type', 'user.type')
->hideIf(request()->routeIs('this.other.route'))
->hideIf(request()->routeIs('this.other.route')),

Column::make('Last 4', 'card_last_four')
->hideIf(! auth()->user()->isAdmin())
->hideIf(! auth()->user()->isAdmin()),
```

### Excluding from Column Select
Expand All @@ -226,4 +226,15 @@ If you don't want a column to be able to be turned off from the column select bo
```php
Column::make('Address', 'address.address')
->excludeFromColumnSelect()
```
```

### Preventing clicks if row URL is enabled

If you have row URLs enabled, but you have a specific column you do not want clickable, i.e. in the event there is something else clickable in that row, you may use the following:

```php
Column::make('Name')
->unclickable(),
```

See more in the [clickable rows documentation](../rows/clickable-rows).
2 changes: 1 addition & 1 deletion docs/columns/column-selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you don't want a column to be able to be turned off from the column select bo

```php
Column::make('Address', 'address.address')
->excludeFromColumnSelect()
->excludeFromColumnSelect(),
```

## Available Methods
Expand Down
24 changes: 18 additions & 6 deletions docs/columns/creating-columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ The `columns` method on your component must return an array of Column objects in
```php
public function columns(): array
{
Column::make('Name'),
Column::make('Email'),
return [
Column::make('Name'),
Column::make('Email'),
];
}
```

Expand All @@ -20,13 +22,23 @@ By default, you only need one parameter which acts as the header of the column,
So if you have:

```php
Column::make('Name') // Looks for column `name`
Column::make('Email') // Looks for column `email`
public function columns(): array
{
return [
Column::make('Name'), // Looks for column `name`
Column::make('Email'), // Looks for column `email`
];
}
```

Of course, this won't work in every situation, for example if you have an ID column, Str::snake will convert it to `i_d` which is incorrect. For this situation and any other situation where you want to specify the field name, you can pass it as the second parameter:

```php
Column::make('ID', 'id'),
Column::make('E-mail', 'email'),
public function columns(): array
{
return [
Column::make('ID', 'id'),
Column::make('E-mail', 'email'),
];
}
```
38 changes: 17 additions & 21 deletions docs/columns/other-column-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ If you want the false value to be the green option, you can set:

```php
BooleanColumn::make('Active')
->setSuccessValue(false) // Makes false the 'successful' option
->setSuccessValue(false); // Makes false the 'successful' option
```

That would swap the colors of the icons in the image above.
Expand All @@ -67,7 +67,7 @@ You can override this functionality:
BooleanColumn::make('Active')
->setCallback(function(string $value) {
// Figure out what makes $value true
})
}),
```

## Image Columns
Expand All @@ -76,24 +76,22 @@ Image columns provide a way to display images in your table without having to us

```php
ImageColumn::make('Avatar')
->location(function($row) {
return storage_path('app/public/avatars/' . $row->id . '.jpg');
})
->location(
fn($row) => storage_path('app/public/avatars/' . $row->id . '.jpg')
),
```

You may also pass an array of attributes to apply to the image tag:

```php
ImageColumn::make('Avatar')
->location(function($row) {
return storage_path('app/public/avatars/' . $row->id . '.jpg');
})
->attributes(function($row) {
return [
'class' => 'rounded-full',
'alt' => $row->name . ' Avatar',
];
})
->location(
fn($row) => storage_path('app/public/avatars/' . $row->id . '.jpg')
)
->attributes(fn($row) => [
'class' => 'rounded-full',
'alt' => $row->name . ' Avatar',
]),
```

## Link Columns
Expand All @@ -103,7 +101,7 @@ Link columns provide a way to display HTML links in your table without having to
```php
LinkColumn::make('Action')
->title(fn($row) => 'Edit')
->location(fn($row) => route('admin.users.edit', $row))
->location(fn($row) => route('admin.users.edit', $row)),
```

You may also pass an array of attributes to apply to the `a` tag:
Expand All @@ -112,10 +110,8 @@ You may also pass an array of attributes to apply to the `a` tag:
LinkColumn::make('Action')
->title(fn($row) => 'Edit')
->location(fn($row) => route('admin.users.edit', $row))
->attributes(function($row) {
return [
'class' => 'rounded-full',
'alt' => $row->name . ' Avatar',
];
})
->attributes(fn($row) => [
'class' => 'rounded-full',
'alt' => $row->name . ' Avatar',
]),
```
Loading

0 comments on commit 2788f4a

Please sign in to comment.