Skip to content

Commit 095b3a1

Browse files
committed
Merge branch 'feature/drag-and-drop' into develop
2 parents 7ce4512 + 9630aed commit 095b3a1

39 files changed

+432
-179
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class UsersTable extends DataTableComponent
6767
- [x] Bootstrap 5 Template
6868
- [x] Sorting By Relationships
6969
- [x] User Column Selection
70+
- [x] Drag & Drop (alpha)
7071
- [ ] Collection/Query Support
7172
- [ ] Test Suite (WIP)
7273
- [ ] Column Search

resources/lang/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"Bulk Actions": "Bulk Actions",
66
"Clear": "Clear",
77
"Columns": "Columns",
8+
"Done Reordering": "Done Reordering",
89
"Filters": "Filters",
910
"Remove filter option": "Remove filter option",
1011
"Remove sort option": "Remove sort option",
@@ -16,6 +17,7 @@
1617
"You are not connected to the internet.": "You are not connected to the internet.",
1718
"You have selected": "You have selected",
1819
"of": "of",
20+
"Reorder": "Reorder",
1921
"results": "results",
2022
"rows": "rows",
2123
"rows, do you want to select all": "rows, do you want to select all",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
@props([
22
'column',
3+
'sortingEnabled' => true,
34
'sortable' => null,
45
'direction' => null,
56
'text' => null,
67
])
78

8-
@unless ($sortable)
9+
@unless ($sortingEnabled && $sortable)
910
<th {{ $attributes->only('class') }}>
1011
{{ $text ?? $slot }}
1112
</th>

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/components/table/table.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<div class="table-responsive">
2-
<table class="table table-striped">
2+
<table {{ $attributes->except('wire:sortable') }} class="table table-striped">
33
<thead>
44
<tr>
55
{{ $head }}
66
</tr>
77
</thead>
88

9-
<tbody>
9+
<tbody {{ $attributes->only('wire:sortable') }}>
1010
{{ $body }}
1111
</tbody>
1212
</table>

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ 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

24-
@if ($showFilterDropdown)
25-
<div class="ml-0 ml-md-3 mb-3 mb-md-0">
25+
@if ($filtersEnabled && $showFilterDropdown)
26+
<div class="{{ $showSearch ? 'ml-0 ml-md-2' : '' }} mb-3 mb-md-0">
2627
@include('livewire-tables::bootstrap-4.includes.filters')
2728
</div>
2829
@endif
2930
</div>
3031

3132
<div class="d-md-flex">
32-
@include('livewire-tables::bootstrap-4.includes.bulk-actions')
33-
@include('livewire-tables::bootstrap-4.includes.column-select')
34-
@include('livewire-tables::bootstrap-4.includes.per-page')
33+
<div>@include('livewire-tables::bootstrap-4.includes.bulk-actions')</div>
34+
<div>@include('livewire-tables::bootstrap-4.includes.column-select')</div>
35+
<div>@include('livewire-tables::bootstrap-4.includes.per-page')</div>
3536
</div>
3637
</div>
3738

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
@if (count($bulkActions))
2-
<div class="dropdown mb-3 mb-md-0 d-block d-md-inline">
3-
<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">
4-
@lang('Bulk Actions')
5-
</button>
1+
@if ($bulkActionsEnabled && count($bulkActions))
2+
<div class="mb-3 mb-md-0">
3+
<div class="dropdown d-block d-md-inline">
4+
<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">
5+
@lang('Bulk Actions')
6+
</button>
67

7-
<div class="dropdown-menu dropdown-menu-right w-100" aria-labelledby="bulkActions">
8-
@foreach($bulkActions as $action => $title)
9-
<a
10-
href="#"
11-
wire:click.prevent="{{ $action }}"
12-
wire:key="bulk-action-{{ $action }}"
13-
class="dropdown-item"
14-
>
15-
{{ $title }}
16-
</a>
17-
@endforeach
8+
<div class="dropdown-menu dropdown-menu-right w-100" aria-labelledby="bulkActions">
9+
@foreach($bulkActions as $action => $title)
10+
<a
11+
href="#"
12+
wire:click.prevent="{{ $action }}"
13+
wire:key="bulk-action-{{ $action }}"
14+
class="dropdown-item"
15+
>
16+
{{ $title }}
17+
</a>
18+
@endforeach
19+
</div>
1820
</div>
1921
</div>
2022
@endif

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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">
3-
<x-livewire-tables::bs4.table.cell colspan="{{ count($bulkActions) ? count($columns) + 1 : count($columns) }}">
3+
<x-livewire-tables::bs4.table.cell colspan="{{ $colspan }}">
44
@if (count($selected) && !$selectAll && !$selectPage)
55
<div>
66
<span>
Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
11
@if ($columnSelect)
2-
<div
3-
x-cloak
4-
x-data="{ open: false }"
5-
@keydown.escape.stop="open = false"
6-
@mousedown.away="open = false"
7-
class="dropdown mb-3 mb-md-0 pl-0 pl-md-3 d-block d-md-inline"
8-
>
9-
<button
10-
@click="open = !open"
11-
class="btn dropdown-toggle d-block w-100 d-md-inline"
12-
type="button"
13-
id="columnSelect"
14-
aria-haspopup="true"
15-
aria-expanded="false"
16-
>
17-
@lang('Columns')
18-
</button>
19-
2+
<div class="mb-3 mb-md-0 pl-0 pl-md-2">
203
<div
21-
class="dropdown-menu dropdown-menu-right w-100"
22-
:class="{'show' : open}"
23-
aria-labelledby="columnSelect"
4+
x-data="{ open: false }"
5+
x-on:keydown.escape.stop="open = false"
6+
x-on:mousedown.away="open = false"
7+
class="dropdown d-block d-md-inline"
248
>
25-
@foreach($columns as $column)
26-
@if ($column->isVisible() && $column->isSelectable())
27-
<div wire:key="columnSelect-{{ $loop->index }}">
28-
<label class="px-2 {{ $loop->last ? 'mb-0' : 'mb-1' }}">
29-
<input
30-
wire:model="columnSelectEnabled"
31-
wire:target="columnSelectEnabled"
32-
wire:loading.attr="disabled"
33-
type="checkbox"
34-
value="{{ $column->column() }}"
35-
/>
36-
<span class="ml-2">{{ $column->text() }}</span>
37-
</label>
38-
</div>
39-
@endif
40-
@endforeach
9+
<button
10+
x-on:click="open = !open"
11+
class="btn dropdown-toggle d-block w-100 d-md-inline"
12+
type="button"
13+
id="columnSelect"
14+
aria-haspopup="true"
15+
x-bind:aria-expanded="open"
16+
>
17+
@lang('Columns')
18+
</button>
19+
20+
<div
21+
class="dropdown-menu dropdown-menu-right w-100 mt-0 mt-md-3"
22+
:class="{'show' : open}"
23+
aria-labelledby="columnSelect"
24+
>
25+
@foreach($columns as $column)
26+
@if ($column->isVisible() && $column->isSelectable())
27+
<div wire:key="columnSelect-{{ $loop->index }}">
28+
<label class="px-2 {{ $loop->last ? 'mb-0' : 'mb-1' }}">
29+
<input
30+
wire:model="columnSelectEnabled"
31+
wire:target="columnSelectEnabled"
32+
wire:loading.attr="disabled"
33+
type="checkbox"
34+
value="{{ $column->column() }}"
35+
/>
36+
<span class="ml-2">{{ $column->text() }}</span>
37+
</label>
38+
</div>
39+
@endif
40+
@endforeach
41+
</div>
4142
</div>
4243
</div>
4344
@endif

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')

0 commit comments

Comments
 (0)