-
-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENHANCEMENT/FIX] Fix
hideToggleable, add Action Rules
editOnClick(…
…)`, `toggleable()`, `unless()` condition and others... (#1559) * change link of demo image * Refactor to use RuleManager Constant * Create Base Rule and rule "unless" * Fix hideToggleable not working * Rule for Field * Action Rule Toggleable * Add Rule EditOnClick and Row Enable/Disable EditOnClick * ToggleDetail Row Rule * improve Rule Facades * fix types * Rules Tests
- Loading branch information
1 parent
431d609
commit 61b4c44
Showing
31 changed files
with
724 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
resources/views/components/frameworks/bootstrap5/no-toggle-detail.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<td | ||
class="{{ data_get($theme, 'tdBodyClass') }}" | ||
style="{{ data_get($theme, 'tdBodyStyle') }}" | ||
></td> |
2 changes: 1 addition & 1 deletion
2
resources/views/components/frameworks/bootstrap5/toggleable.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
resources/views/components/frameworks/tailwind/no-toggle-detail.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<td | ||
class="{{ data_get($theme, 'tdBodyClass') }}" | ||
style="{{ data_get($theme, 'tdBodyStyle') }}" | ||
></td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace PowerComponents\LivewirePowerGrid\Components\Rules; | ||
|
||
use Closure; | ||
|
||
use Livewire\Wireable; | ||
use PowerComponents\LivewirePowerGrid\Contracts\ConditionalRule; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
|
||
class BaseRule implements Wireable, ConditionalRule | ||
{ | ||
public array $rule = []; | ||
|
||
public string $forAction = ''; | ||
|
||
public string $column = ''; | ||
|
||
private bool $hasCondition = false; | ||
|
||
public function setCondition(string $condition, Closure $closure): self | ||
{ | ||
if ($this->hasCondition === true) { | ||
throw new \InvalidArgumentException('A rule must have only one condition.'); | ||
} | ||
|
||
$this->hasCondition = true; | ||
|
||
$this->rule[$condition] = $closure; | ||
|
||
return $this; | ||
} | ||
|
||
public function isValidModifier(string $modifier): bool | ||
{ | ||
return in_array($modifier, RuleManager::applicableModifiers()); | ||
} | ||
|
||
public function setModifier(string $modifier, mixed $arguments): void | ||
{ | ||
if ($this->isValidModifier($modifier) === false) { | ||
throw new \InvalidArgumentException('Invalid Modifier for Row [' . $modifier . ']'); | ||
} | ||
|
||
$this->rule[$modifier] = $arguments; | ||
} | ||
|
||
public function pushModifier(string $modifier, array $argument): void | ||
{ | ||
if (isset($this->rule[$modifier]) && is_array($this->rule[$modifier])) { | ||
array_push($this->rule[$modifier], $argument); | ||
|
||
return; | ||
} | ||
|
||
$this->setModifier($modifier, [$argument]); | ||
} | ||
|
||
public function toLivewire(): array | ||
{ | ||
return (array) $this; | ||
} | ||
|
||
public static function fromLivewire($value) | ||
{ | ||
return $value; | ||
} | ||
|
||
public function when(Closure $closure): self | ||
{ | ||
$this->setCondition('when', $closure); | ||
|
||
return $this; | ||
} | ||
|
||
public function unless(Closure $closure): self | ||
{ | ||
$this->setCondition('unless', $closure); | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.