Skip to content

Commit

Permalink
Filter Trait - Reorganization (rappasoft#2181)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lrljoe authored Jan 24, 2025
1 parent 5b23dfb commit 424ab84
Show file tree
Hide file tree
Showing 44 changed files with 1,251 additions and 697 deletions.
55 changes: 26 additions & 29 deletions resources/views/components/tools/filter-pills.blade.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
@aware([ 'tableName','isTailwind','isBootstrap','isBootstrap4','isBootstrap5'])

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

@foreach($this->getAppliedFiltersWithValues() as $filterSelectName => $value)
@php($filter = $this->getFilterByKey($filterSelectName))
@continue(is_null($filter) || $filter->isHiddenFromPills())
@php( $filterPillTitle = $filter->getFilterPillTitle())
@php( $filterPillValue = $filter->getFilterPillValue($value))
@php( $separator = method_exists($filter, 'getPillsSeparator') ? $filter->getPillsSeparator() : ', ')
@continue((is_array($filterPillValue) && empty($filterPillValue)))

@if ($filter->hasCustomPillBlade())
@include($filter->getCustomPillBlade(), ['filter' => $filter])
@else
<x-livewire-tables::tools.filter-pills.item :$filterPillTitle :$filterPillValue :$filterSelectName :$separator/>
@endif
@endforeach
<x-livewire-tables::tools.filter-pills.buttons.reset-all />
</div>
@tableloop($this->getAppliedFiltersWithValues() as $filterSelectName => $value)
@php($filter = $this->getFilterByKey($filterSelectName))
@continue(is_null($filter) || $filter->isHiddenFromPills())
@php( $filterPillValue = $filter->getFilterPillValue($value))
@continue((is_array($filterPillValue) && empty($filterPillValue)))
@php( $filterPillTitle = $filter->getFilterPillTitle())
@php( $separator = method_exists($filter, 'getPillsSeparator') ? $filter->getPillsSeparator() : ', ')
@if ($filter->hasCustomPillBlade())
@include($filter->getCustomPillBlade(), ['filter' => $filter])
@else
<x-livewire-tables::tools.filter-pills.item :$filterPillTitle :$filterPillValue :$filterSelectName :$separator/>
@endif
@endtableloop
<x-livewire-tables::tools.filter-pills.buttons.reset-all />
</div>
@endif
</div>
10 changes: 5 additions & 5 deletions resources/views/components/tools/filter-pills/item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<span
wire:key="{{ $tableName }}-filter-pill-{{ $filterSelectName }}"
{{
$attributes->merge($this->getFilterPillsItemAttributes())
$attributes->merge($this->getFilterPillsItemAttributes)
->class([
'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 capitalize' => $isTailwind && $this->getFilterPillsItemAttributes()['default-styling'],
'bg-indigo-100 text-indigo-800 dark:bg-indigo-200 dark:text-indigo-900' => $isTailwind && $this->getFilterPillsItemAttributes()['default-colors'],
'badge badge-pill badge-info d-inline-flex align-items-center' => $isBootstrap4 && $this->getFilterPillsItemAttributes()['default-styling'],
'badge rounded-pill bg-info d-inline-flex align-items-center' => $isBootstrap5 && $this->getFilterPillsItemAttributes()['default-styling'],
'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 capitalize' => $isTailwind && $this->getFilterPillsItemAttributes['default-styling'],
'bg-indigo-100 text-indigo-800 dark:bg-indigo-200 dark:text-indigo-900' => $isTailwind && $this->getFilterPillsItemAttributes['default-colors'],
'badge badge-pill badge-info d-inline-flex align-items-center' => $isBootstrap4 && $this->getFilterPillsItemAttributes['default-styling'],
'badge rounded-pill bg-info d-inline-flex align-items-center' => $isBootstrap5 && $this->getFilterPillsItemAttributes['default-styling'],
])
->except(['default-styling', 'default-colors'])
}}
Expand Down
208 changes: 105 additions & 103 deletions resources/views/datatable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,139 +7,141 @@
@php($isBootstrap5 = $this->isBootstrap5)

<div>
<div {{ $this->getTopLevelAttributes() }}>

@includeWhen(
$this->hasConfigurableAreaFor('before-wrapper'),
$this->getConfigurableAreaFor('before-wrapper'),
$this->getParametersForConfigurableArea('before-wrapper')
)

<x-livewire-tables::wrapper :component="$this" :tableName="$tableName" :$primaryKey :$isTailwind :$isBootstrap :$isBootstrap4 :$isBootstrap5>
@if($this->hasActions && !$this->showActionsInToolbar)
<x-livewire-tables::includes.actions/>
@endif
<div x-data="{ currentlyReorderingStatus: false }">
<div {{ $this->getTopLevelAttributes() }}>

@includeWhen(
$this->hasConfigurableAreaFor('before-tools'),
$this->getConfigurableAreaFor('before-tools'),
$this->getParametersForConfigurableArea('before-tools')
$this->hasConfigurableAreaFor('before-wrapper'),
$this->getConfigurableAreaFor('before-wrapper'),
$this->getParametersForConfigurableArea('before-wrapper')
)

@if($this->shouldShowTools)
<x-livewire-tables::tools>
@if ($this->showSortPillsSection)
<x-livewire-tables::tools.sorting-pills />
@endif
@if($this->showFilterPillsSection)
<x-livewire-tables::tools.filter-pills />
<x-livewire-tables::wrapper :component="$this" :tableName="$tableName" :$primaryKey :$isTailwind :$isBootstrap :$isBootstrap4 :$isBootstrap5>
@if($this->hasActions && !$this->showActionsInToolbar)
<x-livewire-tables::includes.actions/>
@endif

@includeWhen(
$this->hasConfigurableAreaFor('before-toolbar'),
$this->getConfigurableAreaFor('before-toolbar'),
$this->getParametersForConfigurableArea('before-toolbar')
$this->hasConfigurableAreaFor('before-tools'),
$this->getConfigurableAreaFor('before-tools'),
$this->getParametersForConfigurableArea('before-tools')
)

@if($this->shouldShowToolBar)
<x-livewire-tables::tools.toolbar />
@endif

@includeWhen(
$this->hasConfigurableAreaFor('after-toolbar'),
$this->getConfigurableAreaFor('after-toolbar'),
$this->getParametersForConfigurableArea('after-toolbar')
)

</x-livewire-tables::tools>
@endif

@includeWhen(
$this->hasConfigurableAreaFor('after-tools'),
$this->getConfigurableAreaFor('after-tools'),
$this->getParametersForConfigurableArea('after-tools')
)
@if($this->shouldShowTools)
<x-livewire-tables::tools>
@if ($this->showSortPillsSection)
<x-livewire-tables::tools.sorting-pills />
@endif
@if($this->showFilterPillsSection)
<x-livewire-tables::tools.filter-pills />
@endif

<x-livewire-tables::table>
@includeWhen(
$this->hasConfigurableAreaFor('before-toolbar'),
$this->getConfigurableAreaFor('before-toolbar'),
$this->getParametersForConfigurableArea('before-toolbar')
)

<x-slot name="thead">
@if($this->getCurrentlyReorderingStatus)
<x-livewire-tables::table.th.reorder x-cloak x-show="currentlyReorderingStatus" />
@endif
@if($this->showBulkActionsSections)
<x-livewire-tables::table.th.bulk-actions :displayMinimisedOnReorder="true" />
@endif
@if ($this->showCollapsingColumnSections)
<x-livewire-tables::table.th.collapsed-columns />
@endif
@if($this->shouldShowToolBar)
<x-livewire-tables::tools.toolbar />
@endif

@foreach($this->selectedVisibleColumns as $index => $column)
<x-livewire-tables::table.th wire:key="{{ $tableName.'-table-head-'.$index }}" :$column :$index />
@endforeach
</x-slot>
@includeWhen(
$this->hasConfigurableAreaFor('after-toolbar'),
$this->getConfigurableAreaFor('after-toolbar'),
$this->getParametersForConfigurableArea('after-toolbar')
)

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

@if($this->showBulkActionsSections)
<x-livewire-tables::table.tr.bulk-actions :displayMinimisedOnReorder="true" />
@endif
@includeWhen(
$this->hasConfigurableAreaFor('after-tools'),
$this->getConfigurableAreaFor('after-tools'),
$this->getParametersForConfigurableArea('after-tools')
)

<x-livewire-tables::table>

@forelse ($this->getRows as $rowIndex => $row)
<x-livewire-tables::table.tr wire:key="{{ $tableName }}-row-wrap-{{ $row->{$primaryKey} }}" :$row :$rowIndex>
<x-slot name="thead">
@if($this->getCurrentlyReorderingStatus)
<x-livewire-tables::table.td.reorder x-cloak x-show="currentlyReorderingStatus" wire:key="{{ $tableName }}-row-reorder-{{ $row->{$primaryKey} }}" :rowID="$tableName.'-'.$row->{$this->getPrimaryKey()}" :$rowIndex />
<x-livewire-tables::table.th.reorder x-cloak x-show="currentlyReorderingStatus" />
@endif
@if($this->showBulkActionsSections)
<x-livewire-tables::table.td.bulk-actions wire:key="{{ $tableName }}-row-bulk-act-{{ $row->{$primaryKey} }}" :$row :$rowIndex />
<x-livewire-tables::table.th.bulk-actions :displayMinimisedOnReorder="true" />
@endif
@if ($this->showCollapsingColumnSections)
<x-livewire-tables::table.td.collapsed-columns wire:key="{{ $tableName }}-row-collapsed-{{ $row->{$primaryKey} }}" :$rowIndex />
<x-livewire-tables::table.th.collapsed-columns />
@endif

@foreach($this->selectedVisibleColumns as $colIndex => $column)
<x-livewire-tables::table.td wire:key="{{ $tableName . '-' . $row->{$primaryKey} . '-datatable-td-' . $column->getSlug() }}" :$column :$colIndex>
@if($column->isHtml())
{!! $column->setIndexes($rowIndex, $colIndex)->renderContents($row) !!}
@else
{{ $column->setIndexes($rowIndex, $colIndex)->renderContents($row) }}
@endif
</x-livewire-tables::table.td>
@foreach($this->selectedVisibleColumns as $index => $column)
<x-livewire-tables::table.th wire:key="{{ $tableName.'-table-head-'.$index }}" :$column :$index />
@endforeach
</x-livewire-tables::table.tr>
</x-slot>

@if($this->secondaryHeaderIsEnabled() && $this->hasColumnsWithSecondaryHeader())
<x-livewire-tables::table.tr.secondary-header />
@endif
@if($this->hasDisplayLoadingPlaceholder())
<x-livewire-tables::includes.loading colCount="{{ $this->columns->count()+1 }}" />
@endif

@if ($this->showCollapsingColumnSections)
<x-livewire-tables::table.collapsed-columns :$row :$rowIndex />
@if($this->showBulkActionsSections)
<x-livewire-tables::table.tr.bulk-actions :displayMinimisedOnReorder="true" />
@endif
@empty
<x-livewire-tables::table.empty />
@endforelse

@if ($this->footerIsEnabled() && $this->hasColumnsWithFooter())
<x-slot name="tfoot">
@if ($this->useHeaderAsFooterIsEnabled())
<x-livewire-tables::table.tr.secondary-header />
@else
<x-livewire-tables::table.tr.footer />

@forelse ($this->getRows as $rowIndex => $row)
<x-livewire-tables::table.tr wire:key="{{ $tableName }}-row-wrap-{{ $row->{$primaryKey} }}" :$row :$rowIndex>
@if($this->getCurrentlyReorderingStatus)
<x-livewire-tables::table.td.reorder x-cloak x-show="currentlyReorderingStatus" wire:key="{{ $tableName }}-row-reorder-{{ $row->{$primaryKey} }}" :rowID="$tableName.'-'.$row->{$this->getPrimaryKey()}" :$rowIndex />
@endif
@if($this->showBulkActionsSections)
<x-livewire-tables::table.td.bulk-actions wire:key="{{ $tableName }}-row-bulk-act-{{ $row->{$primaryKey} }}" :$row :$rowIndex />
@endif
@if ($this->showCollapsingColumnSections)
<x-livewire-tables::table.td.collapsed-columns wire:key="{{ $tableName }}-row-collapsed-{{ $row->{$primaryKey} }}" :$rowIndex />
@endif

@foreach($this->selectedVisibleColumns as $colIndex => $column)
<x-livewire-tables::table.td wire:key="{{ $tableName . '-' . $row->{$primaryKey} . '-datatable-td-' . $column->getSlug() }}" :$column :$colIndex>
@if($column->isHtml())
{!! $column->setIndexes($rowIndex, $colIndex)->renderContents($row) !!}
@else
{{ $column->setIndexes($rowIndex, $colIndex)->renderContents($row) }}
@endif
</x-livewire-tables::table.td>
@endforeach
</x-livewire-tables::table.tr>

@if ($this->showCollapsingColumnSections)
<x-livewire-tables::table.collapsed-columns :$row :$rowIndex />
@endif
</x-slot>
@endif
</x-livewire-tables::table>
@empty
<x-livewire-tables::table.empty />
@endforelse

@if ($this->footerIsEnabled() && $this->hasColumnsWithFooter())
<x-slot name="tfoot">
@if ($this->useHeaderAsFooterIsEnabled())
<x-livewire-tables::table.tr.secondary-header />
@else
<x-livewire-tables::table.tr.footer />
@endif
</x-slot>
@endif
</x-livewire-tables::table>

<x-livewire-tables::pagination />
<x-livewire-tables::pagination />

@includeIf($customView)
</x-livewire-tables::wrapper>
@includeIf($customView)
</x-livewire-tables::wrapper>

@includeWhen(
$this->hasConfigurableAreaFor('after-wrapper'),
$this->getConfigurableAreaFor('after-wrapper'),
$this->getParametersForConfigurableArea('after-wrapper')
)
@includeWhen(
$this->hasConfigurableAreaFor('after-wrapper'),
$this->getConfigurableAreaFor('after-wrapper'),
$this->getParametersForConfigurableArea('after-wrapper')
)

</div>
</div>
</div>
5 changes: 0 additions & 5 deletions src/Traits/Configuration/FilterConfiguration.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/Traits/Core/Filters/HandlesFilterTraits.php

This file was deleted.

36 changes: 0 additions & 36 deletions src/Traits/Core/Filters/HasFilterGenericData.php

This file was deleted.

Loading

0 comments on commit 424ab84

Please sign in to comment.