Skip to content

Commit 2788f4a

Browse files
authored
Merge pull request #713 from rappasoft/develop
v2.1.0
2 parents ee303cd + 24e21fb commit 2788f4a

38 files changed

+390
-253
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
## [2.1.0] - 2022-04-12
8+
9+
### Added
10+
11+
- Turkish Translation - https://github.com/rappasoft/laravel-livewire-tables/pull/686
12+
- Added missing table row click functionality
13+
- Added ability to mark column as unclickable if you need a cell to have another clickable element with clickable rows turned on.
14+
15+
### Changed
16+
17+
- Update filter docs - https://github.com/rappasoft/laravel-livewire-tables/pull/691
18+
- Update getTdAttributes to take 4th missing argument
19+
- Add filters in the config section - https://github.com/rappasoft/laravel-livewire-tables/pull/709
20+
- Update some docs formatting
21+
722
## [2.0.0] - 2022-03-30
823

924
Ground Up Rebuild
@@ -578,7 +593,8 @@ Ground Up Rebuild
578593

579594
- Initial release
580595

581-
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.0.0...development
596+
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.1.0...development
597+
[2.1.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.0.0...v2.1.0
582598
[2.0.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.20.1...v2.0.0
583599
[1.21.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.20.1...v1.21.0
584600
[1.20.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.20.0...v1.20.1

docs/bulk-actions/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
title: Bulk Actions
3-
weight: 8
3+
weight: 9
44
---

docs/columns/available-methods.md

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ To enable sorting you can chain the `sortable` method on your column:
1111

1212
```php
1313
Column::make('Name')
14-
->sortable()
14+
->sortable(),
1515
```
1616

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

1919
```php
2020
Column::make(__('Address'))
21-
->sortable(function(Builder $query, string $direction) {
22-
return $query->orderBy()...
23-
})
21+
->sortable(
22+
fn(Builder $query, string $direction) => $query->orderBy()
23+
),
2424
```
2525

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

5656
```php
5757
Column::make('Name')
58-
->searchable()
58+
->searchable(),
5959
```
6060

6161
You can override the default search query using a closure:
6262

6363
```php
6464
Column::make('Name')
65-
->searchable(function (Builder $query, $searchTerm) {
66-
$query->orWhere(...);
67-
}),
65+
->searchable(
66+
fn(Builder $query, $searchTerm) => $query->orWhere()
67+
),
6868
```
6969

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

8080
```php
8181
Column::make('Name')
82-
->format(function($value, $row, Column $column) {
83-
return $row->first_name . ' ' . $row->last_name;
84-
})
82+
->format(
83+
fn($value, $row, Column $column) => $row->first_name . ' ' . $row->last_name
84+
),
8585
```
8686

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

9191
```php
9292
Column::make('Name')
93-
->format(function($value, $row, Column $column) {
94-
return '<strong>'.$row->first_name . ' ' . $row->last_name.'</strong>';
95-
})
96-
->html()
93+
->format(
94+
fn($value, $row, Column $column) => '<strong>'.$row->first_name . ' ' . $row->last_name.'</strong>'
95+
)
96+
->html(),
9797
```
9898

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

103103
```php
104104
Column::make('Name')
105-
->format(function($value, $row, Column $column) {
106-
return view('my.custom.view')->withValue($value);
107-
})
105+
->format(
106+
fn($value, $row, Column $column) => view('my.custom.view')->withValue($value)
107+
),
108108
```
109109

110110
As a shorthand you can use the following:
111111

112112
```php
113113
Column::make('Name')
114-
->view('my.custom.view')
114+
->view('my.custom.view'),
115115
```
116116

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

123123
```php
124124
Column::make('My one off column')
125-
->label(function($row, Column $column) {
126-
return $this->getSomeOtherValue($row, $column);
127-
})
125+
->label(
126+
fn($row, Column $column) => $this->getSomeOtherValue($row, $column)
127+
),
128128
```
129129

130130
You can return HTML:
131131

132132
```php
133133
Column::make('My one off column')
134-
->label(function($row, Column $column) {
135-
return '<strong>'.$row->this_other_column.'</strong>';
136-
})
137-
->html()
134+
->label(
135+
fn($row, Column $column) => '<strong>'.$row->this_other_column.'</strong>'
136+
)
137+
->html(),
138138
```
139139

140140
You can also return a view:
141141

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

150150
## Collapsing
@@ -159,7 +159,7 @@ Collapse on tablet:
159159

160160
```php
161161
Column::make('Name')
162-
->collapseOnTablet()
162+
->collapseOnTablet(),
163163
```
164164

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

169169
```php
170170
Column::make('Name')
171-
->collapseOnMobile()
171+
->collapseOnMobile(),
172172
```
173173

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

184184
```php
185185
Column::make('Name')
186-
->setSortingPillTitle('Full Name')
186+
->setSortingPillTitle('Full Name'),
187187
```
188188

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

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

205205
```php
206206
Column::make('Address', 'address.address')
207-
->eagerLoadRelations() // Adds with('address') to the query
207+
->eagerLoadRelations(), // Adds with('address') to the query
208208
```
209209

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

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

218218
Column::make('Last 4', 'card_last_four')
219-
->hideIf(! auth()->user()->isAdmin())
219+
->hideIf(! auth()->user()->isAdmin()),
220220
```
221221

222222
### Excluding from Column Select
@@ -226,4 +226,15 @@ If you don't want a column to be able to be turned off from the column select bo
226226
```php
227227
Column::make('Address', 'address.address')
228228
->excludeFromColumnSelect()
229-
```
229+
```
230+
231+
### Preventing clicks if row URL is enabled
232+
233+
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:
234+
235+
```php
236+
Column::make('Name')
237+
->unclickable(),
238+
```
239+
240+
See more in the [clickable rows documentation](../rows/clickable-rows).

docs/columns/column-selection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ If you don't want a column to be able to be turned off from the column select bo
1111

1212
```php
1313
Column::make('Address', 'address.address')
14-
->excludeFromColumnSelect()
14+
->excludeFromColumnSelect(),
1515
```
1616

1717
## Available Methods

docs/columns/creating-columns.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ The `columns` method on your component must return an array of Column objects in
88
```php
99
public function columns(): array
1010
{
11-
Column::make('Name'),
12-
Column::make('Email'),
11+
return [
12+
Column::make('Name'),
13+
Column::make('Email'),
14+
];
1315
}
1416
```
1517

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

2224
```php
23-
Column::make('Name') // Looks for column `name`
24-
Column::make('Email') // Looks for column `email`
25+
public function columns(): array
26+
{
27+
return [
28+
Column::make('Name'), // Looks for column `name`
29+
Column::make('Email'), // Looks for column `email`
30+
];
31+
}
2532
```
2633

2734
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:
2835

2936
```php
30-
Column::make('ID', 'id'),
31-
Column::make('E-mail', 'email'),
37+
public function columns(): array
38+
{
39+
return [
40+
Column::make('ID', 'id'),
41+
Column::make('E-mail', 'email'),
42+
];
43+
}
3244
```

docs/columns/other-column-types.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ If you want the false value to be the green option, you can set:
4848

4949
```php
5050
BooleanColumn::make('Active')
51-
->setSuccessValue(false) // Makes false the 'successful' option
51+
->setSuccessValue(false); // Makes false the 'successful' option
5252
```
5353

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

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

7777
```php
7878
ImageColumn::make('Avatar')
79-
->location(function($row) {
80-
return storage_path('app/public/avatars/' . $row->id . '.jpg');
81-
})
79+
->location(
80+
fn($row) => storage_path('app/public/avatars/' . $row->id . '.jpg')
81+
),
8282
```
8383

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

8686
```php
8787
ImageColumn::make('Avatar')
88-
->location(function($row) {
89-
return storage_path('app/public/avatars/' . $row->id . '.jpg');
90-
})
91-
->attributes(function($row) {
92-
return [
93-
'class' => 'rounded-full',
94-
'alt' => $row->name . ' Avatar',
95-
];
96-
})
88+
->location(
89+
fn($row) => storage_path('app/public/avatars/' . $row->id . '.jpg')
90+
)
91+
->attributes(fn($row) => [
92+
'class' => 'rounded-full',
93+
'alt' => $row->name . ' Avatar',
94+
]),
9795
```
9896

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

109107
You may also pass an array of attributes to apply to the `a` tag:
@@ -112,10 +110,8 @@ You may also pass an array of attributes to apply to the `a` tag:
112110
LinkColumn::make('Action')
113111
->title(fn($row) => 'Edit')
114112
->location(fn($row) => route('admin.users.edit', $row))
115-
->attributes(function($row) {
116-
return [
117-
'class' => 'rounded-full',
118-
'alt' => $row->name . ' Avatar',
119-
];
120-
})
113+
->attributes(fn($row) => [
114+
'class' => 'rounded-full',
115+
'alt' => $row->name . ' Avatar',
116+
]),
121117
```

0 commit comments

Comments
 (0)