Skip to content

Commit

Permalink
refactor component
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev committed Sep 21, 2023
1 parent 613fa8d commit 3a3c5ae
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 212 deletions.
4 changes: 2 additions & 2 deletions resources/views/components/checkbox-row.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@php
$rulesValues = $actionRulesClass->recoverFromAction($row, 'pg:checkbox');
$inputAttributes = new \Illuminate\View\ComponentAttributeBag([
'class' => $theme->checkbox->inputClass,
]);
if (filled($rulesValues['setAttributes'])) {
foreach ($rulesValues['setAttributes'] as $rulesAttributes) {
$inputAttributes = $inputAttributes->merge([
Expand Down
14 changes: 7 additions & 7 deletions resources/views/components/editable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
$resolveContent = function (string $currentTable, string $field, \Illuminate\Database\Eloquent\Model|\stdClass $row): ?string {
$currentField = $field;
$replace = fn($content) => preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
/** @codeCoverageIgnore */
if (str_contains($currentField, '.')) {
$data = \Illuminate\Support\Str::of($field)->explode('.');
$table = $data->get(0);
$field = $data->get(1);
if ($table === $currentTable) {
return $replace($row->{$field});
}
return $replace($row->{$table}->{$field});
}
return $replace($row->{$field});
};
$fallback = html_entity_decode(strval(data_get($editable, 'fallback')), ENT_QUOTES, 'utf-8');
$value = html_entity_decode(strval($resolveContent($currentTable, $field, $row)), ENT_QUOTES, 'utf-8');
$content = !empty($value) || $value == '0' ? $value : $fallback;
$params = [
'theme' => $theme->name,
'tableName' => $tableName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class="mt-2 md:mt-0"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-90"
class="py-3"
wire:key="{{ uniqid() }}"
wire:key="filter-{{ uniqid() }}"
>
@php
$customConfig = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'justify-between' => filled(data_get($setUp, 'footer.perPage')),
'justify-end' => blank(data_get($setUp, 'footer.perPage')),
'md:flex md:flex-row w-full items-center py-3 bg-white overflow-y-auto pl-2 pr-2 relative
dark:bg-pg-primary-900' => blank(
dark:bg-pg-primary-900' => blank(
data_get($setUp, 'footer.pagination')),
])>
@if (filled(data_get($setUp, 'footer.perPage')) &&
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/radio-row.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@php
$rulesValues = $actionRulesClass->recoverFromAction($row, 'pg:radio');
$inputAttributes = new \Illuminate\View\ComponentAttributeBag([
'class' => $theme->radio->inputClass,
]);
if (filled($rulesValues['setAttributes'])) {
foreach ($rulesValues['setAttributes'] as $rulesAttributes) {
$inputAttributes = $inputAttributes->merge([
Expand Down
32 changes: 30 additions & 2 deletions resources/views/components/row.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
@props([
'rowIndex' => 0,
])

@includeWhen(isset($setUp['responsive']), powerGridThemeRoot() . '.toggle-detail-responsive', [
'theme' => $theme->table,
'rowId' => $rowId,
'view' => data_get($setUp, 'detail.viewIcon') ?? null,
])

@php
$ruleDetailView = data_get($rulesValues, 'detailView');
@endphp

@includeWhen(data_get($setUp, 'detail.showCollapseIcon'), powerGridThemeRoot() . '.toggle-detail', [
'theme' => $theme->table,
'view' => data_get($setUp, 'detail.viewIcon') ?? null,
])

@includeWhen($radio, 'livewire-powergrid::components.radio-row', [
'attribute' => $row->{$radioAttribute},
])

@includeWhen($checkbox, 'livewire-powergrid::components.checkbox-row', [
'attribute' => $row->{$checkboxAttribute},
])

@foreach ($columns as $column)
@php
$content = $row->{$column->field} ?? null;
Expand All @@ -11,9 +38,10 @@
$contentClass = array_key_exists($content, $column->contentClasses) ? $column->contentClasses[$content] : '';
}
@endphp
<td @class([$theme->table->tdBodyClass, $column->bodyClass])
<td
@class([$theme->table->tdBodyClass, $column->bodyClass])
style="{{ $column->hidden === true ? 'display:none' : '' }}; {{ $theme->table->tdBodyStyle . ' ' . $column->bodyStyle ?? '' }}"
wire:key="row-{{ $column->field }}-{{ uniqid() }}"
wire:key="row-{{ $column->field }}"
>
<div class="flex gap-2 w-full">
<!-- Render Action -->
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/table-base.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class="{{ $theme->theadClass }}"
class="{{ $theme->tbodyClass }}"
style="{{ $theme->tbodyStyle }}"
>
{{ $rows }}
{{ $body }}
</tbody>
@else
<tbody
Expand Down
Loading

0 comments on commit 3a3c5ae

Please sign in to comment.