From a625478a035ac45da601531e05aafa1d230a785d Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Thu, 19 Oct 2023 08:53:12 +0200 Subject: [PATCH] Split `stylisedUi` into `stylized` and `lazyLoad` --- README.md | 14 +++++++++++++- src/Fields/Select.php | 11 +++++++++-- tests/Fields/SelectTest.php | 10 ++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index deb71f7a..a2de642c 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,9 @@ Select::make('Color') ->default('forest_green') ->returnFormat('value') // array, label, value (default) ->multiple() - ->nullabel() + ->nullable() + ->stylized() // stylized checkbox using select2 + ->lazyLoad() // use AJAX to lazy load choices ->required() ``` @@ -845,6 +847,16 @@ The `stylisedUi` method has been renamed to `stylized` on the `TrueFalse` field. +TrueFalse::make('Disabled')->stylized(on: 'Yes') ``` +The `stylisedUi` method has been split into two methods `stylized` and `lazyLoad` on the `Select` field. + +```diff +-Select::make('Friends')->stylisedUi() ++Select::make('Friends')->stylized() + +-Select::make('Friends')->stylisedUi(true) ++Select::make('Friends')->lazyLoad() +``` + The `CharacterLimit` trait has been renamed to `MaxLength`. ```diff diff --git a/src/Fields/Select.php b/src/Fields/Select.php index 948e6c2f..87af9486 100644 --- a/src/Fields/Select.php +++ b/src/Fields/Select.php @@ -41,10 +41,17 @@ class Select extends Field protected string|null $type = 'select'; - public function stylisedUi(bool $useAjax = false): static + public function stylized(): static { $this->settings['ui'] = true; - $this->settings['ajax'] = $useAjax; + + return $this; + } + + public function lazyLoad(): static + { + $this->settings['ui'] = true; + $this->settings['ajax'] = true; return $this; } diff --git a/tests/Fields/SelectTest.php b/tests/Fields/SelectTest.php index cf0564dc..7a5387d0 100644 --- a/tests/Fields/SelectTest.php +++ b/tests/Fields/SelectTest.php @@ -24,9 +24,15 @@ public function testType() $this->assertSame('select', $field['type']); } - public function testStylisedUi() + public function testStylized() { - $field = Select::make('Select Stylised UI')->stylisedUi(true)->get(); + $field = Select::make('Select Stylized')->stylized()->get(); + $this->assertTrue($field['ui']); + } + + public function testLazyLoad() + { + $field = Select::make('Select Lazy Load')->lazyLoad()->get(); $this->assertTrue($field['ui']); $this->assertTrue($field['ajax']); }