Skip to content

Commit

Permalink
Refactoring Structure (#1350)
Browse files Browse the repository at this point in the history
* Refactor structure

* Prevent applySummaries from being unnecessary

* Add persist to computed

* wip

* refactoring

* Pint

* Fix getWireAttributes
  • Loading branch information
luanfreitasdev authored Jan 25, 2024
1 parent 2e5e92b commit 9fea61d
Show file tree
Hide file tree
Showing 25 changed files with 398 additions and 399 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
},
"scripts": {
"pint:fix": "./vendor/bin/pint",
"test": "@test:sqlite --bail",
"test": "@test:sqlite",
"test:pint": "./vendor/bin/pint --test",
"test:sqlite": [
"./vendor/bin/pest --compact"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Actions/ActionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Blade;
use Illuminate\View\ComponentAttributeBag;
use PowerComponents\LivewirePowerGrid\{Button, PowerGridComponent, Traits\UnDot};
use PowerComponents\LivewirePowerGrid\{Button, Components\Concerns\UnDot, PowerGridComponent};

class ActionsController
{
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/UnDot.php → src/Components/Concerns/UnDot.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace PowerComponents\LivewirePowerGrid\Traits;
namespace PowerComponents\LivewirePowerGrid\Components\Concerns;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\{Arr, Collection};
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Filters/FilterBoolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static function getWireAttributes(string $field, string $title): array
{
return collect()
->put('selectAttributes', new ComponentAttributeBag([
'wire:input.blur' => 'filterBoolean(\'' . $field . '\', $event.target.value, \'' . $title . '\')',
'wire:model' => 'filters.boolean.' . $field,
'wire:input.live.debounce.600ms' => 'filterBoolean(\'' . $field . '\', $event.target.value, \'' . $title . '\')',
'wire:model' => 'filters.boolean.' . $field,
]))->toArray();
}
}
4 changes: 2 additions & 2 deletions src/Components/Filters/FilterSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static function getWireAttributes(string $field, string $title): array
{
return collect()
->put('selectAttributes', new ComponentAttributeBag([
'wire:model' => 'filters.select.' . $field,
'wire:input.debounce.600ms' => 'filterSelect(\'' . $field . '\', \'' . $title . '\')',
'wire:model' => 'filters.select.' . $field,
'wire:input.live.debounce.600ms' => 'filterSelect(\'' . $field . '\', \'' . $title . '\')',
]))
->toArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Rules/RulesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use PowerComponents\LivewirePowerGrid\Traits\UnDot;
use PowerComponents\LivewirePowerGrid\Components\Concerns\UnDot;

class RulesController
{
Expand Down
94 changes: 94 additions & 0 deletions src/Concerns/Base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace PowerComponents\LivewirePowerGrid\Concerns;

use PowerComponents\LivewirePowerGrid\ProcessDataSource;

trait Base
{
public string $primaryKey = 'id';

public bool $ignoreTablePrefix = true;

public string $tableName = 'default';

public array $setUp = [];

public bool $showErrorBag = false;

public bool $rowIndex = true;

public array $searchMorphs = [];

public bool $deferLoading = false;

public bool $readyToLoad = false;

public string $loadingComponent = '';

public array $columns = [];

protected ?ProcessDataSource $processDataSourceInstance = null;

public array $actions = [];

public array $headers = [];

public string $search = '';

public string $currentTable = '';

public array $relationSearch = [];

public int $total = 0;

public int $totalCurrentPage = 0;

public function template(): ?string
{
return null;
}

public function relationSearch(): array
{
return [];
}

public function searchMorphs(): array
{
return [];
}

public function header(): array
{
return [];
}

public function setUp(): array
{
return [];
}

public function columns(): array
{
return [];
}

public function filters(): array
{
return [];
}

/**
* @return null
*/
public function datasource()
{
return null;
}

public function summarizeFormat(): array
{
return [];
}
}
4 changes: 2 additions & 2 deletions src/Traits/WithCheckbox.php → src/Concerns/Checkbox.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace PowerComponents\LivewirePowerGrid\Traits;
namespace PowerComponents\LivewirePowerGrid\Concerns;

use Exception;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Pagination\AbstractPaginator;
use PowerComponents\LivewirePowerGrid\Components\Rules\RulesController;
use Throwable;

trait WithCheckbox
trait Checkbox
{
public bool $checkbox = false;

Expand Down
Loading

0 comments on commit 9fea61d

Please sign in to comment.