Skip to content

Commit

Permalink
Split stylisedUi into stylized and lazyLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Oct 19, 2023
1 parent 21e31e9 commit a625478
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```

Expand Down Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions src/Fields/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 8 additions & 2 deletions tests/Fields/SelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down

0 comments on commit a625478

Please sign in to comment.