Skip to content

Commit

Permalink
add visibleColumns property
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev committed Oct 23, 2023
1 parent a418338 commit a6b4ed7
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 101 deletions.
80 changes: 40 additions & 40 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@ class="btn btn-light dropdown-toggle"
<x-livewire-powergrid::icons.eye-off width="20" />
</button>
<ul class="dropdown-menu">
@foreach ($columns as $column)
@if (!$column->forceHidden)
<li
wire:click="$dispatch('pg:toggleColumn-{{ $tableName }}', { field: '{{ $column->field }}'})"
wire:key="toggle-column-{{ $column->field }}"
@foreach ($this->visibleColumns as $column)
<li
wire:click="$dispatch('pg:toggleColumn-{{ $tableName }}', { field: '{{ $column->field }}'})"
wire:key="toggle-column-{{ $column->field }}"
>
<a
class="dropdown-item"
href="#"
>
<a
class="dropdown-item"
href="#"
>
@if ($column->hidden === false)
<x-livewire-powergrid::icons.eye width="20" />
@else
<x-livewire-powergrid::icons.eye-off width="20" />
@endif
{!! $column->title !!}
</a>
</li>
@endif
@if ($column->hidden === false)
<x-livewire-powergrid::icons.eye width="20" />
@else
<x-livewire-powergrid::icons.eye-off width="20" />
@endif
{!! $column->title !!}
</a>
</li>
@endforeach
</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,21 @@ class="pg-btn-white dark:ring-pg-primary-600 dark:border-pg-primary-600 dark:hov
x-transition:leave-end="opacity-0 scale-90"
class="mt-2 py-2 w-48 bg-white shadow-xl absolute z-10 dark:bg-pg-primary-700"
>

@foreach ($columns as $column)
@if (!$column->forceHidden)
<div
@foreach ($this->visibleColumns as $column)
<div
wire:click="$dispatch('pg:toggleColumn-{{ $tableName }}', { field: '{{ $column->field }}'})"
wire:key="toggle-column-{{ $column->field }}"
class="@if ($column->hidden) opacity-40 bg-pg-primary-300 dark:bg-pg-primary-800 @endif cursor-pointer flex justify-start block px-4 py-2 text-pg-primary-800 hover:bg-pg-primary-50 hover:text-black-200 dark:text-pg-primary-200 dark:hover:bg-gray-900 dark:hover:bg-pg-primary-700"
>
@if (!$column->hidden)
<x-livewire-powergrid::icons.eye class="text-pg-primary-500 dark:text-pg-primary-300" />
@else
<x-livewire-powergrid::icons.eye-off class="text-pg-primary-500 dark:text-pg-primary-300" />
@endif
<div class="ml-2">
{!! $column->title !!}
</div>
>
@if (!$column->hidden)
<x-livewire-powergrid::icons.eye class="text-pg-primary-500 dark:text-pg-primary-300" />
@else
<x-livewire-powergrid::icons.eye-off class="text-pg-primary-500 dark:text-pg-primary-300" />
@endif
<div class="ml-2">
{!! $column->title !!}
</div>
@endif
</div>
@endforeach
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/inline-filters.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class="{{ $tdClasses }}"
></td>
@endif

@foreach ($columns as $column)
@foreach ($this->visibleColumns as $column)
<td
class="{{ $theme->table->tdBodyClass }}"
wire:key="column-filter-{{ $column->field }}"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'attribute' => $row->{$checkboxAttribute},
])

@foreach ($columns as $column)
@foreach ($this->visibleColumns as $column)
@php
$content = $row->{$column->field} ?? null;
$contentClassField = $column->contentClassField != '' ? $row->{$column->contentClassField} : '';
Expand Down
1 change: 0 additions & 1 deletion resources/views/components/table-base.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class="{{ $theme->theadClass }}"
<tbody
class="{{ $theme->tbodyClass }}"
style="{{ $theme->tbodyStyle }}"
wire:key="tableBody-{{ uniqid() }}"
>
{{ $body }}
</tbody>
Expand Down
10 changes: 5 additions & 5 deletions resources/views/components/table-footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ class="{{ $theme->table->tdBodyClass }}"
@if ($checkbox)
<td></td>
@endif
@foreach ($columns as $column)
@foreach ($this->visibleColumns as $column)
<td
class="{{ $theme->table->tdBodyClassTotalColumns . ' ' . $column->bodyClass ?? '' }}"
style="{{ $column->hidden === true ? 'display:none' : '' }}; {{ $theme->table->tdBodyStyleTotalColumns . ' ' . $column->bodyStyle ?? '' }}"
>
@include('livewire-powergrid::components.summarize', [
'sum' => $column->sum['footer'] ? data_get($column, 'summarize.sum') : null,
'labelSum' => $column->sum['label'],
'count' => $column->count['footer'] ? data_get($column, 'summarize.count') : null,
'labelCount' => $column->count['label'],
'min' => $column->min['footer'] ? data_get($column, 'summarize.min') : null,
'labelMin' => $column->min['label'],
'max' => $column->max['footer'] ? data_get($column, 'summarize.max') : null,
'labelMax' => $column->max['label'],
'avg' => $column->avg['footer'] ? data_get($column, 'summarize.avg') : null,
'labelAvg' => $column->avg['label'],
])
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/table-header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@if($checkbox)
<td class="{{ $theme->table->tdBodyClass }}" style="{{ $theme->table->tdBodyStyle }}"></td>
@endif
@foreach ($columns as $column)
@foreach ($this->visibleColumns as $column)
<td class="{{ $theme->table->tdBodyClassTotalColumns . ' '.$column->bodyClass ?? '' }}"
style="{{ $column->hidden === true ? 'display:none': '' }}; {{$theme->table->tdBodyStyleTotalColumns . ' '.$column->bodyStyle ?? '' }}">
@include('livewire-powergrid::components.summarize', [
Expand Down
Loading

0 comments on commit a6b4ed7

Please sign in to comment.