Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Header/Footer #2164

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Traits/Helpers/ColumnHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ protected function setupColumns(): void
->setHasTableRowUrl($this->hasTableRowUrl())
->setIsReorderColumn($this->getDefaultReorderColumn() == $column->getField());

if ($column->hasFooter()) {
$this->columnsWithFooter = true;
}
if ($column->hasSecondaryHeader()) {
$this->columnsWithSecondaryHeader = true;
}

if ($column instanceof AggregateColumn) {
if ($column->getAggregateMethod() == 'count' && $column->hasDataSource()) {
$this->addExtraWithCount($column->getDataSource());
Expand Down
14 changes: 0 additions & 14 deletions src/Traits/WithFooter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,4 @@ trait WithFooter
protected bool $useHeaderAsFooterStatus = false;

protected bool $columnsWithFooter = false;

public function setupFooter(): void
{
foreach ($this->getColumns() as $column) {
if ($column->hasFooter()) {
$this->columnsWithFooter = true;
}
}
}

public function renderingWithFooter(): void
{
$this->setupFooter();
}
}
14 changes: 0 additions & 14 deletions src/Traits/WithSecondaryHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,4 @@ trait WithSecondaryHeader
protected bool $secondaryHeaderStatus = true;

protected bool $columnsWithSecondaryHeader = false;

public function bootedWithSecondaryHeader(): void
{
$this->setupSecondaryHeader();
}

public function setupSecondaryHeader(): void
{
foreach ($this->getColumns() as $column) {
if ($column->hasSecondaryHeader()) {
$this->columnsWithSecondaryHeader = true;
}
}
}
}
1 change: 0 additions & 1 deletion tests/DataTableComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function test_minimum_one_column_expected(): void
$table->bootedComponentUtilities();
$table->bootedWithColumns();
$table->bootedWithColumnSelect();
$table->bootedWithSecondaryHeader();
$table->booted();
$table->renderingWithPagination($view, []);
$table->render();
Expand Down
12 changes: 0 additions & 12 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,11 @@ protected function setupBasicTable()
$this->basicTable->bootedComponentUtilities();
$this->basicTable->bootedWithColumns();
$this->basicTable->bootedWithColumnSelect();
$this->basicTable->bootedWithSecondaryHeader();
$this->basicTable->booted();
$this->basicTable->renderingWithColumns($view, $view->getData());
$this->basicTable->renderingWithColumnSelect($view, $view->getData());
$this->basicTable->renderingWithCustomisations($view, $view->getData());
$this->basicTable->renderingWithData($view, $view->getData());
$this->basicTable->renderingWithFooter($view, $view->getData());
$this->basicTable->renderingWithReordering($view, $view->getData());
$this->basicTable->renderingWithPagination($view, $view->getData());
$this->basicTable->render();
Expand All @@ -124,13 +122,11 @@ protected function setupEventsTable()
$this->eventsTable->bootedManagesFilters();
$this->eventsTable->bootedWithColumns();
$this->eventsTable->bootedWithColumnSelect();
$this->eventsTable->bootedWithSecondaryHeader();
$this->eventsTable->booted();
$this->eventsTable->renderingWithColumns($view, $view->getData());
$this->eventsTable->renderingWithColumnSelect($view, $view->getData());
$this->eventsTable->renderingWithCustomisations($view, $view->getData());
$this->eventsTable->renderingWithData($view, $view->getData());
$this->eventsTable->renderingWithFooter($view, $view->getData());
$this->eventsTable->renderingWithReordering($view, $view->getData());
$this->eventsTable->renderingWithPagination($view, $view->getData());

Expand All @@ -147,13 +143,11 @@ protected function setupBreedsTable()
$this->breedsTable->bootedManagesFilters();
$this->breedsTable->bootedWithColumns();
$this->breedsTable->bootedWithColumnSelect();
$this->breedsTable->bootedWithSecondaryHeader();
$this->breedsTable->booted();
$this->breedsTable->renderingWithColumns($view, $view->getData());
$this->breedsTable->renderingWithColumnSelect($view, $view->getData());
$this->breedsTable->renderingWithCustomisations($view, $view->getData());
$this->breedsTable->renderingWithData($view, $view->getData());
$this->breedsTable->renderingWithFooter($view, $view->getData());
$this->breedsTable->renderingWithReordering($view, $view->getData());
$this->breedsTable->renderingWithPagination($view, $view->getData());
$this->breedsTable->render();
Expand All @@ -169,13 +163,11 @@ protected function setupPetOwnerTable()
$this->petOwnerTable->bootedManagesFilters();
$this->petOwnerTable->bootedWithColumns();
$this->petOwnerTable->bootedWithColumnSelect();
$this->petOwnerTable->bootedWithSecondaryHeader();
$this->petOwnerTable->booted();
$this->petOwnerTable->renderingWithColumns($view, $view->getData());
$this->petOwnerTable->renderingWithColumnSelect($view, $view->getData());
$this->petOwnerTable->renderingWithCustomisations($view, $view->getData());
$this->petOwnerTable->renderingWithData($view, $view->getData());
$this->petOwnerTable->renderingWithFooter($view, $view->getData());
$this->petOwnerTable->renderingWithReordering($view, $view->getData());
$this->petOwnerTable->renderingWithPagination($view, $view->getData());
$this->petOwnerTable->render();
Expand All @@ -191,13 +183,11 @@ protected function setupSpeciesTable()
$this->speciesTable->bootedManagesFilters();
$this->speciesTable->bootedWithColumns();
$this->speciesTable->bootedWithColumnSelect();
$this->speciesTable->bootedWithSecondaryHeader();
$this->speciesTable->booted();
$this->speciesTable->renderingWithColumns($view, $view->getData());
$this->speciesTable->renderingWithColumnSelect($view, $view->getData());
$this->speciesTable->renderingWithCustomisations($view, $view->getData());
$this->speciesTable->renderingWithData($view, $view->getData());
$this->speciesTable->renderingWithFooter($view, $view->getData());
$this->speciesTable->renderingWithReordering($view, $view->getData());
$this->speciesTable->renderingWithPagination($view, $view->getData());
$this->speciesTable->render();
Expand All @@ -214,13 +204,11 @@ protected function setupUnpaginatedTable()
$this->unpaginatedTable->bootedManagesFilters();
$this->unpaginatedTable->bootedWithColumns();
$this->unpaginatedTable->bootedWithColumnSelect();
$this->unpaginatedTable->bootedWithSecondaryHeader();
$this->unpaginatedTable->booted();
$this->unpaginatedTable->renderingWithColumns($view, $view->getData());
$this->unpaginatedTable->renderingWithColumnSelect($view, $view->getData());
$this->unpaginatedTable->renderingWithCustomisations($view, $view->getData());
$this->unpaginatedTable->renderingWithData($view, $view->getData());
$this->unpaginatedTable->renderingWithFooter($view, $view->getData());
$this->unpaginatedTable->renderingWithReordering($view, $view->getData());
$this->unpaginatedTable->renderingWithPagination($view, $view->getData());
$this->unpaginatedTable->render();
Expand Down
4 changes: 0 additions & 4 deletions tests/Unit/Traits/Configuration/SortingConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,13 @@ public function configure(): void
$tempDesc->bootedManagesFilters();
$tempDesc->bootedWithColumns();
$tempDesc->bootedWithColumnSelect();
$tempDesc->bootedWithSecondaryHeader();
$tempDesc->booted();
$tempDesc->mountManagesFilters();
$tempDesc->mountWithSorting();
$tempDesc->renderingWithColumns($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithColumnSelect($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithCustomisations($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithData($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithFooter($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithReordering($viewDesc, $viewDesc->getData());
$tempDesc->renderingWithPagination($viewDesc, $viewDesc->getData());
$tempDesc->render();
Expand All @@ -142,15 +140,13 @@ public function configure(): void
$tempAsc->bootedManagesFilters();
$tempAsc->bootedWithColumns();
$tempAsc->bootedWithColumnSelect();
$tempAsc->bootedWithSecondaryHeader();
$tempAsc->booted();
$tempAsc->mountManagesFilters();
$tempAsc->mountWithSorting();
$tempAsc->renderingWithColumns($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithColumnSelect($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithCustomisations($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithData($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithFooter($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithReordering($viewAsc, $viewAsc->getData());
$tempAsc->renderingWithPagination($viewAsc, $viewAsc->getData());
$tempAsc->render();
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Traits/Helpers/ColumnHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ public function columns(): array
$testTable->bootedManagesFilters();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

}
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Traits/Helpers/ColumnSelectHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public function configure(): void
$testTable->bootedComponentUtilities();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
Expand Down Expand Up @@ -164,7 +163,6 @@ public function configure(): void
$testTable->bootedManagesFilters();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
Expand Down Expand Up @@ -195,7 +193,6 @@ public function configure(): void
$testTable->bootedComponentUtilities();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Traits/Helpers/FilterHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ public function configure(): void
$testTable->bootedComponentUtilities();
$testTable->bootedWithColumns();
$testTable->bootedWithColumnSelect();
$testTable->bootedWithSecondaryHeader();
$testTable->booted();

$testTable->setFilter('breed_id_filter', '2');
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Traits/Helpers/QueryStringHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function getCurrentQueryStringBinding(): array
$testTableQueryString->bootedManagesFilters();
$testTableQueryString->bootedWithColumns();
$testTableQueryString->bootedWithColumnSelect();
$testTableQueryString->bootedWithSecondaryHeader();
$testTableQueryString->booted();

$this->assertSame([], $testTableQueryString->getCurrentQueryStringBinding());
Expand Down Expand Up @@ -62,7 +61,6 @@ public function getCurrentQueryStringBinding(): array
$testTableQueryString->bootedManagesFilters();
$testTableQueryString->bootedWithColumns();
$testTableQueryString->bootedWithColumnSelect();
$testTableQueryString->bootedWithSecondaryHeader();
$testTableQueryString->booted();

$this->assertSame(['table' => ['except' => null, 'history' => false, 'keep' => false, 'as' => 'table']], $testTableQueryString->getCurrentQueryStringBinding());
Expand Down Expand Up @@ -93,7 +91,6 @@ public function getCurrentQueryStringBinding(): array
$testTableQueryString->bootedManagesFilters();
$testTableQueryString->bootedWithColumns();
$testTableQueryString->bootedWithColumnSelect();
$testTableQueryString->bootedWithSecondaryHeader();
$testTableQueryString->booted();

$this->assertFalse($testTableQueryString->hasQueryStringAlias());
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/Traits/WithColumnsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ public function configure(): void
$testTableDefault->bootedManagesFilters();
$testTableDefault->bootedWithColumns();
$testTableDefault->bootedWithColumnSelect();
$testTableDefault->bootedWithSecondaryHeader();
$testTableDefault->booted();
$testTableDefault->renderingWithColumns($view, $view->getData());
$testTableDefault->renderingWithColumnSelect($view, $view->getData());
$testTableDefault->renderingWithCustomisations($view, $view->getData());
$testTableDefault->renderingWithData($view, $view->getData());
$testTableDefault->renderingWithFooter($view, $view->getData());
$testTableDefault->renderingWithReordering($view, $view->getData());
$testTableDefault->renderingWithPagination($view, $view->getData());
$testTableDefault->render();
Expand Down
8 changes: 0 additions & 8 deletions tests/Unit/Traits/WithCustomisationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ public function configure(): void
$temp->bootedManagesFilters();
$temp->bootedWithColumns();
$temp->bootedWithColumnSelect();
$temp->bootedWithSecondaryHeader();
$temp->booted();
$temp->renderingWithColumns($view, $view->getData());
$temp->renderingWithColumnSelect($view, $view->getData());
$temp->renderingWithCustomisations($view, $view->getData());
$temp->renderingWithData($view, $view->getData());
$temp->renderingWithFooter($view, $view->getData());
$temp->renderingWithReordering($view, $view->getData());
$temp->renderingWithPagination($view, $view->getData());
$temp->render();
Expand Down Expand Up @@ -63,13 +61,11 @@ public function configure(): void
$temp->bootedManagesFilters();
$temp->bootedWithColumns();
$temp->bootedWithColumnSelect();
$temp->bootedWithSecondaryHeader();
$temp->booted();
$temp->renderingWithColumns($view, $view->getData());
$temp->renderingWithColumnSelect($view, $view->getData());
$temp->renderingWithCustomisations($view, $view->getData());
$temp->renderingWithData($view, $view->getData());
$temp->renderingWithFooter($view, $view->getData());
$temp->renderingWithReordering($view, $view->getData());
$temp->renderingWithPagination($view, $view->getData());
$temp->render();
Expand Down Expand Up @@ -98,13 +94,11 @@ public function configure(): void
$temp->bootedManagesFilters();
$temp->bootedWithColumns();
$temp->bootedWithColumnSelect();
$temp->bootedWithSecondaryHeader();
$temp->booted();
$temp->renderingWithColumns($view, $view->getData());
$temp->renderingWithColumnSelect($view, $view->getData());
$temp->renderingWithCustomisations($view, $view->getData());
$temp->renderingWithData($view, $view->getData());
$temp->renderingWithFooter($view, $view->getData());
$temp->renderingWithReordering($view, $view->getData());
$temp->renderingWithPagination($view, $view->getData());
$temp->render();
Expand All @@ -131,13 +125,11 @@ public function configure(): void
$temp->bootedComponentUtilities();
$temp->bootedWithColumns();
$temp->bootedWithColumnSelect();
$temp->bootedWithSecondaryHeader();
$temp->booted();
$temp->renderingWithColumns($view, $view->getData());
$temp->renderingWithColumnSelect($view, $view->getData());
$temp->renderingWithCustomisations($view, $view->getData());
$temp->renderingWithData($view, $view->getData());
$temp->renderingWithFooter($view, $view->getData());
$temp->renderingWithReordering($view, $view->getData());
$temp->renderingWithPagination($view, $view->getData());
$temp->render();
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Traits/WithMountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function test_mounttable_gets_correct_first_item(): void
$table->bootedComponentUtilities();
$table->bootedWithColumns();
$table->bootedWithColumnSelect();
$table->bootedWithSecondaryHeader();
$table->booted();
$table->renderingWithPagination($view, []);
$table->render();
Expand All @@ -36,7 +35,6 @@ public function test_mounttable_gets_correct_first_item(): void
$table2->bootedManagesFilters();
$table2->bootedWithColumns();
$table2->bootedWithColumnSelect();
$table2->bootedWithSecondaryHeader();
$table2->booted();
$table2->renderingWithPagination($view, []);
$table2->render();
Expand All @@ -53,7 +51,6 @@ public function test_mounttable_gets_correct_first_item(): void
$table3->bootedComponentUtilities();
$table3->bootedWithColumns();
$table3->bootedWithColumnSelect();
$table3->bootedWithSecondaryHeader();
$table3->booted();
$table3->renderingWithPagination($view, []);
$table3->render();
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/Traits/WithSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function configure(): void
$testTableDefault->bootedManagesFilters();
$testTableDefault->bootedWithColumns();
$testTableDefault->bootedWithColumnSelect();
$testTableDefault->bootedWithSecondaryHeader();
$testTableDefault->booted();

$this->assertSame('', $testTableDefault->search);
Expand Down Expand Up @@ -97,7 +96,6 @@ public function configure(): void
$testTableTrimSearch->bootedManagesFilters();
$testTableTrimSearch->bootedWithColumns();
$testTableTrimSearch->bootedWithColumnSelect();
$testTableTrimSearch->bootedWithSecondaryHeader();
$testTableTrimSearch->booted();

$this->assertSame('', $testTableTrimSearch->search);
Expand Down