Skip to content

Commit

Permalink
Merge pull request #682 from rappasoft/develop
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
rappasoft authored Mar 30, 2022
2 parents 2465eae + 1658b19 commit 139daac
Show file tree
Hide file tree
Showing 338 changed files with 15,698 additions and 7,012 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,13 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.1, 8.0, 7.4]
laravel: [8.*, 9.*]
stability: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
php: [8.0, 8.1]
laravel: [9.*]
stability: [prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*
exclude:
- laravel: 9.*
php: 7.4
- laravel: 8.*
php: 8.1
stability: prefer-lowest
testbench: 7.0

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -48,4 +40,4 @@ jobs:
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit
run: vendor/bin/phpunit
448 changes: 199 additions & 249 deletions CHANGELOG.md

Large diffs are not rendered by default.

16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ You can install the package via composer:
composer require rappasoft/laravel-livewire-tables
```

You must also have [Alpine.js](https://alpinejs.dev) version 3 or greater installed and available to the component.

## Documentation and Usage Instructions

See the [documentation](https://rappasoft.com/docs/laravel-livewire-tables) for detailed installation and usage instructions.
Expand Down Expand Up @@ -61,19 +63,7 @@ class UsersTable extends DataTableComponent
}
```

### [See advanced example](https://rappasoft.com/docs/laravel-livewire-tables/v1/usage/advanced-example-table)

## To-do/Roadmap

- [x] Bootstrap 4 Template
- [x] Bootstrap 5 Template
- [x] Sorting By Relationships
- [x] User Column Selection
- [x] Drag & Drop (beta)
- [x] Column Search
- [x] Greater Configurability
- [ ] Collection/Query Support
- [ ] Test Suite (WIP)
### [See advanced example](https://rappasoft.com/docs/laravel-livewire-tables/v2/usage/advanced-example-table)

## Testing

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"ext-sqlite3": "*",
"orchestra/testbench": "^6.13|^7.0",
"phpunit/phpunit": "^9.3",
"spatie/laravel-ray": "^1.9",
"vimeo/psalm": "^4.4"
"spatie/laravel-ray": "^1.9"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions database/migrations/create_test_tables.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CreateTestTables extends Migration

Schema::create('pets', function (Blueprint $table) {
$table->id();
$table->integer('sort')->default(0);
$table->string('name')->index();
$table->string('age')->nullable();
$table->date('last_visit')->nullable();
Expand Down
4 changes: 2 additions & 2 deletions docs/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: v1
title: v2
slogan: A dynamic table component for Laravel Livewire.
githubUrl: https://github.com/rappasoft/laravel-livewire-tables
branch: v1
branch: master
---
2 changes: 1 addition & 1 deletion docs/bulk-actions/_index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
title: Bulk Actions
weight: 6
weight: 8
---
135 changes: 135 additions & 0 deletions docs/bulk-actions/available-methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: Available Methods
weight: 4
---

These are the available configuration methods for bulk actions.

---

## setBulkActions

Set the bulk actions array.

```php
public function configure(): void
{
$this->setBulkActions([
'exportSelected' => 'Export',
]);
}
```

---

## setBulkActionsStatus

**Enabled by default**, enable/disable bulk actions for the component.

```php
public function configure(): void
{
$this->setBulkActionsStatus(true);
$this->setBulkActionsStatus(false);
}
```

## setBulkActionsEnabled

Enable bulk actions on the component.

```php
public function configure(): void
{
// Shorthand for $this->setBulkActionsStatus(true)
$this->setBulkActionsEnabled();
}
```

## setBulkActionsDisabled

Disable bulk actions on the component.

```php
public function configure(): void
{
// Shorthand for $this->setBulkActionsStatus(false)
$this->setBulkActionsDisabled();
}
```

---

## setSelectAllStatus

**Disabled by default**, enable/disable pre-selection of all bulk action check boxes.

```php
public function configure(): void
{
$this->setSelectAllStatus(true);
$this->setSelectAllStatus(false);
}
```

## setSelectAllEnabled

Check all bulk action checkboxes.

```php
public function configure(): void
{
// Shorthand for $this->setSelectAllStatus(true)
$this->setSelectAllEnabled();
}
```

## setSelectAllDisabled

Deselect the select-all bulk actions checkbox.

```php
public function configure(): void
{
// Shorthand for $this->setSelectAllStatus(false)
$this->setSelectAllDisabled();
}
```

---

## setHideBulkActionsWhenEmptyStatus

**Disabled by default**, enable/disable hiding of bulk actions dropdown when empty.

```php
public function configure(): void
{
$this->setHideBulkActionsWhenEmptyStatus(true);
$this->setHideBulkActionsWhenEmptyStatus(false);
}
```

## setHideBulkActionsWhenEmptyEnabled

Hide bulk actions dropdown when empty.

```php
public function configure(): void
{
// Shorthand for $this->setHideBulkActionsWhenEmptyStatus(true)
$this->setHideBulkActionsWhenEmptyEnabled();
}
```

## setHideBulkActionsWhenEmptyDisabled

Show bulk actions dropdown when empty.

```php
public function configure(): void
{
// Shorthand for $this->setHideBulkActionsWhenEmptyStatus(false)
$this->setHideBulkActionsWhenEmptyDisabled();
}
```
38 changes: 19 additions & 19 deletions docs/bulk-actions/creating-bulk-actions.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
---
title: Creating bulk actions
title: Creating Bulk Actions
weight: 2
---

To create bulk actions, you must specify a `method` and a `button title` in the `$bulkActions` component property.
There are 3 ways to define your bulk actions.

They all do the same thing except provide different levels of flexibility.

The **key** is the Livewire method to call, and the value is the name of the item in the bulk actions dropdown.

## Property

The first way to define your bulk actions is with the `bulkActions` component property:

```php
public array $bulkActions = [
'exportSelected' => 'Export',
];
```

------
## Method

**The following method is only available in v1.16 and above**

As of v1.16 you can define bulk action with a method, so you can perform other actions to determine what your actions are or perform translations on the strings:
You can also use the `bulkActions` method on the component:

```php
public function bulkActions(): array
{
// Figure out what actions the admin gets
...

return [
'activate' => __('Activate'),
'deactivate' => __('Deactivate'),
'exportSelected' => 'Export',
];
}
```

------
## Configuration

The **key** is the Livewire method to call, and the value is the name of the item in the bulk actions dropdown.

You can define your method to do whatever you want:
You can also set them via the component's configure method:

```php
public function exportSelected()
public function configure(): void
{
// Do something with the selected rows.
$this->setBulkActions([
'exportSelected' => 'Export',
]);
}
```

See [Getting the selected rows query](./getting-the-selected-rows-query) or [Getting the selected keys](./getting-the-selected-keys) to understand how to work with the selected data.
27 changes: 0 additions & 27 deletions docs/bulk-actions/getting-the-selected-keys.md

This file was deleted.

19 changes: 0 additions & 19 deletions docs/bulk-actions/getting-the-selected-rows-query.md

This file was deleted.

4 changes: 3 additions & 1 deletion docs/bulk-actions/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Introduction
weight: 1
---

Bulk actions are a way for you to perform methods on selected rows, a full-page, or all rows, at the same time.
Bulk actions are a way for you to perform methods on selected rows or all rows at the same time.

By default, bulk actions are hidden. I.e. the bulk action selector, and the left-hand checkboxes do not appear until you specify at least one bulk action.

![Bulk Actions](https://imgur.com/fD3ZAbU.gif)
42 changes: 42 additions & 0 deletions docs/bulk-actions/processing-bulk-actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: Processing Bulk Actions
weight: 3
---

To process your bulk action you must have a method on the component with the same name as the key in the bulk actions array:

```php
public array $bulkActions = [
'exportSelected' => 'Export',
];

public function exportSelected()
{

}
```

You have access to the `selectedKeys` method to grab the IDs of the rows that were selected:

```php
public function exportSelected()
{
foreach($this->getSelected() as $item)
{
// These are strings since they came from an HTML element
}
}
```

## Resetting

After you process your action you'll probably want to reset the screen back to normal, for this you can call the `clearSelected` method at the end:

```php
public function exportSelected()
{
...

$this->clearSelected();
}
```
Loading

0 comments on commit 139daac

Please sign in to comment.