Skip to content

Commit 3a260dc

Browse files
lrljoeMP70
andauthored
Development to Master (3.3.0) (#1764)
* Adjust for HTML Columns * Update ChangeLog and SP * fix: Apply cursor pointer only on clickable columns when using Bootst… (#1742) * Ensure HTML Columns Return HTML Correctly (#1737) * Adjust for HTML Columns * fix: Apply cursor pointer only on clickable columns when using Bootstrap --------- Co-authored-by: Joe <[email protected]> * Fix styling * Fix hide bulk actions when empty not reflecting in frontend (#1747) * Fix issue with Hide Bulk Actions When Empty not reflecting in frontend * Fix styling * Add development branch into tests --------- Co-authored-by: lrljoe <[email protected]> * Change Return Type for attributes() to static (#1749) * Switch to using Composer\InstalledVersions for AboutCommand to reduce necessity to update ServiceProvider with each update (#1748) * Two improvements to improve typehinting, migrate to larastan/larastan, cleanup of test (#1750) * Add ArrayColumn (BETA) (#1751) * Add ArrayColumn * Fix styling --------- Co-authored-by: lrljoe <[email protected]> * Always hide bulk actions option (#1752) * Add option to "Always Hide Bulk Actions" * Fix styling * Fix test function name clash --------- Co-authored-by: lrljoe <[email protected]> * Optionally disable count for simple pagination (#1755) * Add option for setShouldRetrieveTotalItemCountStatus * Fix styling --------- Co-authored-by: lrljoe <[email protected]> * Update ChangeLog For 3.2.8 Release (#1754) * Update ChangeLog for 3.2.8 * Add release date * Fix phpstan unescaped | * Fix missing typehints (#1757) * Add additional typehints * Fix styling * Add filterCollection typehint * Fix styling * trUrlCallback fixes * Use Collection rather than collect() helper * Fix styling * Add ignore for "Unable to resolve the template type" for Illuminate Collection, add typehint for empty * Add ignore for $model has no defined type (allows for non Eloquent Model to be used longer term) * Adjust concurrency * Adjust Test * Adjust Again * Adjust PHPStan * Add Max Parallel * Use v4 of checkout/cache * Run one at a time * Add Clear Cache Workflow * Fix * Migrate to v4 and adjust workflows * Adjust workflow run rules * Adjust Run-Tests to separate L10 and L11 jobs * Adjust run-tests * Adjust Test * Add Laravel matrix * Adjust Concurrency * Adjust * Adjust Pull Jobs to Match Push jobs --------- Co-authored-by: lrljoe <[email protected]> * Add CountColumn, simpler adding of WithCounts, With (#1761) * Initial Commit * Adjust CountColumn * Add ExtraWiths * Add AggregateColumn * Add SumColumn * Update Docs - Add Column Types Section * Add exceptions for empty data source, add standard tests * Ensure pcov runs on push to master/development/develop * Update to use codecov v4 --------- Co-authored-by: lrljoe <[email protected]> * Add Option to Retain Selected when Searching/Filtering (#1762) * Initial Commit for Retaining Selected * Update Test for Search/Filter --------- Co-authored-by: lrljoe <[email protected]> * Add WireLink Column (#1763) * Add WireLinkColumn * Add Tests for WireLinkColumn --------- Co-authored-by: lrljoe <[email protected]> * Fix styling --------- Co-authored-by: Matt Pickering <[email protected]> Co-authored-by: lrljoe <[email protected]>
1 parent 1099d17 commit 3a260dc

File tree

67 files changed

+1691
-3159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1691
-3159
lines changed

.github/workflows/run-tests-pcov-pull.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: run-tests-pcov-pull
22

33
on:
4+
push:
5+
branches:
6+
- 'develop'
7+
- 'development'
8+
- 'master'
49
pull_request:
510
branches:
611
- 'develop'
@@ -18,7 +23,7 @@ jobs:
1823
laravel: [10]
1924
stability: [prefer-dist]
2025

21-
name: PCOV-PULL - ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
26+
name: PCOV - ${{ matrix.os }} - P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
2227
env:
2328
extensionKey: phpextensions-${{ matrix.os }}-P${{ matrix.php }}-withpcov
2429
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pcov,pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
@@ -86,7 +91,7 @@ jobs:
8691
run: php ./vendor/bin/paratest --cache-directory=".phpunit.cache/code-coverage" --strict-coverage --coverage-clover ./coverage.xml --processes=4
8792

8893
- name: Upload coverage reports to Codecov
89-
uses: codecov/codecov-action@v3
94+
uses: codecov/codecov-action@v4
9095
env:
9196
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
9297
with:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ phpunit.xml.dist.dev
1818
.history/*
1919
.env
2020
phpunit.xml.bak
21-
phpstan.txt
21+
phpstan.txt
22+
coverage.xml
23+
./tmp/**

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `laravel-livewire-tables` will be documented in this file
44

5+
## [v3.3.0] - 2024-07-12
6+
### New Features
7+
- Add new columns (ArrayColumn, AvgColumn, CountColumn, SumColumn) by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1761
8+
59
## [v3.2.8] - 2024-07-03
610
### Bug Fixes
711
- Fix hide bulk actions when empty not reflecting in frontend by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1747

coverage.xml

Lines changed: 0 additions & 2894 deletions
This file was deleted.

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: 9
3+
weight: 10
44
---

docs/bulk-actions/available-methods.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,75 @@ public function configure(): void
274274
$this->setShouldAlwaysHideBulkActionsDropdownOptionDisabled();
275275
}
276276
```
277+
278+
279+
## setClearSelectedOnSearch
280+
281+
By default, any selected items for Bulk Actions are cleared upon searching. You may configure this behaviour here.
282+
283+
```php
284+
public function configure(): void
285+
{
286+
$this->setClearSelectedOnSearch(true);
287+
}
288+
```
289+
290+
291+
## setClearSelectedOnSearchEnabled
292+
293+
By default, any selected items for Bulk Actions are cleared upon searching. This enables this behaviour.
294+
295+
```php
296+
public function configure(): void
297+
{
298+
$this->setClearSelectedOnSearchEnabled();
299+
}
300+
```
301+
302+
303+
## setClearSelectedOnSearchDisabled
304+
305+
By default, any selected items for Bulk Actions are cleared upon searching. This disables this behaviour, ensuring that selected items are retained after searching.
306+
307+
```php
308+
public function configure(): void
309+
{
310+
$this->setClearSelectedOnSearchDisabled();
311+
}
312+
```
313+
314+
315+
## setClearSelectedOnFilter
316+
317+
By default, any selected items for Bulk Actions are cleared upon filtering. You may configure this behaviour here.
318+
319+
```php
320+
public function configure(): void
321+
{
322+
$this->setClearSelectedOnFilter(true);
323+
}
324+
```
325+
326+
327+
## setClearSelectedOnFilterEnabled
328+
329+
By default, any selected items for Bulk Actions are cleared upon filtering. This enables this behaviour.
330+
331+
```php
332+
public function configure(): void
333+
{
334+
$this->setClearSelectedOnFilterEnabled();
335+
}
336+
```
337+
338+
339+
## setClearSelectedOnFilterDisabled
340+
341+
By default, any selected items for Bulk Actions are cleared upon filtering. This disables this behaviour, ensuring that selected items are retained after filtering.
342+
343+
```php
344+
public function configure(): void
345+
{
346+
$this->setClearSelectedOnFilterDisabled();
347+
}
348+
```

docs/column-types/_index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Column Types
3+
weight: 5
4+
---

docs/column-types/array_column.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Array Columns (beta)
3+
weight: 1
4+
---
5+
6+
Array columns provide an easy way to work with and display an array of data from a field.
7+
8+
```
9+
ArrayColumn::make('notes', 'name')
10+
->data(fn($value, $row) => ($row->notes))
11+
->outputFormat(fn($index, $value) => "<a href='".$value->id."'>".$value->name."</a>")
12+
->separator('<br />')
13+
->sortable(),
14+
```
15+
16+
### Empty Value
17+
You may define the default/empty value using the "emptyValue" method
18+
19+
```
20+
ArrayColumn::make('notes', 'name')
21+
->emptyValue('Unknown'),
22+
```

docs/column-types/avg_column.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Avg Columns (beta)
3+
weight: 2
4+
---
5+
6+
Avg columns provide an easy way to display the "Average" of a field on a relation.
7+
8+
```
9+
AvgColumn::make('Average Related User Age')
10+
->setDataSource('users','age')
11+
->sortable(),
12+
```
13+
14+
The "sortable()" callback can accept a callback, or you can use the default behaviour, which calculates the correct field to sort on.

docs/column-types/boolean_columns.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Boolean Columns
3+
weight: 3
4+
---
5+
6+
Boolean columns are good if you have a column type that is a true/false, or 0/1 value.
7+
8+
For example:
9+
10+
```php
11+
BooleanColumn::make('Active')
12+
```
13+
14+
Would yield:
15+
16+
![Boolean Column](https://imgur.com/LAk6gHY.png)
17+
18+
### Using your own view
19+
20+
If you don't want to use the default view and icons you can set your own:
21+
22+
```php
23+
BooleanColumn::make('Active')
24+
->setView('my.active.view')
25+
```
26+
27+
You will have access to `$component`, `$status`, and `$successValue`.
28+
29+
To help you better understand, this is the Tailwind implementation of BooleanColumn:
30+
31+
```html
32+
@if ($status)
33+
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block h-5 w-5 @if ($successValue === true) text-green-500 @else text-red-500 @endif" fill="none" viewBox="0 0 24 24" stroke="currentColor">
34+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
35+
</svg>
36+
@else
37+
<svg xmlns="http://www.w3.org/2000/svg" class="inline-block h-5 w-5 @if ($successValue === false) text-green-500 @else text-red-500 @endif" fill="none" viewBox="0 0 24 24" stroke="currentColor">
38+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
39+
</svg>
40+
@endif
41+
```
42+
43+
### Setting the truthy value
44+
45+
If you want the false value to be the green option, you can set:
46+
47+
```php
48+
BooleanColumn::make('Active')
49+
->setSuccessValue(false); // Makes false the 'successful' option
50+
```
51+
52+
That would swap the colors of the icons in the image above.
53+
54+
### Setting the status value
55+
56+
By default, the `$status` is set to:
57+
58+
```php
59+
(bool)$value === true
60+
```
61+
62+
You can override this functionality:
63+
64+
```php
65+
BooleanColumn::make('Active')
66+
// Note: Parameter `$row` available as of v2.4
67+
->setCallback(function(string $value, $row) {
68+
// Figure out what makes $value true
69+
}),
70+
```
71+
72+
### Different types of boolean display
73+
74+
By default, the BooleanColumn displays icons.
75+
76+
If you would like the BooleanColumn to display a plain Yes/No, you can set:
77+
78+
```php
79+
BooleanColumn::make('Active')
80+
->yesNo()
81+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: Button Group Columns
3+
weight: 4
4+
---
5+
6+
Button group columns let you provide an array of LinkColumns to display in a single cell.
7+
8+
```php
9+
ButtonGroupColumn::make('Actions')
10+
->attributes(function($row) {
11+
return [
12+
'class' => 'space-x-2',
13+
];
14+
})
15+
->buttons([
16+
LinkColumn::make('View') // make() has no effect in this case but needs to be set anyway
17+
->title(fn($row) => 'View ' . $row->name)
18+
->location(fn($row) => route('user.show', $row))
19+
->attributes(function($row) {
20+
return [
21+
'class' => 'underline text-blue-500 hover:no-underline',
22+
];
23+
}),
24+
LinkColumn::make('Edit')
25+
->title(fn($row) => 'Edit ' . $row->name)
26+
->location(fn($row) => route('user.edit', $row))
27+
->attributes(function($row) {
28+
return [
29+
'target' => '_blank',
30+
'class' => 'underline text-blue-500 hover:no-underline',
31+
];
32+
}),
33+
]),
34+
```

docs/column-types/color_columns.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Color Columns
3+
weight: 5
4+
---
5+
6+
Color columns provide an easy way to a Color in a Column
7+
8+
You may pass either pass a CSS-compliant colour as a field
9+
```php
10+
ColorColumn::make('Favourite Colour', 'favourite_color'),
11+
```
12+
13+
Or you may use a Callback
14+
```php
15+
ColorColumn::make('Favourite Colour')
16+
->color(
17+
function ($row) {
18+
if ($row->success_rate < 40)
19+
{
20+
return '#ff0000';
21+
}
22+
else if ($row->success_rate > 90)
23+
{
24+
return '#008000';
25+
}
26+
else return '#ffa500';
27+
28+
}
29+
),
30+
```
31+
32+
You may also specify attributes to use on the div displaying the color, to adjust the size or appearance, this receives the full row. By default, this will replace the standard classes, to retain them, set "default" to true. To then over-ride, you should prefix your classes with "!" to signify importance.
33+
```php
34+
ColorColumn::make('Favourite Colour')
35+
->attributes(function ($row) {
36+
return [
37+
'class' => '!rounded-lg self-center',
38+
'default' => true,
39+
];
40+
}),
41+
```

docs/column-types/component_column.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Component Columns
3+
weight: 6
4+
---
5+
6+
Component columns let you specify a component name and attributes and provides the column value to the slot.
7+
8+
```php
9+
// Before
10+
Column::make("Email", "email")
11+
->format(function ($value) {
12+
return view('components.alert')
13+
->with('attributes', new ComponentAttributeBag([
14+
'type' => Str::endsWith($value, 'example.org') ? 'success' : 'danger',
15+
'dismissible' => true,
16+
]))
17+
->with('slot', $value);
18+
}),
19+
20+
// After
21+
ComponentColumn::make('E-mail', 'email')
22+
->component('email')
23+
->attributes(fn ($value, $row, Column $column) => [
24+
'type' => Str::endsWith($value, 'example.org') ? 'success' : 'danger',
25+
'dismissible' => true,
26+
]),
27+
```
28+

docs/column-types/count_column.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Count Columns (beta)
3+
weight: 7
4+
---
5+
6+
Count columns provide an easy way to display the "Count" of a relation.
7+
8+
```
9+
CountColumn::make('Related Users')
10+
->setDataSource('users')
11+
->sortable(),
12+
```
13+
14+
The "sortable()" callback can accept a callback, or you can use the default behaviour, which calculates the correct field to sort on.

0 commit comments

Comments
 (0)