Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
nikuscs authored and github-actions[bot] committed Feb 14, 2023
1 parent f71da89 commit 54c2334
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 63 deletions.
14 changes: 0 additions & 14 deletions src/Core/Concerns/EvaluatesClosures.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,17 @@ trait EvaluatesClosures
{
/**
* The identifier used to inject the component into the evaluation closure.
*
* @var string
*/
protected string $evaluationIdentifier;

/**
* The parameters that should be removed from the evaluation closure.
*
* @var array
*/
protected array $evaluationParametersToRemove = [];

/**
* Stolen from Filament, evaluate the closure with given params, and exclude some.
*
* @param $value
* @param array $parameters
* @param array $exceptParameters
* @return mixed
*/
protected function evaluate($value, array $parameters = [], array $exceptParameters = [])
Expand All @@ -48,8 +41,6 @@ protected function evaluate($value, array $parameters = [], array $exceptParamet

/**
* Get the default params that should be always injected
*
* @return array
*/
protected function getDefaultEvaluationParameters(): array
{
Expand All @@ -59,8 +50,6 @@ protected function getDefaultEvaluationParameters(): array
/**
* Resolve the given evaluation parameter.
*
* @param string $parameter
* @param Closure $value
* @return mixed|null
*/
protected function resolveEvaluationParameter(string $parameter, Closure $value)
Expand All @@ -74,9 +63,6 @@ protected function resolveEvaluationParameter(string $parameter, Closure $value)

/**
* Determine if the given evaluation parameter should be removed.
*
* @param string $parameter
* @return bool
*/
protected function isEvaluationParameterRemoved(string $parameter): bool
{
Expand Down
3 changes: 0 additions & 3 deletions src/Core/Concerns/Makable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ trait Makable
{
/**
* Quick static constructor.
*
* @param array $args
* @return static
*/
public static function make(array $args = []): static
{
Expand Down
14 changes: 12 additions & 2 deletions src/Core/Integrations/VanillaHybridly.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public function __construct(
protected ?string $url = null,
protected array $query = [],
protected array $options = [],
){}
) {
}

public function reload(bool|Closure $reload = true): static
{
Expand Down Expand Up @@ -48,21 +49,24 @@ public function preserve(bool|Closure $state = true, bool|Closure $scroll = true
public function replace(bool|Closure $replace = true): static
{
$this->options['replace'] = $this->evaluate($replace);

return $this;
}

public function method(string|Closure $method = 'POST'): static
{
$this->options['method'] = $this->evaluate($method);

return $this;
}

public function post(array|Closure $data = []): static
{
$data = $this->evaluate($data);
if(!empty($data)){
if (! empty($data)) {
$this->data($data);
}

return $this->method();
}

Expand Down Expand Up @@ -94,6 +98,7 @@ public function only(array|Closure $keys): static
$this->evaluate($keys)
)
);

return $this;
}

Expand All @@ -105,6 +110,7 @@ public function except(array|Closure $keys): static
$this->evaluate($keys)
)
);

return $this;
}

Expand All @@ -116,6 +122,7 @@ public function headers(array|Closure $headers): static
$this->evaluate($headers)
)
);

return $this;
}

Expand All @@ -125,6 +132,7 @@ public function data(array|Closure $data = []): static
Arr::get($this->options, 'data', []),
$this->evaluate($data)
);

return $this;
}

Expand All @@ -136,6 +144,7 @@ public function query(array|Closure $params = []): self
$params
)
);

return $this;
}

Expand All @@ -147,6 +156,7 @@ public function options(array|Closure $options = []): static
$this->evaluate($options)
)
);

return $this;
}

Expand Down
15 changes: 12 additions & 3 deletions src/Core/Integrations/VanillaInertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public function __construct(
protected ?string $url = null,
protected array $query = [],
protected array $options = [],
){}
) {
}

public function reload(bool|Closure $reload = true): static
{
Expand Down Expand Up @@ -48,21 +49,24 @@ public function preserve(bool|Closure $state = true, bool|Closure $scroll = true
public function replace(bool|Closure $replace = true): static
{
$this->options['replace'] = $this->evaluate($replace);

return $this;
}

public function method(string|Closure $method = 'POST'): static
{
$this->options['method'] = $this->evaluate($method);

return $this;
}

public function post(array|Closure $data = []): static
{
$data = $this->evaluate($data);
if(!empty($data)){
if (! empty($data)) {
$this->data($data);
}

return $this->method();
}

Expand Down Expand Up @@ -94,6 +98,7 @@ public function only(array|Closure $keys): static
$this->evaluate($keys)
)
);

return $this;
}

Expand All @@ -105,6 +110,7 @@ public function headers(array|Closure $headers): static
$this->evaluate($headers)
)
);

return $this;
}

Expand All @@ -114,6 +120,7 @@ public function data(array|Closure $data = []): static
Arr::get($this->options, 'data', []),
$this->evaluate($data)
);

return $this;
}

Expand All @@ -125,6 +132,7 @@ public function query(array|Closure $params = []): self
$params
)
);

return $this;
}

Expand All @@ -136,6 +144,7 @@ public function options(array|Closure $options = []): static
$this->evaluate($options)
)
);

return $this;
}

Expand All @@ -149,7 +158,7 @@ public function toArray(): array
'method' => 'GET',
'preserveState' => true,
'preserveScroll' => true,
],$this->options)),
], $this->options)),
];
}

Expand Down
4 changes: 3 additions & 1 deletion src/Datatables/Actions/Concerns/HasRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
namespace Flavorly\VanillaComponents\Datatables\Actions\Concerns;

use Closure;
use Flavorly\VanillaComponents\Core\Integrations\VanillaInertia;

trait HasRedirect
{
protected ?string $redirectTo = null;

protected bool $redirectToNewTab = false;

public function redirect(Closure|string $url, Closure|bool $openInNewTab = false): static
{
$this->redirectTo = $this->evaluate($url);
$this->redirectToNewTab = $this->evaluate($openInNewTab);

return $this;
}

public function redirectToRoute(Closure|string $route, Closure|bool $openInNewTab = false): static
{
$this->redirect(route($this->evaluate($route)), $openInNewTab);

return $this;
}

Expand Down
1 change: 0 additions & 1 deletion src/Datatables/Concerns/HasOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

trait HasOptions
{
/** @var array */
protected array $options = [];

public function options(): array|Options
Expand Down
1 change: 0 additions & 1 deletion src/Datatables/Concerns/HasPolling.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

trait HasPolling
{
/** @var array */
protected array $pollingOptions = [];

public function polling(): array|Polling
Expand Down
1 change: 0 additions & 1 deletion src/Datatables/Concerns/HasTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

trait HasTranslations
{
/** @var array */
protected array $translations = [];

protected function getDefaultTranslations(): array
Expand Down
29 changes: 0 additions & 29 deletions src/Datatables/Concerns/InteractsWithQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@ trait InteractsWithQueryBuilder
{
/**
* Stores the query object
*
* @var Builder|ScoutBuilder|Closure|null
*/
protected Builder|ScoutBuilder|null|Closure $query = null;

/**
* Stores the data comming from the client side
*
* @var RequestPayload
*/
protected RequestPayload $data;

/**
* The actual query builder instance provided by the user.
*
* @return mixed
*/
public function query(): mixed
{
Expand All @@ -53,8 +47,6 @@ protected function getQuery()

/**
* Boot the query and save it on the instance.
*
* @return void
*/
public function setupQuery(): void
{
Expand All @@ -81,9 +73,6 @@ public function withQuery(mixed $query): static

/**
* Attempts to resolve the query from a string, class or a model
*
* @param mixed|null $queryOrModel
* @return Builder
*/
protected function resolveQueryOrModel(mixed $queryOrModel = null): Builder
{
Expand All @@ -107,10 +96,6 @@ protected function resolveQueryOrModel(mixed $queryOrModel = null): Builder

/**
* Apply the user provided filters using the follow method
*
* @param Builder $query
* @param RequestPayload $payload
* @return Builder
*/
protected function applyQueryFilters(Builder $query, RequestPayload $payload): Builder
{
Expand All @@ -127,10 +112,6 @@ protected function applyQueryFilters(Builder $query, RequestPayload $payload): B

/**
* Apply the sorting using the following method
*
* @param Builder $query
* @param RequestPayload $payload
* @return Builder
*/
protected function applyQuerySorting(Builder $query, RequestPayload $payload): Builder
{
Expand All @@ -146,10 +127,6 @@ protected function applyQuerySorting(Builder $query, RequestPayload $payload): B

/**
* Apply the search using the following method, supporting scout if the class uses scout.
*
* @param Builder $query
* @param RequestPayload $payload
* @return Builder
*/
protected function applySearch(Builder $query, RequestPayload $payload): Builder
{
Expand Down Expand Up @@ -181,9 +158,6 @@ protected function applySearch(Builder $query, RequestPayload $payload): Builder
/**
* Transform the Laravel pagination with Vanilla Datatable Pagination structure
* The ideia was origonally taken from Reink at PingCRM Demo
*
* @param LengthAwarePaginator $paginator
* @return array
*/
protected function transformPagination(LengthAwarePaginator $paginator): array
{
Expand Down Expand Up @@ -270,7 +244,6 @@ protected function transformPagination(LengthAwarePaginator $paginator): array
/**
* Process an action once is dispatched from the frontend to the backend
*
* @return void
*
* @throws Exception
*/
Expand All @@ -290,8 +263,6 @@ protected function dispatchAction(): void
* otherwise we can inject the user provided query into the table.
*
*
* @param Builder|null $queryOrModel
* @return array|Collection
*
* @throws Exception
*/
Expand Down
2 changes: 0 additions & 2 deletions src/Datatables/Http/Payload/Concerns/CanSelectAllRows.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ trait CanSelectAllRows
{
/**
* Checks if all is selected
*
* @var bool
*/
protected bool $isAllSelected = false;

Expand Down
Loading

0 comments on commit 54c2334

Please sign in to comment.