Skip to content

Commit 300929b

Browse files
lrljoegithub-actions[bot]
authored andcommitted
Fix styling
1 parent 54f0e53 commit 300929b

File tree

3 files changed

+49
-60
lines changed

3 files changed

+49
-60
lines changed

src/Traits/Helpers/TableAttributeHelpers.php

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,24 +103,21 @@ public function getTrAttributes(Model $row, int $index): array
103103
public function getTrAttributesBag(Model $row, int $index): ComponentAttributeBag
104104
{
105105
$default = [
106-
'id' => $this->getTableName()."-row-".$row->{$this->getPrimaryKey()},
106+
'id' => $this->getTableName().'-row-'.$row->{$this->getPrimaryKey()},
107107
'loopType' => $index % 2 === 0 ? 'even' : 'odd',
108108
'rowpk' => $row->{$this->getPrimaryKey()},
109-
'x-on:dragstart.self' => "currentlyReorderingStatus && dragStart(event)",
110-
'x-on:drop.prevent' => "currentlyReorderingStatus && dropEvent(event)",
111-
'x-on:dragover.prevent.throttle.500ms' => "currentlyReorderingStatus && dragOverEvent(event)",
112-
'x-on:dragleave.prevent.throttle.500ms' => "currentlyReorderingStatus && dragLeaveEvent(event)",
113-
':draggable' => "currentlyReorderingStatus",
114-
'wire:key' => $this->getTableName()."-tablerow-tr-".$row->{$this->getPrimaryKey()},
109+
'x-on:dragstart.self' => 'currentlyReorderingStatus && dragStart(event)',
110+
'x-on:drop.prevent' => 'currentlyReorderingStatus && dropEvent(event)',
111+
'x-on:dragover.prevent.throttle.500ms' => 'currentlyReorderingStatus && dragOverEvent(event)',
112+
'x-on:dragleave.prevent.throttle.500ms' => 'currentlyReorderingStatus && dragLeaveEvent(event)',
113+
':draggable' => 'currentlyReorderingStatus',
114+
'wire:key' => $this->getTableName().'-tablerow-tr-'.$row->{$this->getPrimaryKey()},
115115
];
116116

117-
if($this->hasDisplayLoadingPlaceholder())
118-
{
119-
$default['wire:loading.class.add'] = "hidden d-none";
120-
}
121-
else
122-
{
123-
$default['wire:loading.class.delay'] = "opacity-50 dark:bg-gray-900 dark:opacity-60";
117+
if ($this->hasDisplayLoadingPlaceholder()) {
118+
$default['wire:loading.class.add'] = 'hidden d-none';
119+
} else {
120+
$default['wire:loading.class.delay'] = 'opacity-50 dark:bg-gray-900 dark:opacity-60';
124121
}
125122

126123
return new ComponentAttributeBag(array_merge($default, $this->getTrAttributes($row, $index)));
@@ -135,28 +132,25 @@ public function getTdAttributes(Column $column, Model $row, int $colIndex, int $
135132
#[Computed]
136133
public function getTdAttributesBag(Column $column, Model $row, int $colIndex, int $rowIndex): ComponentAttributeBag
137134
{
138-
$default = [
139-
'wire:key' => $this->getTableName() . '-table-td-'.$row->{$this->getPrimaryKey()}.'-'.$column->getSlug(),
135+
$default = [
136+
'wire:key' => $this->getTableName().'-table-td-'.$row->{$this->getPrimaryKey()}.'-'.$column->getSlug(),
140137
'default' => true,
141138
'default-colors' => true,
142139
'default-styling' => true,
143140
];
144-
if($column->isClickable())
145-
{
146-
if($this->getTableRowUrlTarget($row) === 'navigate') {
141+
if ($column->isClickable()) {
142+
if ($this->getTableRowUrlTarget($row) === 'navigate') {
147143
$default['wire:navigate'] = '';
148144
$default['href'] = $this->getTableRowUrl($row);
149-
}
150-
else
151-
{
145+
} else {
152146
$target = $this->getTableRowUrlTarget($row) ?? '_self';
153147
$default['onclick'] = "window.open('".$this->getTableRowUrl($row)."', '".$target."')";
154-
}
148+
}
155149
}
150+
156151
return new ComponentAttributeBag(array_merge($default, $this->getTdAttributes($column, $row, $colIndex, $rowIndex)));
157152
}
158153

159-
160154
public function hasTableRowUrl(): bool
161155
{
162156
return isset($this->trUrlCallback);

src/Traits/Styling/Helpers/BulkActionStylingHelpers.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers;
44

5-
use Illuminate\View\ComponentAttributeBag;
65
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\View\ComponentAttributeBag;
77
use Livewire\Attributes\Computed;
88

99
trait BulkActionStylingHelpers
@@ -83,13 +83,14 @@ public function getBulkActionsThCheckboxAttributes(): array
8383
public function getBulkActionsTdAttributesNew(string $rowPrimaryKey): array
8484
{
8585
$default = [
86-
'wire:key' => $this->getTableName() ."-tbody-td-bulk-actions-".$rowPrimaryKey,
87-
':displayMinimisedOnReorder' => "true",
86+
'wire:key' => $this->getTableName().'-tbody-td-bulk-actions-'.$rowPrimaryKey,
87+
':displayMinimisedOnReorder' => 'true',
8888
];
89+
8990
return array_merge($default, $this->getBulkActionsTdAttributes());
9091
}
9192

92-
/**
93+
/**
9394
* Used to get attributes for the Bulk Actions TD
9495
*
9596
* @return array<mixed>
@@ -99,7 +100,6 @@ public function getBulkActionsTdAttributes(): array
99100
return $this->getCustomAttributes('bulkActionsTdAttributes');
100101
}
101102

102-
103103
/**
104104
* Used to get attributes for the Bulk Actions TD
105105
*
@@ -108,7 +108,6 @@ public function getBulkActionsTdAttributes(): array
108108
public function getBulkActionsTdCheckboxAttributes(): array
109109
{
110110

111-
112111
return $this->getCustomAttributes('bulkActionsTdCheckboxAttributes');
113112

114113
}
@@ -117,20 +116,19 @@ public function getBulkActionsTdCheckboxAttributesNew(string $rowPrimaryKey): ar
117116
{
118117
$default = [
119118
'x-cloak' => '',
120-
'x-show' => "!currentlyReorderingStatus",
121-
'x-model' => "selectedItems",
122-
'wire:key' => $this->getTableName()."-selectedItems-".$rowPrimaryKey,
123-
'id' => $this->getTableName()."-row-bac-".$rowPrimaryKey,
119+
'x-show' => '!currentlyReorderingStatus',
120+
'x-model' => 'selectedItems',
121+
'wire:key' => $this->getTableName().'-selectedItems-'.$rowPrimaryKey,
122+
'id' => $this->getTableName().'-row-bac-'.$rowPrimaryKey,
124123
'value' => $rowPrimaryKey,
125-
'wire:loading.attr.delay' => "disabled",
126-
'type' => "checkbox",
124+
'wire:loading.attr.delay' => 'disabled',
125+
'type' => 'checkbox',
127126
];
128127

129128
return array_merge($default, $this->getBulkActionsTdCheckboxAttributes());
130129

131130
}
132131

133-
134132
/**
135133
* Used to get attributes for the Bulk Actions Row Buttons
136134
*

tests/Unit/Traits/Configuration/BulkActionsStylingConfigurationTest.php

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ public function test_can_set_bulk_actions_checkbox_attributes(): void
145145
'value' => '5',
146146
'wire:loading.attr.delay' => 'disabled',
147147
'type' => 'checkbox',
148-
'default' => true,
149-
'default-colors' => false,
150-
'default-styling' => false
151-
],
152-
$this->basicTable->getBulkActionsTdCheckboxAttributesNew(5));
148+
'default' => true,
149+
'default-colors' => false,
150+
'default-styling' => false,
151+
],
152+
$this->basicTable->getBulkActionsTdCheckboxAttributesNew(5));
153153

154154
$this->assertSame([
155155
'x-cloak' => '',
@@ -160,36 +160,33 @@ public function test_can_set_bulk_actions_checkbox_attributes(): void
160160
'value' => '14',
161161
'wire:loading.attr.delay' => 'disabled',
162162
'type' => 'checkbox',
163-
'default' => true,
164-
'default-colors' => false,
165-
'default-styling' => false
166-
],
167-
$this->basicTable->getBulkActionsTdCheckboxAttributesNew(14));
163+
'default' => true,
164+
'default-colors' => false,
165+
'default-styling' => false,
166+
],
167+
$this->basicTable->getBulkActionsTdCheckboxAttributesNew(14));
168168

169169
}
170170

171-
172171
public function test_can_set_bulk_actions_td_attributes(): void
173172
{
174173
$this->assertSame([
175174
'wire:key' => 'table-tbody-td-bulk-actions-5',
176175
':displayMinimisedOnReorder' => 'true',
177-
'default' => true,
178-
'default-colors' => false,
179-
'default-styling' => false
180-
],
181-
$this->basicTable->getBulkActionsTdAttributesNew(5));
176+
'default' => true,
177+
'default-colors' => false,
178+
'default-styling' => false,
179+
],
180+
$this->basicTable->getBulkActionsTdAttributesNew(5));
182181

183182
$this->assertSame([
184183
'wire:key' => 'table-tbody-td-bulk-actions-14',
185184
':displayMinimisedOnReorder' => 'true',
186-
'default' => true,
187-
'default-colors' => false,
188-
'default-styling' => false
189-
],
190-
$this->basicTable->getBulkActionsTdAttributesNew(14));
185+
'default' => true,
186+
'default-colors' => false,
187+
'default-styling' => false,
188+
],
189+
$this->basicTable->getBulkActionsTdAttributesNew(14));
191190

192191
}
193-
194-
195192
}

0 commit comments

Comments
 (0)