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

v3.4.14 #1890

Merged
merged 31 commits into from
Aug 25, 2024
Merged

v3.4.14 #1890

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
30d65ac
Add explanation of setRefreshMethod (#1857)
lrljoe Aug 16, 2024
b3137d9
Unlocking Entangled Items (#1859)
lrljoe Aug 17, 2024
b6890e9
Add dispatch on updated filter components (#1861)
lrljoe Aug 18, 2024
fb646a5
v3.4.8
lrljoe Aug 18, 2024
4a18b05
Merge branch 'master' into development
lrljoe Aug 18, 2024
8eafffe
Fix superfluous bulk actions tr < (#1868)
lrljoe Aug 21, 2024
d1a563f
Default useComputedProperties to False (#1869)
lrljoe Aug 21, 2024
da50aa1
Update ChangeLog
lrljoe Aug 21, 2024
1ff4126
Merge branch 'master' into development
lrljoe Aug 21, 2024
74c35e2
Add Action Buttons (#1864)
lrljoe Aug 21, 2024
46d2752
FixDateRangeFilter (#1872)
lrljoe Aug 23, 2024
7aa4268
Adjust Methods - useComputedProperties (#1873)
lrljoe Aug 23, 2024
3456674
Update ChangeLog
lrljoe Aug 23, 2024
6480f1a
Merge branch 'master' into development
lrljoe Aug 23, 2024
32fe628
AllowDeleteDateRangeFilter (#1875)
lrljoe Aug 23, 2024
1f0c14d
Fix ChangeLog
lrljoe Aug 23, 2024
b80be2d
Update Docs (#1876)
lrljoe Aug 23, 2024
f0c5d04
Update ChangeLog - Add Docs Update
lrljoe Aug 23, 2024
ec5401a
Add setIconLeft/setIconRight (#1877)
lrljoe Aug 23, 2024
ae019cf
Adjust ChangeLog
lrljoe Aug 23, 2024
8e33fba
Merge branch 'master' into development
lrljoe Aug 23, 2024
edc7ea3
Adjust Action Button Icon Margin (#1880)
lrljoe Aug 23, 2024
79cf988
Merge branch 'master' into development
lrljoe Aug 23, 2024
6766707
Change Order of "Getting Started" section (#1883)
lrljoe Aug 24, 2024
39c5032
Add Button with No Icon (#1887)
lrljoe Aug 25, 2024
918bd31
Add a "Recommended" approach (#1886)
lrljoe Aug 25, 2024
1d18cb2
v3.4.13
lrljoe Aug 25, 2024
683666f
Merge branch 'master' into development
lrljoe Aug 25, 2024
8cafe98
Set actions position (#1889)
lrljoe Aug 25, 2024
5007627
Update ChangeLog
lrljoe Aug 25, 2024
b927a98
Merge branch 'master' into development
lrljoe Aug 25, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-livewire-tables` will be documented in this file

## [v3.4.14] - 2024-08-25
### New Features
- Set Action Position (Left/Center/Right) and Set Actions in Toolbar by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1889

## [v3.4.13] - 2024-08-25
### Bug Fixes
- Fix for Action Button with no icon by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1887
Expand Down
55 changes: 55 additions & 0 deletions docs/misc/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,61 @@ This is used to set attributes for the "div" that wraps all defined Action Butto
}
```

### setActionsInToolbarEnabled

Displays the Actions within the Toolbar. Default is displaying above the Toolbar.

```php
public function configure(): void
{
$this->setActionsInToolbarEnabled();
}
```

### setActionsInToolbarDisabled

Displays the Actions above the Toolbar, default behaviour
```php
public function configure(): void
{
$this->setActionsInToolbarDisabled();
}
```


### setActionsLeft

Displays the Actions justified to the left

```php
public function configure(): void
{
$this->setActionsLeft();
}
```

### setActionsCenter

Displays the Actions justified to the center

```php
public function configure(): void
{
$this->setActionsCenter();
}
```

### setActionsRight

Displays the Actions justified to the right

```php
public function configure(): void
{
$this->setActionsRight();
}
```

### actions()

Define your actions using the actions() method:
Expand Down
15 changes: 10 additions & 5 deletions resources/views/components/includes/actions.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<div {{ $attributes
->merge($this->getActionWrapperAttributes())
->class(['flex flex-cols justify-center' => $this->isTailwind && $this->getActionWrapperAttributes()['default-styling'] ?? true])
->class(['' => $this->isTailwind && $this->getActionWrapperAttributes()['default-colors'] ?? true])
->class(['d-flex flex-cols justify-center' => $this->isBootstrap && $this->getActionWrapperAttributes()['default-styling'] ?? true])
->class(['' => $this->isBootstrap && $this->getActionWrapperAttributes()['default-colors'] ?? true])
->merge($this->getActionWrapperAttributes)
->class(['flex flex-cols py-2 space-x-2' => $this->isTailwind && $this->getActionWrapperAttributes['default-styling'] ?? true])
->class(['' => $this->isTailwind && $this->getActionWrapperAttributes['default-colors'] ?? true])
->class(['d-flex flex-cols py-2 space-x-2' => $this->isBootstrap && $this->getActionWrapperAttributes['default-styling'] ?? true])
->class(['' => $this->isBootstrap && $this->getActionWrapperAttributes['default-colors'] ?? true])
->class(['justify-start' => $this->getActionsPosition == 'left'])
->class(['justify-center' => $this->getActionsPosition == 'center'])
->class(['justify-end' => $this->getActionsPosition == 'right'])
->class(['pl-2' => $this->showActionsInToolbar && $this->getActionsPosition == 'left'])
->class(['pr-2' => $this->showActionsInToolbar && $this->getActionsPosition == 'right'])
->except(['default-styling','default-colors'])
}} >
@foreach($this->getActions as $action)
Expand Down
8 changes: 8 additions & 0 deletions resources/views/components/tools/toolbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<x-livewire-tables::tools.toolbar.items.filter-button />
@endif

@if($this->hasActions && $this->showActionsInToolbar && $this->getActionsPosition == 'left')
<x-livewire-tables::includes.actions/>
@endif

@if ($this->hasConfigurableAreaFor('toolbar-left-end'))
<div x-cloak x-show="!currentlyReorderingStatus" @class([
'mb-3 mb-md-0 input-group' => $this->isBootstrap,
Expand All @@ -56,6 +60,10 @@
@include($this->getConfigurableAreaFor('toolbar-right-start'), $this->getParametersForConfigurableArea('toolbar-right-start'))
@endif

@if($this->hasActions && $this->showActionsInToolbar && $this->getActionsPosition == 'right')
<x-livewire-tables::includes.actions/>
@endif

@if ($this->showBulkActionsDropdownAlpine() && $this->shouldAlwaysHideBulkActionsDropdownOption != true)
<x-livewire-tables::tools.toolbar.items.bulk-actions />
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/datatable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div x-data="laravellivewiretable($wire, '{{ $this->showBulkActionsDropdownAlpine() }}', '{{ $tableId }}', '{{ $primaryKey }}')">
<x-livewire-tables::wrapper :component="$this" :tableName="$tableName" :$primaryKey :$isTailwind :$isBootstrap :$isBootstrap4 :$isBootstrap5>
@if(method_exists($this,'hasActions') && $this->hasActions())
@if($this->hasActions && !$this->showActionsInToolbar)
<x-livewire-tables::includes.actions/>
@endif

Expand Down
52 changes: 52 additions & 0 deletions src/Traits/Configuration/ActionsConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Configuration;

trait ActionsConfiguration
{
public function setActionWrapperAttributes(array $actionWrapperAttributes): self
{
$this->actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes];

return $this;
}

public function setActionsInToolbar(bool $status): self
{
$this->displayActionsInToolbar = $status;

return $this;
}

public function setActionsInToolbarEnabled(): self
{
return $this->setActionsInToolbar(true);
}

public function setActionsInToolbarDisabled(): self
{
return $this->setActionsInToolbar(false);
}

protected function setActionsPosition(string $position): self
{
$this->actionsPosition = ($position == 'left' || $position == 'center' || $position == 'right') ? $position : 'right';

return $this;
}

public function setActionsLeft(): self
{
return $this->setActionsPosition('left');
}

public function setActionsCenter(): self
{
return $this->setActionsPosition('center');
}

public function setActionsRight(): self
{
return $this->setActionsPosition('right');
}
}
46 changes: 46 additions & 0 deletions src/Traits/Helpers/ActionsHelpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Rappasoft\LaravelLivewireTables\Traits\Helpers;

use Illuminate\Support\Collection;
use Livewire\Attributes\Computed;
use Rappasoft\LaravelLivewireTables\Views\Action;

trait ActionsHelpers
{
#[Computed]
public function showActionsInToolbar(): bool
{
return $this->displayActionsInToolbar ?? false;
}

#[Computed]
public function getActionsPosition(): string
{
return $this->actionsPosition ?? 'right';
}

#[Computed]
public function getActionWrapperAttributes(): array
{
return [...['class' => '', 'default-styling' => true, 'default-colors' => true], ...$this->actionWrapperAttributes];
}

#[Computed]
public function hasActions(): bool
{
return (new Collection($this->actions()))
->filter(fn ($action) => $action instanceof Action)->count() > 0;
}

#[Computed]
public function getActions(): Collection
{
return (new Collection($this->actions()))
->filter(fn ($action) => $action instanceof Action)
->each(function (Action $action, int $key) {
$action->setTheme($this->getTheme());
});

}
}
43 changes: 9 additions & 34 deletions src/Traits/WithActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,22 @@

namespace Rappasoft\LaravelLivewireTables\Traits;

use Illuminate\Support\Collection;
use Livewire\Attributes\Computed;
use Rappasoft\LaravelLivewireTables\Views\Action;
use Rappasoft\LaravelLivewireTables\Traits\Configuration\ActionsConfiguration;
use Rappasoft\LaravelLivewireTables\Traits\Helpers\ActionsHelpers;

trait WithActions
{
protected array $actionWrapperAttributes = ['default-styling' => true, 'default-colors' => true];
use ActionsConfiguration,
ActionsHelpers;

protected function actions(): array
{
return [];
}
protected array $actionWrapperAttributes = ['class' => '', 'default-styling' => true, 'default-colors' => true];

public function setActionWrapperAttributes(array $actionWrapperAttributes): self
{
$this->actionWrapperAttributes = [...['default-styling' => true, 'default-colors' => true], ...$actionWrapperAttributes];
protected bool $displayActionsInToolbar = false;

return $this;
}
protected string $actionsPosition = 'right';

#[Computed]
public function getActionWrapperAttributes(): array
{
return [...['default-styling' => true, 'default-colors' => true], ...$this->actionWrapperAttributes];
}

#[Computed]
public function hasActions(): bool
{
return (new Collection($this->actions()))
->filter(fn ($action) => $action instanceof Action)->count() > 0;
}

#[Computed]
public function getActions(): Collection
protected function actions(): array
{
return (new Collection($this->actions()))
->filter(fn ($action) => $action instanceof Action)
->each(function (Action $action, int $key) {
$action->setTheme($this->getTheme());
});

return [];
}
}
6 changes: 3 additions & 3 deletions src/Views/Traits/Actions/HasActionAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

trait HasActionAttributes
{
protected array $actionAttributes = ['default-styling' => true, 'default-colors' => true];
protected array $actionAttributes = ['class' => '', 'default-styling' => true, 'default-colors' => true];

public function setActionAttributes(array $actionAttributes): self
{
$this->actionAttributes = [...['default-styling' => true, 'default-colors' => true], ...$actionAttributes];
$this->actionAttributes = [...$this->actionAttributes, ...$actionAttributes];

return $this;
}

public function getActionAttributes(): ComponentAttributeBag
{
$actionAttributes = [...['default-styling' => true, 'default-colors' => true], ...$this->actionAttributes];
$actionAttributes = [...['class' => '', 'default-styling' => true, 'default-colors' => true], ...$this->actionAttributes];

if (! $this->hasWireAction() && method_exists($this, 'getRoute')) {
$actionAttributes['href'] = $this->getRoute();
Expand Down
6 changes: 3 additions & 3 deletions src/Views/Traits/Core/HasIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait HasIcon
{
public ?string $icon;

public array $iconAttributes = ['default-styling' => true];
public array $iconAttributes = ['class' => '', 'default-styling' => true];

public bool $iconRight = true;

Expand All @@ -32,14 +32,14 @@ public function getIcon(): string

public function setIconAttributes(array $iconAttributes): self
{
$this->iconAttributes = [...['default-styling' => true], ...$iconAttributes];
$this->iconAttributes = [...$this->iconAttributes, ...$iconAttributes];

return $this;
}

public function getIconAttributes(): ComponentAttributeBag
{
return new ComponentAttributeBag([...['default-styling' => true], ...$this->iconAttributes]);
return new ComponentAttributeBag([...['class' => '', 'default-styling' => true], ...$this->iconAttributes]);
}

public function getIconRight(): bool
Expand Down
Loading
Loading