Skip to content

Commit

Permalink
Development to Master (3.3.0) (#1764)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Jul 11, 2024
1 parent 1099d17 commit 3a260dc
Show file tree
Hide file tree
Showing 67 changed files with 1,691 additions and 3,159 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/run-tests-pcov-pull.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: run-tests-pcov-pull

on:
push:
branches:
- 'develop'
- 'development'
- 'master'
pull_request:
branches:
- 'develop'
Expand All @@ -18,7 +23,7 @@ jobs:
laravel: [10]
stability: [prefer-dist]

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

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ phpunit.xml.dist.dev
.history/*
.env
phpunit.xml.bak
phpstan.txt
phpstan.txt
coverage.xml
./tmp/**
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## [v3.3.0] - 2024-07-12
### New Features
- Add new columns (ArrayColumn, AvgColumn, CountColumn, SumColumn) by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1761

## [v3.2.8] - 2024-07-03
### Bug Fixes
- Fix hide bulk actions when empty not reflecting in frontend by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1747
Expand Down
2,894 changes: 0 additions & 2,894 deletions coverage.xml

This file was deleted.

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: 9
weight: 10
---
72 changes: 72 additions & 0 deletions docs/bulk-actions/available-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,75 @@ public function configure(): void
$this->setShouldAlwaysHideBulkActionsDropdownOptionDisabled();
}
```


## setClearSelectedOnSearch

By default, any selected items for Bulk Actions are cleared upon searching. You may configure this behaviour here.

```php
public function configure(): void
{
$this->setClearSelectedOnSearch(true);
}
```


## setClearSelectedOnSearchEnabled

By default, any selected items for Bulk Actions are cleared upon searching. This enables this behaviour.

```php
public function configure(): void
{
$this->setClearSelectedOnSearchEnabled();
}
```


## setClearSelectedOnSearchDisabled

By default, any selected items for Bulk Actions are cleared upon searching. This disables this behaviour, ensuring that selected items are retained after searching.

```php
public function configure(): void
{
$this->setClearSelectedOnSearchDisabled();
}
```


## setClearSelectedOnFilter

By default, any selected items for Bulk Actions are cleared upon filtering. You may configure this behaviour here.

```php
public function configure(): void
{
$this->setClearSelectedOnFilter(true);
}
```


## setClearSelectedOnFilterEnabled

By default, any selected items for Bulk Actions are cleared upon filtering. This enables this behaviour.

```php
public function configure(): void
{
$this->setClearSelectedOnFilterEnabled();
}
```


## setClearSelectedOnFilterDisabled

By default, any selected items for Bulk Actions are cleared upon filtering. This disables this behaviour, ensuring that selected items are retained after filtering.

```php
public function configure(): void
{
$this->setClearSelectedOnFilterDisabled();
}
```
4 changes: 4 additions & 0 deletions docs/column-types/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Column Types
weight: 5
---
22 changes: 22 additions & 0 deletions docs/column-types/array_column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Array Columns (beta)
weight: 1
---

Array columns provide an easy way to work with and display an array of data from a field.

```
ArrayColumn::make('notes', 'name')
->data(fn($value, $row) => ($row->notes))
->outputFormat(fn($index, $value) => "<a href='".$value->id."'>".$value->name."</a>")
->separator('<br />')
->sortable(),
```

### Empty Value
You may define the default/empty value using the "emptyValue" method

```
ArrayColumn::make('notes', 'name')
->emptyValue('Unknown'),
```
14 changes: 14 additions & 0 deletions docs/column-types/avg_column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Avg Columns (beta)
weight: 2
---

Avg columns provide an easy way to display the "Average" of a field on a relation.

```
AvgColumn::make('Average Related User Age')
->setDataSource('users','age')
->sortable(),
```

The "sortable()" callback can accept a callback, or you can use the default behaviour, which calculates the correct field to sort on.
81 changes: 81 additions & 0 deletions docs/column-types/boolean_columns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
title: Boolean Columns
weight: 3
---

Boolean columns are good if you have a column type that is a true/false, or 0/1 value.

For example:

```php
BooleanColumn::make('Active')
```

Would yield:

![Boolean Column](https://imgur.com/LAk6gHY.png)

### Using your own view

If you don't want to use the default view and icons you can set your own:

```php
BooleanColumn::make('Active')
->setView('my.active.view')
```

You will have access to `$component`, `$status`, and `$successValue`.

To help you better understand, this is the Tailwind implementation of BooleanColumn:

```html
@if ($status)
<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">
<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" />
</svg>
@else
<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">
<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" />
</svg>
@endif
```

### Setting the truthy value

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
```

That would swap the colors of the icons in the image above.

### Setting the status value

By default, the `$status` is set to:

```php
(bool)$value === true
```

You can override this functionality:

```php
BooleanColumn::make('Active')
// Note: Parameter `$row` available as of v2.4
->setCallback(function(string $value, $row) {
// Figure out what makes $value true
}),
```

### Different types of boolean display

By default, the BooleanColumn displays icons.

If you would like the BooleanColumn to display a plain Yes/No, you can set:

```php
BooleanColumn::make('Active')
->yesNo()
```
34 changes: 34 additions & 0 deletions docs/column-types/button_group_column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: Button Group Columns
weight: 4
---

Button group columns let you provide an array of LinkColumns to display in a single cell.

```php
ButtonGroupColumn::make('Actions')
->attributes(function($row) {
return [
'class' => 'space-x-2',
];
})
->buttons([
LinkColumn::make('View') // make() has no effect in this case but needs to be set anyway
->title(fn($row) => 'View ' . $row->name)
->location(fn($row) => route('user.show', $row))
->attributes(function($row) {
return [
'class' => 'underline text-blue-500 hover:no-underline',
];
}),
LinkColumn::make('Edit')
->title(fn($row) => 'Edit ' . $row->name)
->location(fn($row) => route('user.edit', $row))
->attributes(function($row) {
return [
'target' => '_blank',
'class' => 'underline text-blue-500 hover:no-underline',
];
}),
]),
```
41 changes: 41 additions & 0 deletions docs/column-types/color_columns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Color Columns
weight: 5
---

Color columns provide an easy way to a Color in a Column

You may pass either pass a CSS-compliant colour as a field
```php
ColorColumn::make('Favourite Colour', 'favourite_color'),
```

Or you may use a Callback
```php
ColorColumn::make('Favourite Colour')
->color(
function ($row) {
if ($row->success_rate < 40)
{
return '#ff0000';
}
else if ($row->success_rate > 90)
{
return '#008000';
}
else return '#ffa500';

}
),
```

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.
```php
ColorColumn::make('Favourite Colour')
->attributes(function ($row) {
return [
'class' => '!rounded-lg self-center',
'default' => true,
];
}),
```
28 changes: 28 additions & 0 deletions docs/column-types/component_column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Component Columns
weight: 6
---

Component columns let you specify a component name and attributes and provides the column value to the slot.

```php
// Before
Column::make("Email", "email")
->format(function ($value) {
return view('components.alert')
->with('attributes', new ComponentAttributeBag([
'type' => Str::endsWith($value, 'example.org') ? 'success' : 'danger',
'dismissible' => true,
]))
->with('slot', $value);
}),

// After
ComponentColumn::make('E-mail', 'email')
->component('email')
->attributes(fn ($value, $row, Column $column) => [
'type' => Str::endsWith($value, 'example.org') ? 'success' : 'danger',
'dismissible' => true,
]),
```

14 changes: 14 additions & 0 deletions docs/column-types/count_column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Count Columns (beta)
weight: 7
---

Count columns provide an easy way to display the "Count" of a relation.

```
CountColumn::make('Related Users')
->setDataSource('users')
->sortable(),
```

The "sortable()" callback can accept a callback, or you can use the default behaviour, which calculates the correct field to sort on.
Loading

0 comments on commit 3a260dc

Please sign in to comment.