Skip to content

Commit f446222

Browse files
committed
CollapseRework2
1 parent e03d795 commit f446222

File tree

10 files changed

+28
-85
lines changed

10 files changed

+28
-85
lines changed

resources/js/laravel-livewire-tables.js

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -415,50 +415,6 @@ document.addEventListener('alpine:init', () => {
415415
}
416416
}));
417417

418-
Alpine.data('booleanFilterLatest', (data) => ({
419-
booleanFilterKey: data.filterKey,
420-
booleanFilterDefaultValue: data.defaultValue,
421-
switchOn: false,
422-
value: false,
423-
toggleStatus()
424-
{
425-
let tempValue = Boolean(Number(this.$wire.get('filterComponents.'+this.booleanFilterKey) ?? this.value));
426-
let newBoolean = !tempValue;
427-
this.switchOn = this.value = newBoolean;
428-
return Number(newBoolean);
429-
},
430-
toggleStatusWithUpdate()
431-
{
432-
let newValue = this.toggleStatus();
433-
this.$wire.set('filterComponents.'+this.booleanFilterKey, newValue);
434-
},
435-
toggleStatusWithReset()
436-
{
437-
let newValue = this.toggleStatus();
438-
this.$wire.call('resetFilter',this.booleanFilterKey);
439-
},
440-
setSwitchOn(val)
441-
{
442-
let number = Number(val ?? 0);
443-
this.switchOn = Boolean(number);
444-
},
445-
init() {
446-
447-
this.$nextTick(() => {
448-
this.value = this.$wire.get('filterComponents.'+this.booleanFilterKey) ?? this.booleanFilterDefaultValue;
449-
this.setSwitchOn(this.value ?? 0);
450-
});
451-
452-
this.listeners.push(
453-
Livewire.on('filter-was-set', (detail) => {
454-
if(detail.tableName == this.tableName && detail.filterKey == this.booleanFilterKey) {
455-
this.switchOn = detail.value ?? this.booleanFilterDefaultValue;
456-
}
457-
})
458-
);
459-
}
460-
}));
461-
462418

463419

464420
Alpine.data('numberRangeFilter', (wire, filterKey, parentElementPath, filterConfig, childElementRoot) => ({

resources/js/laravel-livewire-tables.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/views/components/table/collapsed-columns.blade.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
@aware([ 'tableName', 'primaryKey','isTailwind','isBootstrap', 'collapsingColumnDetails'])
2-
@props(['row', 'rowIndex'])
1+
@aware([ 'tableName', 'primaryKey','isTailwind','isBootstrap', 'collapsingColumnDetails', 'rowPk','row', 'rowIndex','customAttributes', 'hasCollapsingColumns'])
32

4-
@if ($this->collapsingColumnsAreEnabled() && $this->hasCollapsedColumns())
5-
@php($customAttributes = $this->getTrAttributes($row, $rowIndex))
3+
@if ($hasCollapsingColumns)
64
<tr x-data
75
@toggle-row-content.window="($event.detail.tableName === '{{ $tableName }}' && $event.detail.row === {{ $rowIndex }}) ? $el.classList.toggle('{{ $isBootstrap ? 'd-none' : 'hidden' }}') : null"
86
{{
97
$attributes->merge([
108
'wire:loading.class.delay' => 'opacity-50 dark:bg-gray-900 dark:opacity-60',
11-
'wire:key' => $tableName.'-row-'.$row->{$primaryKey}.'-collapsed-contents',
9+
'wire:key' => $tableName.'-row-'.$rowPk.'-collapsed-contents',
1210
])
1311
->merge($customAttributes)
1412
->class($isTailwind ? [
@@ -29,7 +27,7 @@
2927

3028

3129
@tableloop($collapsingColumnDetails as $colIndex => $columnData)
32-
<div wire:key="{{ $tableName }}-row-{{ $row->{$primaryKey} }}-collapsed-contents-{{ $colIndex }}"
30+
<div wire:key="{{ $tableName }}-row-{{ $rowPk }}-collapsed-contents-{{ $colIndex }}"
3331
x-data="{ value: '',
3432
init() {
3533
$nextTick(() => {
@@ -45,7 +43,7 @@
4543
'd-block mb-2',
4644
'd-sm-none' => !$columnData['shouldCollapseAlways'] && !$columnData['shouldCollapseOnTablet'] && !$columnData['shouldCollapseOnMobile'],
4745
'd-md-none' => !$columnData['shouldCollapseAlways'] && !$columnData['shouldCollapseOnTablet'] && $columnData['shouldCollapseOnMobile'],
48-
'd-lg-none' => !$columnData['houldCollapseAlway'] && ($columnData['shouldCollapseOnTablet'] || $columnData['shouldCollapseOnMobile']),
46+
'd-lg-none' => !$columnData['shouldCollapseAlways'] && ($columnData['shouldCollapseOnTablet'] || $columnData['shouldCollapseOnMobile']),
4947
5048
])>
5149
<strong>{{ $columnData['title'] }}</strong>: <br />

resources/views/components/table/tbody.blade.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
@aware(['tableName'])
2-
@props(['row','rowIndex','rowPk'])
3-
@php($coreTableAttributes = $this->getCoreTableAttributes())
4-
@php($currentlyReorderingStatus = $this->getCurrentlyReorderingStatus())
5-
@php($showBulkActionsSections = $this->showBulkActionsSections())
6-
@php($showCollapsingColumnSections = $this->showCollapsingColumnSections())
7-
@php($selectedVisibleColumns = $this->selectedVisibleColumns())
8-
1+
@aware(['tableName','showBulkActionsSections', 'coreTableAttributes', 'currentlyReorderingStatus', 'showCollapsingColumnSections', 'selectedVisibleColumns'])
2+
@props(['row','rowIndex','rowPk','customAttributes'])
93

104
<tbody {{ $attributes->merge($coreTableAttributes['tbody'])
115
->class([
@@ -15,7 +9,7 @@
159
->except(['default','default-styling','default-colors'])
1610
}} x-data
1711
>
18-
<x-livewire-tables::table.tr wire:key="{{ $tableName }}-row-wrap-{{ $rowPk }}" :$row :$rowIndex :$rowPk>
12+
<x-livewire-tables::table.tr wire:key="{{ $tableName }}-row-wrap-{{ $rowPk }}" >
1913

2014
@if($currentlyReorderingStatus)
2115
<x-livewire-tables::table.td.reorder x-cloak x-show="currentlyReorderingStatus" />
@@ -39,6 +33,6 @@
3933
</x-livewire-tables::table.tr>
4034

4135
@if ($showCollapsingColumnSections)
42-
<x-livewire-tables::table.collapsed-columns :$row :$rowIndex />
36+
<x-livewire-tables::table.collapsed-columns />
4337
@endif
4438
</tbody>

resources/views/components/table/td/bulk-actions.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
@aware([ 'tableName', 'isTailwind', 'rowPk', 'tdAttributes', 'tdCheckboxAttributes'])
1+
@aware([ 'tableName', 'isTailwind', 'rowPk', 'tdAttributes', 'tdCheckboxAttributes', 'showBulkActionsSections'])
22

3-
@if ($this->showBulkActionsSections())
3+
@if ($showBulkActionsSections)
44
<x-livewire-tables::table.td.plain wire:key="{{ $tableName }}-tbody-td-bulk-actions-td-{{ $rowPk }}" :displayMinimisedOnReorder="true" :customAttributes=$tdAttributes>
55
<div @class($isTailwind ? [
66
'inline-flex rounded-md shadow-sm',

resources/views/components/table/tr.blade.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
@aware([ 'tableName','primaryKey','isTailwind','isBootstrap'])
2-
@props(['row', 'rowIndex'])
3-
4-
@php
5-
$customAttributes = $this->getTrAttributes($row, $rowIndex);
6-
@endphp
1+
@aware([ 'tableName','primaryKey','isTailwind','isBootstrap','row', 'rowPk', 'rowIndex', 'customAttributes'])
72

83
<tr
9-
rowpk='{{ $row->{$primaryKey} }}'
4+
rowpk='{{ $rowPk }}'
105
x-on:dragstart.self="currentlyReorderingStatus && dragStart(event)"
116
x-on:drop.prevent="currentlyReorderingStatus && dropEvent(event)"
127
x-on:dragover.prevent.throttle.500ms="currentlyReorderingStatus && dragOverEvent(event)"
@@ -16,9 +11,9 @@
1611
@else
1712
wire:loading.class.delay="opacity-50 dark:bg-gray-900 dark:opacity-60"
1813
@endif
19-
id="{{ $tableName }}-row-{{ $row->{$primaryKey} }}"
14+
id="{{ $tableName }}-row-{{ $rowPk }}"
2015
:draggable="currentlyReorderingStatus"
21-
wire:key="{{ $tableName }}-tablerow-tr-{{ $row->{$primaryKey} }}"
16+
wire:key="{{ $tableName }}-tablerow-tr-{{ $rowPk }}"
2217
loopType="{{ ($rowIndex % 2 === 0) ? 'even' : 'odd' }}"
2318
{{
2419
$attributes->merge($customAttributes)

resources/views/components/table/tr/footer.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
@aware([ 'tableName'])
1+
@aware([ 'tableName', 'showBulkActionsSections','hasCollapsingColumns'])
22

33
<x-livewire-tables::table.tr.plain :rowIndex="-1"
44
:customAttributes="$this->getFooterTrAttributes($this->getRows)"
55
wire:key="{{ $tableName .'-footer' }}"
66
>
77
{{-- Adds a Column For Bulk Actions--}}
8-
@if (!$this->bulkActionsAreEnabled() || !$this->hasBulkActions())
8+
@if (!$showBulkActionsSections)
99
<x-livewire-tables::table.td.plain x-cloak x-show="currentlyReorderingStatus" wire:key="{{ $tableName . '-footer-bulkactions-1' }}" />
10-
@elseif ($this->bulkActionsAreEnabled() && $this->hasBulkActions())
10+
@elseif ($showBulkActionsSections)
1111
<x-livewire-tables::table.td.plain wire:key="{{ $tableName . '-footer-bulkactions-2' }}" />
1212
@endif
1313

1414
{{-- Adds a Column If Collapsing Columns Exist --}}
15-
@if ($this->collapsingColumnsAreEnabled() && $this->hasCollapsedColumns())
15+
@if ($hasCollapsingColumns)
1616
<x-livewire-tables::table.td.collapsed-columns :displayMinimisedOnReorder="true" :hidden="true" wire:key="{{ $tableName.'-footer-collapse' }}" />
1717
@endif
1818

resources/views/components/table/tr/secondary-header.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@aware([ 'tableName'])
1+
@aware([ 'tableName', 'hasCollapsingColumns', 'showBulkActionsSections'])
22

33
<x-livewire-tables::table.tr.plain :rowIndex="-1"
44
:customAttributes="$this->getSecondaryHeaderTrAttributes($this->getRows)"
@@ -7,11 +7,11 @@
77
{{-- TODO: Remove --}}
88
<x-livewire-tables::table.td.plain x-cloak x-show="currentlyReorderingStatus" :displayMinimisedOnReorder="true" wire:key="{{ $tableName .'-header-test' }}" />
99

10-
@if ($this->showBulkActionsSections)
10+
@if ($showBulkActionsSections)
1111
<x-livewire-tables::table.td.plain :displayMinimisedOnReorder="true" wire:key="{{ $tableName .'-header-hasBulkActions' }}" />
1212
@endif
1313

14-
@if ($this->collapsingColumnsAreEnabled() && $this->hasCollapsedColumns())
14+
@if ($hasCollapsingColumns)
1515
<x-livewire-tables::table.td.collapsed-columns :hidden=true :displayMinimisedOnReorder="true" wire:key="{{ $tableName .'header-collapsed-hide' }}" />
1616
@endif
1717

resources/views/components/wrapper.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@props(['component', 'tableName', 'primaryKey', 'isTailwind', 'isBootstrap','isBootstrap4', 'isBootstrap5', 'collapsingColumnDetails', 'tdAttributes', 'tdCheckboxAttributes', 'collapsingColumnButtonExpandAttributes', 'collapsingColumnButtonCollapseAttributes', 'hasCollapsingColumns', 'shouldCollapseAlways', 'shouldCollapseOnTablet', 'shouldCollapseOnMobile'])
1+
@props(['component', 'tableName', 'primaryKey', 'isTailwind', 'isBootstrap','isBootstrap4', 'isBootstrap5', 'collapsingColumnDetails', 'tdAttributes', 'tdCheckboxAttributes', 'collapsingColumnButtonExpandAttributes', 'collapsingColumnButtonCollapseAttributes', 'hasCollapsingColumns', 'shouldCollapseAlways', 'shouldCollapseOnTablet', 'shouldCollapseOnMobile', 'showBulkActionsSections', 'coreTableAttributes', 'showCollapsingColumnSections', 'selectedVisibleColumns'])
22
<div wire:key="{{ $tableName }}-wrapper" >
33
<div {{ $attributes->merge($this->getComponentWrapperAttributes()) }}
44
@if ($this->hasRefresh()) wire:poll{{ $this->getRefreshOptions() }} @endif

resources/views/datatable.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@php($shouldCollapseAlways = $this->shouldCollapseAlways())
2121
@php($shouldCollapseOnTablet = $this->shouldCollapseOnTablet())
2222
@php($shouldCollapseOnMobile = $this->shouldCollapseOnMobile())
23-
23+
@php($coreTableAttributes = $this->getCoreTableAttributes())
2424

2525
<div>
2626
<div x-data="{ currentlyReorderingStatus: false }">
@@ -32,7 +32,7 @@
3232
$this->getParametersForConfigurableArea('before-wrapper')
3333
)
3434

35-
<x-livewire-tables::wrapper :$tableName :$primaryKey :$isTailwind :$isBootstrap :$isBootstrap4 :$isBootstrap5 :$localisationPath :$collapsingColumnDetails :$tdAttributes :$tdCheckboxAttributes :$collapsingColumnButtonExpandAttributes :$collapsingColumnButtonCollapseAttributes :$hasCollapsingColumns :$shouldCollapseAlways :$shouldCollapseOnTablet :$shouldCollapseOnMobile>
35+
<x-livewire-tables::wrapper :$tableName :$primaryKey :$isTailwind :$isBootstrap :$isBootstrap4 :$isBootstrap5 :$localisationPath :$collapsingColumnDetails :$tdAttributes :$tdCheckboxAttributes :$collapsingColumnButtonExpandAttributes :$collapsingColumnButtonCollapseAttributes :$hasCollapsingColumns :$shouldCollapseAlways :$shouldCollapseOnTablet :$shouldCollapseOnMobile :$currentlyReorderingStatus :$showBulkActionsSections :$coreTableAttributes :$showCollapsingColumnSections :$selectedVisibleColumns>
3636
@if($this->hasActions() && !$this->showActionsInToolbar())
3737
<x-livewire-tables::includes.actions/>
3838
@endif
@@ -103,8 +103,8 @@
103103

104104
@tableloop ($currentRows as $rowIndex => $row)
105105
@php($rowPk = $row->{$primaryKey})
106-
<x-livewire-tables::table.tbody wire:key="{{ $tableName }}-row-wrap-{{ $rowPk }}" :$row :$rowIndex :$rowPk />
107-
106+
<x-livewire-tables::table.tbody wire:key="{{ $tableName }}-row-wrap-{{ $rowPk }}" :$row :$rowIndex :$rowPk :customAttributes="$this->getTrAttributes($row, $rowIndex)" />
107+
108108
@endtableloop
109109
@else
110110
<x-livewire-tables::table.empty />

0 commit comments

Comments
 (0)