Skip to content

Commit 424ab84

Browse files
authored
Filter Trait - Reorganization (rappasoft#2181)
* Initial Commits * Fix styling * Fix namespace * Fix styling * Remove superfluous filter traits * Fixes for Filter Trait Tidy Up * Fix styling * Tweaks for Lazy Tables & Tidying Item * Roll back to allow HTML separator * Add tests for new methods * Fix styling * Remove duplicate traits * Add additional tests * Add filter slidedown tests * Fix styling * Add Filter Slidedown Row Test * Fix styling * Test Adjustments * Add test for filter slidedown row * Fix styling * Merging * Add setFilterDefaultValue Test * Fix styling
1 parent 5b23dfb commit 424ab84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1251
-697
lines changed
Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
@aware([ 'tableName','isTailwind','isBootstrap','isBootstrap4','isBootstrap5'])
22

3-
@if ($this->filtersAreEnabled() && $this->filterPillsAreEnabled() && $this->hasAppliedVisibleFiltersForPills())
4-
<div>
5-
<div @class([
6-
'mb-4 px-4 md:p-0' => $isTailwind,
7-
'mb-3' => $isBootstrap,
8-
]) x-cloak x-show="!currentlyReorderingStatus">
9-
<small @class([
10-
'text-gray-700 dark:text-white' => $isTailwind,
11-
'' => $isBootstrap,
12-
])>
13-
{{ __($this->getLocalisationPath.'Applied Filters') }}:
14-
</small>
3+
<div>
4+
<div @class([
5+
'mb-4 px-4 md:p-0' => $isTailwind,
6+
'mb-3' => $isBootstrap,
7+
]) x-cloak x-show="!currentlyReorderingStatus">
8+
<small @class([
9+
'text-gray-700 dark:text-white' => $isTailwind,
10+
'' => $isBootstrap,
11+
])>
12+
{{ __($this->getLocalisationPath.'Applied Filters') }}:
13+
</small>
1514

16-
@foreach($this->getAppliedFiltersWithValues() as $filterSelectName => $value)
17-
@php($filter = $this->getFilterByKey($filterSelectName))
18-
@continue(is_null($filter) || $filter->isHiddenFromPills())
19-
@php( $filterPillTitle = $filter->getFilterPillTitle())
20-
@php( $filterPillValue = $filter->getFilterPillValue($value))
21-
@php( $separator = method_exists($filter, 'getPillsSeparator') ? $filter->getPillsSeparator() : ', ')
22-
@continue((is_array($filterPillValue) && empty($filterPillValue)))
23-
24-
@if ($filter->hasCustomPillBlade())
25-
@include($filter->getCustomPillBlade(), ['filter' => $filter])
26-
@else
27-
<x-livewire-tables::tools.filter-pills.item :$filterPillTitle :$filterPillValue :$filterSelectName :$separator/>
28-
@endif
29-
@endforeach
30-
<x-livewire-tables::tools.filter-pills.buttons.reset-all />
31-
</div>
15+
@tableloop($this->getAppliedFiltersWithValues() as $filterSelectName => $value)
16+
@php($filter = $this->getFilterByKey($filterSelectName))
17+
@continue(is_null($filter) || $filter->isHiddenFromPills())
18+
@php( $filterPillValue = $filter->getFilterPillValue($value))
19+
@continue((is_array($filterPillValue) && empty($filterPillValue)))
20+
@php( $filterPillTitle = $filter->getFilterPillTitle())
21+
@php( $separator = method_exists($filter, 'getPillsSeparator') ? $filter->getPillsSeparator() : ', ')
22+
@if ($filter->hasCustomPillBlade())
23+
@include($filter->getCustomPillBlade(), ['filter' => $filter])
24+
@else
25+
<x-livewire-tables::tools.filter-pills.item :$filterPillTitle :$filterPillValue :$filterSelectName :$separator/>
26+
@endif
27+
@endtableloop
28+
<x-livewire-tables::tools.filter-pills.buttons.reset-all />
3229
</div>
33-
@endif
30+
</div>

resources/views/components/tools/filter-pills/item.blade.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<span
44
wire:key="{{ $tableName }}-filter-pill-{{ $filterSelectName }}"
55
{{
6-
$attributes->merge($this->getFilterPillsItemAttributes())
6+
$attributes->merge($this->getFilterPillsItemAttributes)
77
->class([
8-
'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 capitalize' => $isTailwind && $this->getFilterPillsItemAttributes()['default-styling'],
9-
'bg-indigo-100 text-indigo-800 dark:bg-indigo-200 dark:text-indigo-900' => $isTailwind && $this->getFilterPillsItemAttributes()['default-colors'],
10-
'badge badge-pill badge-info d-inline-flex align-items-center' => $isBootstrap4 && $this->getFilterPillsItemAttributes()['default-styling'],
11-
'badge rounded-pill bg-info d-inline-flex align-items-center' => $isBootstrap5 && $this->getFilterPillsItemAttributes()['default-styling'],
8+
'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 capitalize' => $isTailwind && $this->getFilterPillsItemAttributes['default-styling'],
9+
'bg-indigo-100 text-indigo-800 dark:bg-indigo-200 dark:text-indigo-900' => $isTailwind && $this->getFilterPillsItemAttributes['default-colors'],
10+
'badge badge-pill badge-info d-inline-flex align-items-center' => $isBootstrap4 && $this->getFilterPillsItemAttributes['default-styling'],
11+
'badge rounded-pill bg-info d-inline-flex align-items-center' => $isBootstrap5 && $this->getFilterPillsItemAttributes['default-styling'],
1212
])
1313
->except(['default-styling', 'default-colors'])
1414
}}

resources/views/datatable.blade.php

Lines changed: 105 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -7,139 +7,141 @@
77
@php($isBootstrap5 = $this->isBootstrap5)
88

99
<div>
10-
<div {{ $this->getTopLevelAttributes() }}>
11-
12-
@includeWhen(
13-
$this->hasConfigurableAreaFor('before-wrapper'),
14-
$this->getConfigurableAreaFor('before-wrapper'),
15-
$this->getParametersForConfigurableArea('before-wrapper')
16-
)
17-
18-
<x-livewire-tables::wrapper :component="$this" :tableName="$tableName" :$primaryKey :$isTailwind :$isBootstrap :$isBootstrap4 :$isBootstrap5>
19-
@if($this->hasActions && !$this->showActionsInToolbar)
20-
<x-livewire-tables::includes.actions/>
21-
@endif
10+
<div x-data="{ currentlyReorderingStatus: false }">
11+
<div {{ $this->getTopLevelAttributes() }}>
2212

2313
@includeWhen(
24-
$this->hasConfigurableAreaFor('before-tools'),
25-
$this->getConfigurableAreaFor('before-tools'),
26-
$this->getParametersForConfigurableArea('before-tools')
14+
$this->hasConfigurableAreaFor('before-wrapper'),
15+
$this->getConfigurableAreaFor('before-wrapper'),
16+
$this->getParametersForConfigurableArea('before-wrapper')
2717
)
2818

29-
@if($this->shouldShowTools)
30-
<x-livewire-tables::tools>
31-
@if ($this->showSortPillsSection)
32-
<x-livewire-tables::tools.sorting-pills />
33-
@endif
34-
@if($this->showFilterPillsSection)
35-
<x-livewire-tables::tools.filter-pills />
19+
<x-livewire-tables::wrapper :component="$this" :tableName="$tableName" :$primaryKey :$isTailwind :$isBootstrap :$isBootstrap4 :$isBootstrap5>
20+
@if($this->hasActions && !$this->showActionsInToolbar)
21+
<x-livewire-tables::includes.actions/>
3622
@endif
3723

3824
@includeWhen(
39-
$this->hasConfigurableAreaFor('before-toolbar'),
40-
$this->getConfigurableAreaFor('before-toolbar'),
41-
$this->getParametersForConfigurableArea('before-toolbar')
25+
$this->hasConfigurableAreaFor('before-tools'),
26+
$this->getConfigurableAreaFor('before-tools'),
27+
$this->getParametersForConfigurableArea('before-tools')
4228
)
4329

44-
@if($this->shouldShowToolBar)
45-
<x-livewire-tables::tools.toolbar />
46-
@endif
47-
48-
@includeWhen(
49-
$this->hasConfigurableAreaFor('after-toolbar'),
50-
$this->getConfigurableAreaFor('after-toolbar'),
51-
$this->getParametersForConfigurableArea('after-toolbar')
52-
)
53-
54-
</x-livewire-tables::tools>
55-
@endif
56-
57-
@includeWhen(
58-
$this->hasConfigurableAreaFor('after-tools'),
59-
$this->getConfigurableAreaFor('after-tools'),
60-
$this->getParametersForConfigurableArea('after-tools')
61-
)
30+
@if($this->shouldShowTools)
31+
<x-livewire-tables::tools>
32+
@if ($this->showSortPillsSection)
33+
<x-livewire-tables::tools.sorting-pills />
34+
@endif
35+
@if($this->showFilterPillsSection)
36+
<x-livewire-tables::tools.filter-pills />
37+
@endif
6238

63-
<x-livewire-tables::table>
39+
@includeWhen(
40+
$this->hasConfigurableAreaFor('before-toolbar'),
41+
$this->getConfigurableAreaFor('before-toolbar'),
42+
$this->getParametersForConfigurableArea('before-toolbar')
43+
)
6444

65-
<x-slot name="thead">
66-
@if($this->getCurrentlyReorderingStatus)
67-
<x-livewire-tables::table.th.reorder x-cloak x-show="currentlyReorderingStatus" />
68-
@endif
69-
@if($this->showBulkActionsSections)
70-
<x-livewire-tables::table.th.bulk-actions :displayMinimisedOnReorder="true" />
71-
@endif
72-
@if ($this->showCollapsingColumnSections)
73-
<x-livewire-tables::table.th.collapsed-columns />
74-
@endif
45+
@if($this->shouldShowToolBar)
46+
<x-livewire-tables::tools.toolbar />
47+
@endif
7548

76-
@foreach($this->selectedVisibleColumns as $index => $column)
77-
<x-livewire-tables::table.th wire:key="{{ $tableName.'-table-head-'.$index }}" :$column :$index />
78-
@endforeach
79-
</x-slot>
49+
@includeWhen(
50+
$this->hasConfigurableAreaFor('after-toolbar'),
51+
$this->getConfigurableAreaFor('after-toolbar'),
52+
$this->getParametersForConfigurableArea('after-toolbar')
53+
)
8054

81-
@if($this->secondaryHeaderIsEnabled() && $this->hasColumnsWithSecondaryHeader())
82-
<x-livewire-tables::table.tr.secondary-header />
83-
@endif
84-
@if($this->hasDisplayLoadingPlaceholder())
85-
<x-livewire-tables::includes.loading colCount="{{ $this->columns->count()+1 }}" />
55+
</x-livewire-tables::tools>
8656
@endif
8757

88-
@if($this->showBulkActionsSections)
89-
<x-livewire-tables::table.tr.bulk-actions :displayMinimisedOnReorder="true" />
90-
@endif
58+
@includeWhen(
59+
$this->hasConfigurableAreaFor('after-tools'),
60+
$this->getConfigurableAreaFor('after-tools'),
61+
$this->getParametersForConfigurableArea('after-tools')
62+
)
63+
64+
<x-livewire-tables::table>
9165

92-
@forelse ($this->getRows as $rowIndex => $row)
93-
<x-livewire-tables::table.tr wire:key="{{ $tableName }}-row-wrap-{{ $row->{$primaryKey} }}" :$row :$rowIndex>
66+
<x-slot name="thead">
9467
@if($this->getCurrentlyReorderingStatus)
95-
<x-livewire-tables::table.td.reorder x-cloak x-show="currentlyReorderingStatus" wire:key="{{ $tableName }}-row-reorder-{{ $row->{$primaryKey} }}" :rowID="$tableName.'-'.$row->{$this->getPrimaryKey()}" :$rowIndex />
68+
<x-livewire-tables::table.th.reorder x-cloak x-show="currentlyReorderingStatus" />
9669
@endif
9770
@if($this->showBulkActionsSections)
98-
<x-livewire-tables::table.td.bulk-actions wire:key="{{ $tableName }}-row-bulk-act-{{ $row->{$primaryKey} }}" :$row :$rowIndex />
71+
<x-livewire-tables::table.th.bulk-actions :displayMinimisedOnReorder="true" />
9972
@endif
10073
@if ($this->showCollapsingColumnSections)
101-
<x-livewire-tables::table.td.collapsed-columns wire:key="{{ $tableName }}-row-collapsed-{{ $row->{$primaryKey} }}" :$rowIndex />
74+
<x-livewire-tables::table.th.collapsed-columns />
10275
@endif
10376

104-
@foreach($this->selectedVisibleColumns as $colIndex => $column)
105-
<x-livewire-tables::table.td wire:key="{{ $tableName . '-' . $row->{$primaryKey} . '-datatable-td-' . $column->getSlug() }}" :$column :$colIndex>
106-
@if($column->isHtml())
107-
{!! $column->setIndexes($rowIndex, $colIndex)->renderContents($row) !!}
108-
@else
109-
{{ $column->setIndexes($rowIndex, $colIndex)->renderContents($row) }}
110-
@endif
111-
</x-livewire-tables::table.td>
77+
@foreach($this->selectedVisibleColumns as $index => $column)
78+
<x-livewire-tables::table.th wire:key="{{ $tableName.'-table-head-'.$index }}" :$column :$index />
11279
@endforeach
113-
</x-livewire-tables::table.tr>
80+
</x-slot>
81+
82+
@if($this->secondaryHeaderIsEnabled() && $this->hasColumnsWithSecondaryHeader())
83+
<x-livewire-tables::table.tr.secondary-header />
84+
@endif
85+
@if($this->hasDisplayLoadingPlaceholder())
86+
<x-livewire-tables::includes.loading colCount="{{ $this->columns->count()+1 }}" />
87+
@endif
11488

115-
@if ($this->showCollapsingColumnSections)
116-
<x-livewire-tables::table.collapsed-columns :$row :$rowIndex />
89+
@if($this->showBulkActionsSections)
90+
<x-livewire-tables::table.tr.bulk-actions :displayMinimisedOnReorder="true" />
11791
@endif
118-
@empty
119-
<x-livewire-tables::table.empty />
120-
@endforelse
121-
122-
@if ($this->footerIsEnabled() && $this->hasColumnsWithFooter())
123-
<x-slot name="tfoot">
124-
@if ($this->useHeaderAsFooterIsEnabled())
125-
<x-livewire-tables::table.tr.secondary-header />
126-
@else
127-
<x-livewire-tables::table.tr.footer />
92+
93+
@forelse ($this->getRows as $rowIndex => $row)
94+
<x-livewire-tables::table.tr wire:key="{{ $tableName }}-row-wrap-{{ $row->{$primaryKey} }}" :$row :$rowIndex>
95+
@if($this->getCurrentlyReorderingStatus)
96+
<x-livewire-tables::table.td.reorder x-cloak x-show="currentlyReorderingStatus" wire:key="{{ $tableName }}-row-reorder-{{ $row->{$primaryKey} }}" :rowID="$tableName.'-'.$row->{$this->getPrimaryKey()}" :$rowIndex />
97+
@endif
98+
@if($this->showBulkActionsSections)
99+
<x-livewire-tables::table.td.bulk-actions wire:key="{{ $tableName }}-row-bulk-act-{{ $row->{$primaryKey} }}" :$row :$rowIndex />
100+
@endif
101+
@if ($this->showCollapsingColumnSections)
102+
<x-livewire-tables::table.td.collapsed-columns wire:key="{{ $tableName }}-row-collapsed-{{ $row->{$primaryKey} }}" :$rowIndex />
103+
@endif
104+
105+
@foreach($this->selectedVisibleColumns as $colIndex => $column)
106+
<x-livewire-tables::table.td wire:key="{{ $tableName . '-' . $row->{$primaryKey} . '-datatable-td-' . $column->getSlug() }}" :$column :$colIndex>
107+
@if($column->isHtml())
108+
{!! $column->setIndexes($rowIndex, $colIndex)->renderContents($row) !!}
109+
@else
110+
{{ $column->setIndexes($rowIndex, $colIndex)->renderContents($row) }}
111+
@endif
112+
</x-livewire-tables::table.td>
113+
@endforeach
114+
</x-livewire-tables::table.tr>
115+
116+
@if ($this->showCollapsingColumnSections)
117+
<x-livewire-tables::table.collapsed-columns :$row :$rowIndex />
128118
@endif
129-
</x-slot>
130-
@endif
131-
</x-livewire-tables::table>
119+
@empty
120+
<x-livewire-tables::table.empty />
121+
@endforelse
122+
123+
@if ($this->footerIsEnabled() && $this->hasColumnsWithFooter())
124+
<x-slot name="tfoot">
125+
@if ($this->useHeaderAsFooterIsEnabled())
126+
<x-livewire-tables::table.tr.secondary-header />
127+
@else
128+
<x-livewire-tables::table.tr.footer />
129+
@endif
130+
</x-slot>
131+
@endif
132+
</x-livewire-tables::table>
132133

133-
<x-livewire-tables::pagination />
134+
<x-livewire-tables::pagination />
134135

135-
@includeIf($customView)
136-
</x-livewire-tables::wrapper>
136+
@includeIf($customView)
137+
</x-livewire-tables::wrapper>
137138

138-
@includeWhen(
139-
$this->hasConfigurableAreaFor('after-wrapper'),
140-
$this->getConfigurableAreaFor('after-wrapper'),
141-
$this->getParametersForConfigurableArea('after-wrapper')
142-
)
139+
@includeWhen(
140+
$this->hasConfigurableAreaFor('after-wrapper'),
141+
$this->getConfigurableAreaFor('after-wrapper'),
142+
$this->getParametersForConfigurableArea('after-wrapper')
143+
)
143144

145+
</div>
144146
</div>
145147
</div>

src/Traits/Configuration/FilterConfiguration.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/Traits/Core/Filters/HandlesFilterTraits.php

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Traits/Core/Filters/HasFilterGenericData.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)