Skip to content

Commit 0d8c657

Browse files
committed
Hide configurable areas when reordering
1 parent 81410c2 commit 0d8c657

File tree

7 files changed

+146
-2
lines changed

7 files changed

+146
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
## [2.4.0] - 2022-04-30
8+
79
### Added
810

911
- Added table event listeners to sort/filter/clear from other components.
1012
- Added text filter.
1113
- Added $row as second parameter to BooleanColumn `setCallback()`.
1214
- Added `setThSortButtonAttributes()` to set attributes for th sort button.
15+
- Added `setHideConfigurableAreasWhenReorderingStatus()` to hide configurable areas when reordering status which now defaults to true.
1316

1417
### Changed
1518

@@ -630,7 +633,8 @@ Ground Up Rebuild
630633

631634
- Initial release
632635

633-
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.3.0...development
636+
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.4.0...development
637+
[2.4.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.3.0...v2.4.0
634638
[2.3.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.2.1...v2.3.0
635639
[2.2.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.2.0...v2.2.1
636640
[2.2.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.1.0...v2.2.0

docs/datatable/configurable-areas.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,43 @@ public function configure(): void
2929

3030
**Note:** Only specify the keys you are actually implementing, otherwise you may get uneven spacing.
3131

32+
### setHideConfigurableAreasWhenReorderingStatus
33+
34+
Defaults to **true**, set whether or not configurable areas are hidden during reordering.
35+
36+
```php
37+
public function configure(): void
38+
{
39+
$this->setHideConfigurableAreasWhenReorderingStatus(true);
40+
$this->setHideConfigurableAreasWhenReorderingStatus(false);
41+
}
42+
```
43+
44+
### setHideConfigurableAreasWhenReorderingEnabled
45+
46+
Hide configurable areas when reordering.
47+
48+
```php
49+
public function configure(): void
50+
{
51+
// Shorthand for $this->setHideConfigurableAreasWhenReorderingStatus(true)
52+
$this->setHideConfigurableAreasWhenReorderingEnabled();
53+
}
54+
```
55+
56+
### setHideConfigurableAreasWhenReorderingDisabled
57+
58+
Show configurable areas when reordering.
59+
60+
```php
61+
public function configure(): void
62+
{
63+
// Shorthand for $this->setHideConfigurableAreasWhenReorderingStatus(false)
64+
$this->setHideConfigurableAreasWhenReorderingDisabled();
65+
}
66+
```
67+
68+
3269
## Example View
3370

3471
Example dropdown for the toolbar:

src/Traits/ComponentUtilities.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ trait ComponentUtilities
3535
protected $collapsingColumnsStatus = true;
3636
protected string $emptyMessage = 'No items found. Try to broaden your search.';
3737
protected array $additionalSelects = [];
38+
protected bool $hideConfigurableAreasWhenReorderingStatus = true;
3839
protected array $configurableAreas = [
3940
'toolbar-left-start' => null,
4041
'toolbar-left-end' => null,

src/Traits/Configuration/ComponentConfiguration.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,36 @@ public function setConfigurableAreas(array $areas): self
323323

324324
return $this;
325325
}
326+
327+
/**
328+
* @param bool $status
329+
*
330+
* @return $this
331+
*/
332+
public function setHideConfigurableAreasWhenReorderingStatus(bool $status): self
333+
{
334+
$this->hideConfigurableAreasWhenReorderingStatus = $status;
335+
336+
return $this;
337+
}
338+
339+
/**
340+
* @return $this
341+
*/
342+
public function setHideConfigurableAreasWhenReorderingEnabled(): self
343+
{
344+
$this->setHideConfigurableAreasWhenReorderingStatus(true);
345+
346+
return $this;
347+
}
348+
349+
/**
350+
* @return $this
351+
*/
352+
public function setHideConfigurableAreasWhenReorderingDisabled(): self
353+
{
354+
$this->setHideConfigurableAreasWhenReorderingStatus(false);
355+
356+
return $this;
357+
}
326358
}

src/Traits/Helpers/ComponentHelpers.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ public function getConfigurableAreas(): array
354354
*/
355355
public function hasConfigurableAreaFor(string $area): bool
356356
{
357+
if ($this->hideConfigurableAreasWhenReorderingIsEnabled() && $this->reorderIsEnabled() && $this->currentlyReorderingIsEnabled()) {
358+
return false;
359+
}
360+
357361
return isset($this->configurableAreas[$area]) && $this->getConfigurableAreaFor($area) !== null;
358362
}
359363

@@ -366,4 +370,28 @@ public function getConfigurableAreaFor(string $area): ?string
366370
{
367371
return $this->configurableAreas[$area] ?? null;
368372
}
373+
374+
/**
375+
* @return bool
376+
*/
377+
public function getHideConfigurableAreasWhenReorderingStatus(): bool
378+
{
379+
return $this->hideConfigurableAreasWhenReorderingStatus;
380+
}
381+
382+
/**
383+
* @return bool
384+
*/
385+
public function hideConfigurableAreasWhenReorderingIsEnabled(): bool
386+
{
387+
return $this->getHideConfigurableAreasWhenReorderingStatus() === true;
388+
}
389+
390+
/**
391+
* @return bool
392+
*/
393+
public function hideConfigurableAreasWhenReorderingIsDisabled(): bool
394+
{
395+
return $this->getHideConfigurableAreasWhenReorderingStatus() === false;
396+
}
369397
}

tests/Traits/Configuration/ComponentConfigurationTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,26 @@ public function can_set_tr_url_target(): void
250250

251251
$this->assertSame($this->basicTable->getTableRowUrlTarget(1), '_blank');
252252
}
253+
254+
/** @test */
255+
public function can_set_hide_configurable_areas_when_reordering_status(): void
256+
{
257+
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
258+
259+
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(false);
260+
261+
$this->assertFalse($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
262+
263+
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(true);
264+
265+
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
266+
267+
$this->basicTable->setHideConfigurableAreasWhenReorderingDisabled();
268+
269+
$this->assertFalse($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
270+
271+
$this->basicTable->setHideConfigurableAreasWhenReorderingEnabled();
272+
273+
$this->basicTable->setHideConfigurableAreasWhenReorderingStatus(true);
274+
}
253275
}

tests/Traits/Helpers/ComponentHelpersTest.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function can_check_if_table_has_page_name(): void
110110
/** @test */
111111
public function can_get_eager_load_relations_status(): void
112112
{
113-
$this->assertFalse($this->basicTable->getEagerLoadAllRelationsStatus());
113+
$this->assertFalse($this->basicTable->getHideReorderColumnUnlessReorderingStatus());
114114

115115
$this->assertFalse($this->basicTable->eagerLoadAllRelationsIsEnabled());
116116

@@ -183,4 +183,24 @@ public function can_get_configurable_areas(): void
183183

184184
$this->assertEquals('includes.areas.toolbar-left-start', $this->basicTable->getConfigurableAreaFor('toolbar-left-start'));
185185
}
186+
187+
/** @test */
188+
public function can_get_hide_configurable_areas_when_reordering_status(): void
189+
{
190+
$this->assertTrue($this->basicTable->getHideConfigurableAreasWhenReorderingStatus());
191+
192+
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
193+
194+
$this->basicTable->setHideConfigurableAreasWhenReorderingDisabled();
195+
196+
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsDisabled());
197+
198+
$this->assertFalse($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
199+
200+
$this->basicTable->setHideConfigurableAreasWhenReorderingEnabled();
201+
202+
$this->assertTrue($this->basicTable->hideConfigurableAreasWhenReorderingIsEnabled());
203+
204+
$this->assertFalse($this->basicTable->hideConfigurableAreasWhenReorderingIsDisabled());
205+
}
186206
}

0 commit comments

Comments
 (0)