Skip to content

Commit

Permalink
Added configuration options for full page component
Browse files Browse the repository at this point in the history
  • Loading branch information
amshehzad committed Oct 19, 2023
1 parent c972b20 commit 0e96d7b
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/DataTableComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,30 @@ public function render(): \Illuminate\Contracts\Foundation\Application|\Illumina
$this->setupFooter();
$this->setupReordering();

return view('livewire-tables::datatable')
->with([
'columns' => $this->getColumns(),
'rows' => $this->getRows(),
'customView' => $this->customView(),
]);
$view = view('livewire-tables::datatable');

if (isset($this->layout)){
$view->layout($this->layout);

Check warning on line 133 in src/DataTableComponent.php

View check run for this annotation

Codecov / codecov/patch

src/DataTableComponent.php#L133

Added line #L133 was not covered by tests
}

if (isset($this->extends)){
$view->extends($this->extends);

Check warning on line 137 in src/DataTableComponent.php

View check run for this annotation

Codecov / codecov/patch

src/DataTableComponent.php#L137

Added line #L137 was not covered by tests
}

if (isset($this->section)){
$view->section($this->section);

Check warning on line 141 in src/DataTableComponent.php

View check run for this annotation

Codecov / codecov/patch

src/DataTableComponent.php#L141

Added line #L141 was not covered by tests
}

if (isset($this->slot)){
$view->section($this->slot);

Check warning on line 145 in src/DataTableComponent.php

View check run for this annotation

Codecov / codecov/patch

src/DataTableComponent.php#L145

Added line #L145 was not covered by tests
}

$view->with([
'columns' => $this->getColumns(),
'rows' => $this->getRows(),
'customView' => $this->customView(),
]);

return $view;
}
}
8 changes: 8 additions & 0 deletions src/Traits/ComponentUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ trait ComponentUtilities

protected $tdAttributesCallback;

protected string $layout;

protected string $slot;

protected string $extends;

protected string $section;

protected bool $collapsingColumnsStatus = true;

protected string $emptyMessage = 'No items found. Try to broaden your search.';
Expand Down
28 changes: 28 additions & 0 deletions src/Traits/Configuration/ComponentConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,32 @@ public function setQueryStringAlias(string $queryStringAlias): self

return $this;
}

public function setLayout(string $layout): self
{
$this->layout = $layout;

return $this;
}

public function setSlot(string $slot): self
{
$this->slot = $slot;

return $this;
}

public function setExtends(string $layout): self
{
$this->extends = $layout;

return $this;
}

public function setSection(string $section): self
{
$this->section = $section;

return $this;
}
}
20 changes: 20 additions & 0 deletions src/Traits/Helpers/ComponentHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ public function getModel()
return $this->model;
}

public function getExtends()
{
return $this->extends;
}

public function getSection()
{
return $this->section;
}

public function getSlot()
{
return $this->slot;
}

public function getLayout()
{
return $this->layout;
}

public function setTheme(): void
{
$theme = $this->getTheme();
Expand Down
28 changes: 28 additions & 0 deletions tests/Traits/Configuration/ComponentConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,34 @@ public function can_set_empty_message(): void
$this->assertEquals('My empty message', $this->basicTable->getEmptyMessage());
}

/** @test */
public function can_set_extends(): void
{
$this->basicTable->setExtends('app.layout');
$this->assertEquals('app.layout', $this->basicTable->getExtends());
}

/** @test */
public function can_set_layout(): void
{
$this->basicTable->setLayout('app.layout');
$this->assertEquals('app.layout', $this->basicTable->getLayout());
}

/** @test */
public function can_set_section(): void
{
$this->basicTable->setSection('content');
$this->assertEquals('content', $this->basicTable->getSection());
}

/** @test */
public function can_set_slot(): void
{
$this->basicTable->setSlot('my_slot');
$this->assertEquals('my_slot', $this->basicTable->getSlot());
}

/** @test */
public function can_set_offline_indicator_status(): void
{
Expand Down

0 comments on commit 0e96d7b

Please sign in to comment.