Skip to content
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
10 changes: 3 additions & 7 deletions resources/views/components/table/td/bulk-actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@
'inline-flex rounded-md shadow-sm' => $isTailwind,
'form-check' => $isBootstrap5,
])>
<input
x-cloak x-show="!currentlyReorderingStatus"
x-model="selectedItems"
wire:key="{{ $tableName . 'selectedItems-'.$row->{$primaryKey} }}"
wire:loading.attr.delay="disabled"
<input wire:key="{{ $tableName . 'selectedItems-'.$row->{$primaryKey} }}"
value="{{ $row->{$primaryKey} }}"
type="checkbox"
{{
$attributes->merge($bulkActionsTdCheckboxAttributes)->class([
'rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600' => ($isTailwind) && ($bulkActionsTdCheckboxAttributes['default'] ?? true),
'border-gray-300 text-indigo-600 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600' => ($isTailwind) && (($bulkActionsTdCheckboxAttributes['default'] ?? true) || ($bulkActionsTdCheckboxAttributes['default-colors'] ?? true)),
'rounded shadow-sm transition duration-150 ease-in-out focus:ring focus:ring-opacity-50' => ($isTailwind) && (($bulkActionsTdCheckboxAttributes['default'] ?? true) || ($bulkActionsTdCheckboxAttributes['default-styling'] ?? true)),
'form-check-input' => ($isBootstrap5) && ($bulkActionsTdCheckboxAttributes['default'] ?? true),
])->except(['default','default-styling','default-colors'])
}}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/table/th/bulk-actions.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@aware(['isTailwind', 'isBootstrap'])
@aware(['tableName','isTailwind', 'isBootstrap'])
@php
$customAttributes = $this->hasBulkActionsThAttributes ? $this->getBulkActionsThAttributes : $this->getAllThAttributes($this->getBulkActionsColumn())['customAttributes'];
$bulkActionsThCheckboxAttributes = $this->getBulkActionsThCheckboxAttributes();
@endphp

@if ($this->bulkActionsAreEnabled() && $this->hasBulkActions())
<x-livewire-tables::table.th.plain :displayMinimisedOnReorder="true" wire:key="{{ $this->getTableName }}-thead-bulk-actions" :$customAttributes>
<x-livewire-tables::table.th.plain :displayMinimisedOnReorder="true" wire:key="{{ $tableName }}-thead-bulk-actions" :$customAttributes>
<div
x-data="{newSelectCount: 0, indeterminateCheckbox: false, bulkActionHeaderChecked: false}"
x-init="$watch('selectedItems', value => indeterminateCheckbox = (value.length > 0 && value.length < paginationTotalItemCount))"
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Styling/HasBulkActionsStyling.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait HasBulkActionsStyling

protected array $bulkActionsTdAttributes = ['default' => true];

protected array $bulkActionsTdCheckboxAttributes = ['default' => true];
protected array $bulkActionsTdCheckboxAttributes = ['default' => true, 'default-colors' => false, 'default-styling' => false];

protected array $bulkActionsButtonAttributes = ['default-colors' => true, 'default-styling' => true];

Expand Down
16 changes: 14 additions & 2 deletions src/Traits/Styling/Helpers/BulkActionStylingHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,25 @@ public function getBulkActionsTdAttributes(): array
}

/**
* Used to get attributes for the Bulk Actions TD
* Used to get attributes for the Bulk Actions TD Checkbox
*
* @return array<mixed>
*/
public function getBulkActionsTdCheckboxAttributes(): array
{
return $this->getCustomAttributes('bulkActionsTdCheckboxAttributes');
$array = array_merge(
[
'x-cloak',
'x-show' => '!currentlyReorderingStatus',
'x-model' => 'selectedItems',
'wire:loading.attr.delay' => 'disabled',
'type' => 'checkbox',
],
$this->getCustomAttributes('bulkActionsTdCheckboxAttributes')
);
ksort($array);

return $array;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function test_can_set_bulk_actions_attributes_via_provider(string $setMet
'default' => $default,
'default-colors' => $defaultColors,
'default-styling' => $defaultStyling,
], $this->basicTable->{$getMethod}());
], collect($this->basicTable->{$getMethod}())->only(['class', 'default', 'default-colors', 'default-styling'])->toArray());

$this->basicTable->{$setMethod}([
'default' => $default,
Expand All @@ -92,7 +92,7 @@ public function test_can_set_bulk_actions_attributes_via_provider(string $setMet
'default' => $default,
'default-colors' => ! $defaultColors,
'default-styling' => $defaultStyling,
], $this->basicTable->{$getMethod}());
], collect($this->basicTable->{$getMethod}())->only(['class', 'default', 'default-colors', 'default-styling'])->toArray());
}

#[DataProvider('bulkActionAttributesProvider')]
Expand All @@ -107,7 +107,7 @@ public function test_can_get_bulk_actions_attributes_bag_via_provider(string $se

$this->basicTable->{$setMethod}($data);

$this->assertSame($data, $this->basicTable->{$getMethod}());
$this->assertSame($data, collect($this->basicTable->{$getMethod}())->only(['class', 'default', 'default-colors', 'default-styling'])->toArray());

$attributeBag = new ComponentAttributeBag($data);

Expand All @@ -121,11 +121,26 @@ public function test_bulk_actions_td_attributes_returns_default_true_if_not_set(

public function test_bulk_actions_td_checkbox_attributes_returns_default_true_if_not_set(): void
{
$this->assertSame(['default' => true, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getBulkActionsTdCheckboxAttributes());
$data = [
'x-cloak',
'x-show' => '!currentlyReorderingStatus',
'x-model' => 'selectedItems',
'wire:loading.attr.delay' => 'disabled',
'type' => 'checkbox',
'default' => true,
'default-colors' => false,
'default-styling' => false,
];
ksort($data);
$returnedData = $this->basicTable->getBulkActionsTdCheckboxAttributes();
ksort($returnedData);

$this->assertSame($data, $returnedData);
}

public function test_bulk_actions_th_attributes_returns_default_true_if_not_set(): void
{

$this->assertSame(['default' => true, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getBulkActionsThAttributes());
}

Expand Down