Skip to content

Commit 8a04c99

Browse files
committed
Added getTableRowUrlTarget to set row click target based on the row
1 parent b8605d5 commit 8a04c99

File tree

7 files changed

+10
-6
lines changed

7 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
1010

1111
- Thai translation - https://github.com/rappasoft/laravel-livewire-tables/pull/491
1212
- Italian translation - https://github.com/rappasoft/laravel-livewire-tables/pull/493
13+
- Added getTableRowUrlTarget to set row click target based on the row
1314

1415
### Changed
1516

resources/views/bootstrap-4/components/table/row.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@props(['url' => null, 'reordering' => false, 'customAttributes' => []])
1+
@props(['url' => null, 'target' => '_self', 'reordering' => false, 'customAttributes' => []])
22

33
@if (!$reordering && $attributes->has('wire:sortable.item'))
44
@php
@@ -10,7 +10,7 @@
1010
{{ $attributes->merge($customAttributes) }}
1111

1212
@if ($url)
13-
onclick="window.location='{{ $url }}';"
13+
onclick="window.open('{{ $url }}', '{{ $target }}')"
1414
style="cursor:pointer"
1515
@endif
1616
>

resources/views/bootstrap-4/includes/table.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
wire:sortable.item="{{ $row->{$primaryKey} }}"
9797
:reordering="$reordering"
9898
:url="method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
99+
:target="method_exists($this, 'getTableRowUrlTarget') ? $this->getTableRowUrlTarget($row) : ''"
99100
:class="method_exists($this, 'setTableRowClass') ? ' ' . $this->setTableRowClass($row) : ''"
100101
:id="method_exists($this, 'setTableRowId') ? $this->setTableRowId($row) : ''"
101102
:customAttributes="method_exists($this, 'setTableRowAttributes') ? $this->setTableRowAttributes($row) : []"

resources/views/bootstrap-5/components/table/row.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@props(['url' => null, 'reordering' => false, 'customAttributes' => []])
1+
@props(['url' => null, 'target' => '_self', 'reordering' => false, 'customAttributes' => []])
22

33
@if (!$reordering && $attributes->has('wire:sortable.item'))
44
@php
@@ -10,7 +10,7 @@
1010
{{ $attributes->merge($customAttributes) }}
1111

1212
@if ($url)
13-
onclick="window.location='{{ $url }}';"
13+
onclick="window.open('{{ $url }}', '{{ $target }}')"
1414
style="cursor:pointer"
1515
@endif
1616
>

resources/views/bootstrap-5/includes/table.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class="form-check-input"
9797
wire:sortable.item="{{ $row->{$primaryKey} }}"
9898
:reordering="$reordering"
9999
:url="method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
100+
:target="method_exists($this, 'getTableRowUrlTarget') ? $this->getTableRowUrlTarget($row) : ''"
100101
:class="method_exists($this, 'setTableRowClass') ? ' ' . $this->setTableRowClass($row) : ''"
101102
:id="method_exists($this, 'setTableRowId') ? $this->setTableRowId($row) : ''"
102103
:customAttributes="method_exists($this, 'setTableRowAttributes') ? $this->setTableRowAttributes($row) : []"

resources/views/tailwind/components/table/row.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@props(['url' => null, 'reordering' => false, 'customAttributes' => []])
1+
@props(['url' => null, 'target' => '_self', 'reordering' => false, 'customAttributes' => []])
22

33
@if (!$reordering && $attributes->has('wire:sortable.item'))
44
@php
@@ -10,7 +10,7 @@
1010
{{ $attributes->merge($customAttributes) }}
1111

1212
@if ($url)
13-
onclick="window.location='{{ $url }}';"
13+
onclick="window.open('{{ $url }}', '{{ $target }}')"
1414
style="cursor:pointer"
1515
@endif
1616
>

resources/views/tailwind/includes/table.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class="rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150
9999
wire:sortable.item="{{ $row->{$primaryKey} }}"
100100
:reordering="$reordering"
101101
:url="method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
102+
:target="method_exists($this, 'getTableRowUrlTarget') ? $this->getTableRowUrlTarget($row) : ''"
102103
:class="
103104
($index % 2 === 0 ?
104105
'bg-white dark:bg-gray-700 dark:text-white' . (method_exists($this, 'getTableRowUrl') ? ' hover:bg-gray-100' : '') :

0 commit comments

Comments
 (0)