Skip to content

Commit 306c61e

Browse files
committed
Update BS4 for new reordering
1 parent d02a13c commit 306c61e

File tree

8 files changed

+40
-17
lines changed

8 files changed

+40
-17
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
@props(['url' => null, 'customAttributes' => []])
1+
@props(['url' => null, 'reordering' => false, 'customAttributes' => []])
2+
3+
@if (!$reordering && $attributes->has('wire:sortable.item'))
4+
@php
5+
$attributes = $attributes->filter(fn ($value, $key) => $key !== 'wire:sortable.item');
6+
@endphp
7+
@endif
28

39
<tr
410
{{ $attributes->merge($customAttributes) }}

resources/views/bootstrap-4/datatable.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class="container-fluid p-0"
1919

2020
<div class="d-md-flex justify-content-between mb-3">
2121
<div class="d-md-flex">
22+
@include('livewire-tables::bootstrap-4.includes.reorder')
2223
@include('livewire-tables::bootstrap-4.includes.search')
2324

2425
@if ($filtersEnabled && $showFilterDropdown)

resources/views/bootstrap-4/includes/bulk-actions.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@if (count($bulkActions))
1+
@if ($bulkActionsEnabled && count($bulkActions))
22
<div class="dropdown mb-3 mb-md-0 d-block d-md-inline">
33
<button class="btn dropdown-toggle d-block w-100 d-md-inline" type="button" id="bulkActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
44
@lang('Bulk Actions')

resources/views/bootstrap-4/includes/bulk-select-row.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@if (count($bulkActions) && (($selectPage && $rows->total() > $rows->count()) || count($selected)))
1+
@if ($bulkActionsEnabled && count($bulkActions) && (($selectPage && $rows->total() > $rows->count()) || count($selected)))
22
<x-livewire-tables::bs4.table.row wire:key="row-message">
33
<x-livewire-tables::bs4.table.cell colspan="{{ $colspan }}">
44
@if (count($selected) && !$selectAll && !$selectPage)

resources/views/bootstrap-4/includes/column-select.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<div
33
x-cloak
44
x-data="{ open: false }"
5-
@keydown.escape.stop="open = false"
6-
@mousedown.away="open = false"
5+
x-on:keydown.escape.stop="open = false"
6+
x-on:mousedown.away="open = false"
77
class="dropdown mb-3 mb-md-0 pl-0 pl-md-3 d-block d-md-inline"
88
>
99
<button
10-
@click="open = !open"
10+
x-on:click="open = !open"
1111
class="btn dropdown-toggle d-block w-100 d-md-inline"
1212
type="button"
1313
id="columnSelect"

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<div
33
x-cloak
44
x-data="{ open: false }"
5-
@keydown.escape.stop="open = false"
6-
@mousedown.away="open = false"
5+
x-on:keydown.escape.stop="open = false"
6+
x-on:mousedown.away="open = false"
77
class="btn-group d-block d-md-inline"
88
>
99
<button
10-
@click="open = !open"
10+
x-on:click="open = !open"
1111
type="button"
1212
class="btn dropdown-toggle d-block w-100 d-md-inline"
1313
>
@@ -22,7 +22,7 @@ class="btn dropdown-toggle d-block w-100 d-md-inline"
2222
<span class="caret"></span>
2323
</button>
2424
<ul
25-
class="dropdown-menu w-200 mt-3"
25+
class="dropdown-menu w-100 mt-md-3"
2626
:class="{'show' : open}"
2727
role="menu"
2828
>
@@ -50,7 +50,7 @@ class="dropdown-menu w-200 mt-3"
5050

5151
<button
5252
wire:click.prevent="resetFilters"
53-
@click="open = false"
53+
x-on:click="open = false"
5454
class="dropdown-item btn text-center"
5555
>
5656
@lang('Clear')
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@if ($reorderEnabled)
2+
<div class="mr-0 mr-md-3 mb-3 mb-md-0">
3+
<button
4+
wire:click="{{ $reordering ? 'disableReordering' : 'enableReordering' }}"
5+
type="button"
6+
class="btn btn-default d-block w-100 d-md-inline"
7+
>
8+
@if ($reordering)
9+
@lang('Done Reordering')
10+
@else
11+
@lang('Reorder')
12+
@endif
13+
</button>
14+
</div>
15+
@endif

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<x-livewire-tables::bs4.table wire:sortable="{{ $reorderingMethod }}">
1+
<x-livewire-tables::bs4.table wire:sortable="{{ $reordering ? $reorderingMethod : '' }}">
22
<x-slot name="head">
33
@if ($reordering)
44
<x-livewire-tables::bs4.table.heading />
55
@endif
66

7-
@if (count($bulkActions))
7+
@if ($bulkActionsEnabled && count($bulkActions))
88
<x-livewire-tables::bs4.table.heading>
99
<input
1010
wire:model="selectPage"
@@ -36,7 +36,7 @@
3636
<x-slot name="body">
3737
@php
3838
$colspan = count($columns);
39-
if (count($bulkActions)) $colspan++;
39+
if ($bulkActionsEnabled && count($bulkActions)) $colspan++;
4040
if ($reordering) $colspan++;
4141
@endphp
4242

@@ -47,20 +47,21 @@
4747
wire:loading.class.delay="text-muted"
4848
wire:key="table-row-{{ $row->{$primaryKey} }}"
4949
wire:sortable.item="{{ $row->{$primaryKey} }}"
50+
:reordering="$reordering"
5051
:url="method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : ''"
5152
:class="method_exists($this, 'setTableRowClass') ? ' ' . $this->setTableRowClass($row) : ''"
5253
:id="method_exists($this, 'setTableRowId') ? $this->setTableRowId($row) : ''"
5354
:customAttributes="method_exists($this, 'setTableRowAttributes') ? $this->setTableRowAttributes($row) : []"
5455
>
5556
@if ($reordering)
5657
<x-livewire-tables::bs4.table.cell wire:sortable.handle>
57-
<svg xmlns="http://www.w3.org/2000/svg" style="width:1em;height:1em;" fill="none" viewBox="0 0 24 24" stroke="currentColor">
58+
<svg xmlns="http://www.w3.org/2000/svg" class="d-inline" style="width:1em;height:1em;" fill="none" viewBox="0 0 24 24" stroke="currentColor">
5859
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
5960
</svg>
6061
</x-livewire-tables::bs4.table.cell>
6162
@endif
6263

63-
@if (count($bulkActions))
64+
@if ($bulkActionsEnabled && count($bulkActions))
6465
<x-livewire-tables::bs4.table.cell>
6566
<input
6667
wire:model="selected"
@@ -76,7 +77,7 @@
7677
</x-livewire-tables::bs4.table.row>
7778
@empty
7879
<x-livewire-tables::bs4.table.row>
79-
<x-livewire-tables::bs4.table.cell colspan="{{ count($bulkActions) ? count($columns) + 1 : count($columns) }}">
80+
<x-livewire-tables::bs4.table.cell :colspan="$colspan">
8081
@lang($emptyMessage)
8182
</x-livewire-tables::bs4.table.cell>
8283
</x-livewire-tables::bs4.table.row>

0 commit comments

Comments
 (0)