Skip to content

Commit 5553b6d

Browse files
committed
Table Footer
- Ability to use the header as the footer - Ability to define a custom footer cell per column - Ability to set the footer row classes/id/attributes - Ability to set the footer cell classes/id/attributes - Added isHtml method on the column and replace use of property in views for internal use.
1 parent 41c6034 commit 5553b6d

File tree

18 files changed

+286
-7
lines changed

18 files changed

+286
-7
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
## [1.16.0] - 2021-09-XX
8+
9+
### Added
10+
11+
- Ability to use the header as the footer
12+
- Ability to define a custom footer cell per column
13+
- Ability to set the footer row classes/id/attributes
14+
- Ability to set the footer cell classes/id/attributes
15+
- Added isHtml method on the column and replace use of property in views for internal use.
16+
717
## [1.15.0] - 2021-09-19
818

919
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"require": {
2121
"php": "^7.4|^8.0",
22-
"livewire/livewire": "^2.6.2",
22+
"livewire/livewire": "^2.6.5",
2323
"spatie/laravel-package-tools": "^1.4.3",
2424
"illuminate/contracts": "^8.0"
2525
},
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@props(['text' => null, 'customAttributes' => []])
2+
3+
<td {{ $attributes->merge($customAttributes) }}>
4+
{{ $text ?? $slot }}
5+
</td>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:id="method_exists($this, 'setTableDataId') ? $this->setTableDataId($column, $row) : ''"
88
:customAttributes="method_exists($this, 'setTableDataAttributes') ? $this->setTableDataAttributes($column, $row) : []"
99
>
10-
@if ($column->asHtml)
10+
@if ($column->isHtml())
1111
{{ new \Illuminate\Support\HtmlString($column->formatted($row)) }}
1212
@else
1313
{{ $column->formatted($row) }}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,17 @@
99
<tbody {{ $attributes->only('wire:sortable') }}>
1010
{{ $body }}
1111
</tbody>
12+
13+
@if ($useHeaderAsFooter || $customFooter)
14+
<tfoot>
15+
@if ($useHeaderAsFooter)
16+
<tr>
17+
{{ $head }}
18+
</tr>
19+
@elseif($customFooter)
20+
{{ $foot }}
21+
@endif
22+
</tfoot>
23+
@endif
1224
</table>
1325
</div>

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<x-livewire-tables::bs4.table wire:sortable="{{ $reordering ? $reorderingMethod : '' }}">
1+
<x-livewire-tables::bs4.table
2+
wire:sortable="{{ $reordering ? $reorderingMethod : '' }}"
3+
:useHeaderAsFooter="$useHeaderAsFooter"
4+
:customFooter="$customFooter"
5+
>
26
<x-slot name="head">
37
@if ($reordering)
48
<x-livewire-tables::bs4.table.heading />
@@ -84,4 +88,45 @@
8488
</x-livewire-tables::bs4.table.row>
8589
@endforelse
8690
</x-slot>
91+
92+
@if ($customFooter)
93+
<x-slot name="foot">
94+
<x-livewire-tables::bs4.table.row
95+
wire:loading.class.delay="text-muted"
96+
:class="method_exists($this, 'setFooterRowClass') ? ' ' . $this->setFooterRowClass($rows) : ''"
97+
:id="method_exists($this, 'setFooterRowId') ? $this->setFooterRowId($rows) : ''"
98+
:customAttributes="method_exists($this, 'setFooterRowAttributes') ? $this->setFooterRowAttributes($rows) : []"
99+
>
100+
@if ($reordering)
101+
<x-livewire-tables::bs4.table.footer />
102+
@endif
103+
104+
@if ($bulkActionsEnabled && count($bulkActions))
105+
<x-livewire-tables::bs4.table.footer />
106+
@endif
107+
108+
@foreach($columns as $column)
109+
@if ($column->isVisible())
110+
@continue($columnSelect && ! $this->isColumnSelectEnabled($column))
111+
112+
@if ($column->hasFooter())
113+
<x-livewire-tables::bs4.table.footer
114+
:class="method_exists($this, 'setFooterDataClass') ? $this->setFooterDataClass($column, $rows) : ''"
115+
:id="method_exists($this, 'setFooterDataId') ? $this->setFooterDataId($column, $rows) : ''"
116+
:customAttributes="method_exists($this, 'setFooterDataAttributes') ? $this->setFooterDataAttributes($column, $rows) : []"
117+
>
118+
@if ($column->isHtml())
119+
{{ new \Illuminate\Support\HtmlString($column->footerFormatted($row)) }}
120+
@else
121+
{{ $column->footerFormatted($row) }}
122+
@endif
123+
</x-livewire-tables::bs4.table.footer>
124+
@else
125+
<x-livewire-tables::bs4.table.footer />
126+
@endif
127+
@endif
128+
@endforeach
129+
</x-livewire-tables::bs4.table.row>
130+
</x-slot>
131+
@endif
87132
</x-livewire-tables::bs4.table>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@props(['text' => null, 'customAttributes' => []])
2+
3+
<td {{ $attributes->merge($customAttributes) }}>
4+
{{ $text ?? $slot }}
5+
</td>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:id="method_exists($this, 'setTableDataId') ? $this->setTableDataId($column, $row) : ''"
88
:customAttributes="method_exists($this, 'setTableDataAttributes') ? $this->setTableDataAttributes($column, $row) : []"
99
>
10-
@if ($column->asHtml)
10+
@if ($column->isHtml())
1111
{{ new \Illuminate\Support\HtmlString($column->formatted($row)) }}
1212
@else
1313
{{ $column->formatted($row) }}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,17 @@
99
<tbody {{ $attributes->only('wire:sortable') }}>
1010
{{ $body }}
1111
</tbody>
12+
13+
@if ($useHeaderAsFooter || $customFooter)
14+
<tfoot>
15+
@if ($useHeaderAsFooter)
16+
<tr>
17+
{{ $head }}
18+
</tr>
19+
@elseif($customFooter)
20+
{{ $foot }}
21+
@endif
22+
</tfoot>
23+
@endif
1224
</table>
1325
</div>

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<x-livewire-tables::bs5.table wire:sortable="{{ $reordering ? $reorderingMethod : '' }}">
1+
<x-livewire-tables::bs5.table
2+
wire:sortable="{{ $reordering ? $reorderingMethod : '' }}"
3+
:useHeaderAsFooter="$useHeaderAsFooter"
4+
:customFooter="$customFooter"
5+
>
26
<x-slot name="head">
37
@if ($reordering)
48
<x-livewire-tables::bs5.table.heading />
@@ -86,4 +90,45 @@ class="form-check-input"
8690
</x-livewire-tables::bs5.table.row>
8791
@endforelse
8892
</x-slot>
93+
94+
@if ($customFooter)
95+
<x-slot name="foot">
96+
<x-livewire-tables::bs5.table.row
97+
wire:loading.class.delay="text-muted"
98+
:class="method_exists($this, 'setFooterRowClass') ? ' ' . $this->setFooterRowClass($rows) : ''"
99+
:id="method_exists($this, 'setFooterRowId') ? $this->setFooterRowId($rows) : ''"
100+
:customAttributes="method_exists($this, 'setFooterRowAttributes') ? $this->setFooterRowAttributes($rows) : []"
101+
>
102+
@if ($reordering)
103+
<x-livewire-tables::bs5.table.footer />
104+
@endif
105+
106+
@if ($bulkActionsEnabled && count($bulkActions))
107+
<x-livewire-tables::bs5.table.footer />
108+
@endif
109+
110+
@foreach($columns as $column)
111+
@if ($column->isVisible())
112+
@continue($columnSelect && ! $this->isColumnSelectEnabled($column))
113+
114+
@if ($column->hasFooter())
115+
<x-livewire-tables::bs5.table.footer
116+
:class="method_exists($this, 'setFooterDataClass') ? $this->setFooterDataClass($column, $rows) : ''"
117+
:id="method_exists($this, 'setFooterDataId') ? $this->setFooterDataId($column, $rows) : ''"
118+
:customAttributes="method_exists($this, 'setFooterDataAttributes') ? $this->setFooterDataAttributes($column, $rows) : []"
119+
>
120+
@if ($column->isHtml())
121+
{{ new \Illuminate\Support\HtmlString($column->footerFormatted($row)) }}
122+
@else
123+
{{ $column->footerFormatted($row) }}
124+
@endif
125+
</x-livewire-tables::bs5.table.footer>
126+
@else
127+
<x-livewire-tables::bs5.table.footer />
128+
@endif
129+
@endif
130+
@endforeach
131+
</x-livewire-tables::bs5.table.row>
132+
</x-slot>
133+
@endif
89134
</x-livewire-tables::bs5.table>

0 commit comments

Comments
 (0)