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

[4.x] Add Bool for Action to Display Left Side Of Table #1222

Closed
wants to merge 1 commit into from
Closed
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
31 changes: 31 additions & 0 deletions resources/views/components/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ class="{{ $theme->table->thClass }}"
/>
@endif

@if($displayActionsFirst)

@if (isset($actions) && count($actions))
@php
$responsiveActionsColumnName = PowerComponents\LivewirePowerGrid\Responsive::ACTIONS_COLUMN_NAME;

$isActionFixedOnResponsive = isset($this->setUp['responsive']) && in_array($responsiveActionsColumnName, data_get($this->setUp, 'responsive.fixedColumns')) ? true : false;
@endphp

<th
@if($isActionFixedOnResponsive) fixed @endif
class="{{ $theme->table->thClass . ' ' . $theme->table->thActionClass }}"

style="{{ $theme->table->thStyle . ' ' . $theme->table->thActionStyle }} width: max-content; cursor:pointer;"
wire:key="{{ md5('actions') }}"
>
{{ trans('livewire-powergrid::datatable.labels.action') }}
</th>
@endif
@endif

@foreach ($columns as $column)
<x-livewire-powergrid::cols
:column="$column"
Expand Down Expand Up @@ -177,6 +198,16 @@ class="{{ $class }}"
])
@endif

@if($displayActionsFirst)
<x-livewire-powergrid::actions
:primary-key="$primaryKey"
:tableName="$tableName"
:theme="$theme"
:row="$row"
:actions="$actions"
/>
@endif

@include('livewire-powergrid::components.row', ['rowIndex' => $loop->index + 1])

<x-livewire-powergrid::actions
Expand Down
8 changes: 8 additions & 0 deletions src/PowerGridComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class PowerGridComponent extends Component

public bool $showFilters = false;

public bool $displayActionsFirst = false;

protected ?ProcessDataSource $processDataSourceInstance = null;

public function mount(): void
Expand Down Expand Up @@ -126,6 +128,12 @@ public function showCheckBox(string $attribute = 'id'): PowerGridComponent
return $this;
}

public function showActionsFirst(string $attribute = 'id'): PowerGridComponent
{
$this->displayActionsFirst = true;
return $this;
}

private function resolveTotalRow(): void
{
collect($this->columns)->each(function (Column $column) {
Expand Down
Loading