Skip to content

Commit

Permalink
Adjust PowerGrid facade
Browse files Browse the repository at this point in the history
  • Loading branch information
luanfreitasdev committed Sep 18, 2024
1 parent 665d62e commit 3688fb4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 42 deletions.
4 changes: 1 addition & 3 deletions docs/release-notes-and-upgrade/upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;// [!code ++]
```js
import './../../vendor/power-components/livewire-powergrid/dist/powergrid.css' // [!code --]

import './../../vendor/power-components/livewire-powergrid/dist/bootstrap5.css' // [!code ++]
// or
import './../../vendor/power-components/livewire-powergrid/dist/tailwind.css' // [!code ++]
import './../../vendor/power-components/livewire-powergrid/dist/tailwind.css' // [!code ++] // bootstrap5.css

```

Expand Down
37 changes: 19 additions & 18 deletions docs/table-component/component-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ Example:
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Responsive;// [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Responsive::make()// [!code ++:2]
PowerGrid::responsive()// [!code ++:2]
->fixedColumns('id', 'name', Responsive::ACTIONS_COLUMN_NAME),
];
}
Expand Down Expand Up @@ -300,14 +300,14 @@ Example:
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Detail; // [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Detail::make()// [!code ++:4]
PowerGrid::detail()// [!code ++:4]
->view('components.detail')
->showCollapseIcon()
->params(['name' => 'Luan', 'custom_data' => 'foobar']),
Expand All @@ -330,14 +330,14 @@ By default, PowerGrid will keep the open state of other details when you toggle
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Detail; // [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Detail::make()// [!code ++:5]
PowerGrid::detail()// [!code ++:5]
->view('components.detail')
->params(['name' => 'Luan', 'custom_parameter' => 'foobar'])
->showCollapseIcon()
Expand Down Expand Up @@ -365,14 +365,14 @@ In the next example, only 25 lines will be loaded initially. Additional items wi
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Lazy;// [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Lazy::make()// [!code ++:2]
PowerGrid::lazy()// [!code ++:2]
->rowsPerChildren(25),
];
}
Expand All @@ -399,15 +399,15 @@ When calling `toggleDetail` on the child component, `toggleDetailFromChild` will
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Lazy;// [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]
use Livewire\Attributes\On;// [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Lazy::make()// [!code ++:3]
PowerGrid::lazy()// [!code ++:3]
->rowsPerChildren(25)
->dispatchAfterToggleDetail('toggleDetailFromChild'),
];
Expand Down Expand Up @@ -491,15 +491,16 @@ The next example demonstrates how to use Cache in your Component, prefixing the
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Cache;
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
Cache::make()// [!code ++:3]
->forever()
->prefix(auth()->id . '_'), //result: 1_powergrid-dish-DishTable
return [
PowerGrid::cache()// [!code ++:3]
->prefix(auth()->id . '_'), //result: 1_powergrid-dish-DishTable
]
}
}
```
Expand All @@ -511,9 +512,10 @@ use PowerComponents\LivewirePowerGrid\Cache;

public function setUp(): array
{
Cache::make()// [!code ++:3]
->forever(),
->customTag('my-custom-tag'),
return [
PowerGrid::cache()// [!code ++:3]
->customTag('my-custom-tag'),
]
}
```

Expand Down Expand Up @@ -556,7 +558,6 @@ Here you can find all the methods available in the `LivewirePowerGrid\Cache` cla

| Method | Description |
|-------|--------------|
| `forever()` | Creates a cache using the [rememberForever](https://laravel.com/docs/cache#retrieve-store) method. |
| `ttl()` | Maximum time in seconds for which the data can be cached. |
| `customTag()` | Allows you to set a custom cache tag. |
| `prefix()` | Sets a prefix for the cache tag. |
Expand Down
20 changes: 12 additions & 8 deletions docs/table-features/exporting-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ To configure the feature, proceed to chain to `make()` as many [Data Export Conf
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Traits\WithExport;
use PowerComponents\LivewirePowerGrid\Exportable; // [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;
class DishTable extends PowerGridComponent
{
use WithExport;
public function setUp(): array
{
Exportable::make(fileName: 'my-export-file') // [!code ++]
PowerGrid::exportable(fileName: 'my-export-file') // [!code ++]
->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV), // [!code ++]
}
}
Expand Down Expand Up @@ -114,14 +115,15 @@ Example:
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Traits\WithExport;
use PowerComponents\LivewirePowerGrid\Exportable;
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;

class DishTable extends PowerGridComponent
{
use WithExport;

public function setUp(): array
{
Exportable::make(fileName: 'my-export-file') // [!code ++:5]
PowerGRid::exportable(fileName: 'my-export-file') // [!code ++:5]
->columnWidth([
2 => 30,
4 => 20,
Expand All @@ -146,14 +148,15 @@ Example:
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Traits\WithExport;
use PowerComponents\LivewirePowerGrid\Exportable;
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;

class DishTable extends PowerGridComponent
{
use WithExport;

public function setUp(): array
{
Exportable::make(fileName: 'my-export-file') // [!code ++:2]
PowerGrid::exportable(fileName: 'my-export-file') // [!code ++:2]
->stripe('A6ACCD'),
}
}
Expand Down Expand Up @@ -203,13 +206,14 @@ Example:
use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Traits\WithExport;
use PowerComponents\LivewirePowerGrid\Exportable;
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;

class DishTable extends PowerGridComponent
{
public function setUp()
{
return [
Exportable::make('export')// [!code ++:6]
PowerGrid::exportable('export')// [!code ++:6]
->striped()
->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV)
->queues(6)
Expand Down Expand Up @@ -300,14 +304,14 @@ class DishTable extends PowerGridComponent

### make()

Make new `PowerGrid\Exportable` class.
Make new `\PowerComponents\LivewirePowerGrid\Facades\PowerGrid;` facade.

| Parameters | Description |
|-----------------------|---------------------------------------------------|
| (string) $fileName | Name of the file that will contain exported data |

```php
Exportable::make(fileName: 'my-export-file'),
PowerGrid::exportable(fileName: 'my-export-file'),
```

---
Expand All @@ -323,7 +327,7 @@ Set the file types available for data exporting.
Example:

```php
Exportable::make('my-export-file')
PowerGrid::exportable('my-export-file')
->type(types: Exportable::TYPE_XLS, Exportable::TYPE_CSV),
```

Expand All @@ -339,7 +343,7 @@ When exporting to CSV, you may configure the `field separator` and `field delimi
| (string) $delimiter | CSV Delimiter |

```php
Exportable::make('my-export-file')
PowerGrid::exportable('my-export-file')
->type(Exportable::TYPE_CSV)
->csvSeparator(separator: '|')
->csvDelimiter(delimiter: "'"),
Expand Down
26 changes: 13 additions & 13 deletions docs/table-features/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ On this page, you can find information on customizing pagination settings. You m

PowerGrid includes an easy-to-configure built-in Pagination system.

To enable pagination, you must add a call to the `Footer::make()` class in your Component's `setUp()` method. Then, proceed to chain the `showPerPage()` method to the `Footer` class.
To enable pagination, you must add a call to the `PowerGrid::footer()` class in your Component's `setUp()` method. Then, proceed to chain the `showPerPage()` method to the `Footer` class.

Example:

```php
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Footer; // [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Footer::make()// [!code ++]
PowerGrid::footer()// [!code ++]
->showPerPage(perPage: 10, perPageValues: [0, 50, 100, 500]), // [!code ++]
];
}
Expand All @@ -54,14 +54,14 @@ Example:
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Footer;
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Footer::make()// [!code ++]
PowerGrid::footer()// [!code ++]
->showPerPage() // [!code --]
->showRecordCount(mode: 'full'), // [!code ++]
];
Expand Down Expand Up @@ -89,14 +89,14 @@ Example:
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Footer; // [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Footer::make()// [!code ++]
PowerGrid::footer()// [!code ++]
->showRecordCount(mode: 'full'), // [!code ++]
];
}
Expand All @@ -117,14 +117,14 @@ The `DishTable` component uses the `dishPage` parameter from the URL, while the
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Footer; // [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Footer::make()// [!code ++:2]
PowerGrid::footer()// [!code ++:2]
->pageName('dishPage'),
];
}
Expand All @@ -135,14 +135,14 @@ class DishTable extends PowerGridComponent
// app/Livewire/UserTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Footer; // [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class UserTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Footer::make()// [!code ++:2]
PowerGrid::footer()// [!code ++:2]
->pageName('userPage'),
];
}
Expand Down Expand Up @@ -172,14 +172,14 @@ Your custom component will have access to the `$perPage` and `$perPageValues` pr
// app/Livewire/DishTable.php

use PowerComponents\LivewirePowerGrid\PowerGridComponent;
use PowerComponents\LivewirePowerGrid\Footer; // [!code ++]
use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++]

class DishTable extends PowerGridComponent
{
public function setUp(): array
{
return [
Footer::make()// [!code ++]
PowerGrid::footer()// [!code ++]
->showPerPage(25)// [!code ++]
->showRecordCount()// [!code ++]
->pagination(viewPath: 'components.pagination'),// [!code ++]
Expand Down

0 comments on commit 3688fb4

Please sign in to comment.