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

code-creeper/laravel-livewire-tables tests #79

Open
wants to merge 21 commits into
base: code-creeper
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
70bf26b
Merge pull request #1528 from rappasoft/new-develop
lrljoe Nov 3, 2023
6b07b80
Merge pull request #1530 from rappasoft/new-develop
lrljoe Nov 3, 2023
f0a32bc
Merge pull request #1532 from rappasoft/develop
lrljoe Nov 3, 2023
b554a83
Merge pull request #1535 from rappasoft/develop
lrljoe Nov 3, 2023
419c2ff
Merge pull request #1541 from rappasoft/develop
lrljoe Nov 5, 2023
df31c86
Merge pull request #1561 from rappasoft/develop
lrljoe Nov 19, 2023
aec86d1
Merge pull request #1579 from rappasoft/develop
lrljoe Dec 4, 2023
2bfe6df
Merge pull request #1591 from rappasoft/develop
lrljoe Dec 9, 2023
e2b5c4f
Merge pull request #1610 from rappasoft/develop
lrljoe Dec 26, 2023
269c86b
Merge pull request #1617 from rappasoft/develop
lrljoe Dec 29, 2023
669269f
Merge pull request #1619 from rappasoft/develop
lrljoe Dec 29, 2023
2c0d9c9
Update ChangeLog - Showing as UNRELEASED rather than 3.1.8 (#1621)
lrljoe Dec 29, 2023
9b05c64
Merge branch 'develop' into master
lrljoe Jan 4, 2024
d49c0c7
Merge pull request #1667 from rappasoft/develop
lrljoe Feb 24, 2024
d07354a
Merge pull request #1672 from rappasoft/develop
lrljoe Feb 29, 2024
67c6489
Merge pull request #1676 from rappasoft/develop
lrljoe Mar 1, 2024
05a3d41
Fix for Collapsing Columns - Multiple Tables, Single Page (#1678) (#1…
lrljoe Mar 2, 2024
31915d5
Merge pull request #1707 from rappasoft/develop
lrljoe Apr 30, 2024
2bd477e
Fix ChangeLog, SP (#1710)
lrljoe Apr 30, 2024
d149957
Add the html render support for the LinkColumn
code-creeper May 31, 2024
c0c60a9
Merge branch 'code-creeper' into master
lrljoe Jun 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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

=======
## [v3.2.6] - UNRELEASED
### New Features
- Add configurable wire:model for filters by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1699
Expand All @@ -15,7 +14,6 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
- Migrate to PHPUnit Attributes rather than Doc Comments by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1727
- Remove broken test by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1719


## [v3.2.5] - 2024-04-30
### New Features
- Add setConfigurableArea by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1706
Expand Down
9 changes: 9 additions & 0 deletions docs/columns/available-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ Column::make('Name')
->html(),
```

And this method is also available for the [LinkColumn](./other-column-types#content-link-columns)

```php
LinkColumn::make('Name', 'name')
->title(fn ($row) => 'Title')
->location(fn ($row) => "#$row->id")
->html(),
```

### Using a view

If you would like to render a view for the cell:
Expand Down
8 changes: 7 additions & 1 deletion resources/views/includes/columns/link.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<a href="{{ $path }}" {!! count($attributes) ? $column->arrayToAttributes($attributes) : '' !!}>{{ $title }}</a>
<a href="{{ $path }}" {!! count($attributes) ? $column->arrayToAttributes($attributes) : '' !!}>
@if($column->isHtml())
{!! $title !!}
@else
{{ $title }}
@endif
</a>
30 changes: 30 additions & 0 deletions tests/Views/Columns/LinkColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,34 @@ public function test_can_render_field_if_title_and_location_callback(): void

$this->assertNotEmpty($column);
}

/** @test */
public function can_check_ishtml_from_html_column(): void
{
$column = LinkColumn::make('Name', 'name')
->title(fn ($row) => 'Title')
->location(fn ($row) => "#$row->id")
->html();

$this->assertTrue($column->isHtml());
}

/** @test */
public function can_get_html_from_html_label_column(): void
{
$column = LinkColumn::make('Name', 'name')
->title(fn ($row) => '<strong>My Label</strong>')
->location(fn ($row) => "#$row->id")
->html();

$rows = $this->basicTable->getRows();
$location = '#'.$rows->first()->id;
$htmlString = new \Illuminate\Support\HtmlString('<a href="'.$location.'"><strong>My Label</strong></a>');

// Removing every whitespace and line break for the comparison
$expectedHtml = preg_replace('/\s+/', '', $htmlString->toHtml());
$actualHtml = preg_replace('/\s+/', '', $column->getContents($rows->first())->toHtml());

$this->assertSame($expectedHtml, $actualHtml);
}
}
Loading