Skip to content

Commit fbc321c

Browse files
Merge pull request #190 from nathanheffley/add-is-grouped-value-option
Add isGroupedValue option
2 parents 051b550 + a312803 commit fbc321c

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ Display individual leaf nodes instead of the main group when all leaf nodes are
137137
->grouped(false)
138138
```
139139

140+
Return parent node value if all of its children are selected, instead of individual leaf nodes.
141+
142+
```php
143+
->isGroupedValue()
144+
```
145+
140146
Hide the clearable icon
141147

142148
```php

resources/dist/filament-select-tree.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default function selectTree({
1919
emptyText,
2020
expandSelected = true,
2121
grouped = true,
22+
isGroupedValue = false,
2223
openLevel = 0,
2324
direction = 'auto'
2425
}) {
@@ -64,6 +65,7 @@ export default function selectTree({
6465
emptyText,
6566
expandSelected,
6667
grouped,
68+
isGroupedValue,
6769
openLevel,
6870
direction,
6971
rtl

resources/views/select-tree.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
emptyText: @js($getEmptyLabel()),
4040
expandSelected: @js($getExpandSelected()),
4141
grouped: @js($getGrouped()),
42+
isGroupedValue: @js($getIsGroupedValue()),
4243
openLevel: @js($getDefaultOpenLevel()),
4344
direction: @js($getDirection()),
4445
rtl: @js(__('filament-panels::layout.direction') === 'rtl'),

src/SelectTree.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class SelectTree extends Field implements HasAffixActions
5858

5959
protected bool $grouped = true;
6060

61+
protected bool $isGroupedValue = false;
62+
6163
protected Closure|Builder|null $query = null;
6264

6365
protected string|Closure|null $relationship = null;
@@ -438,6 +440,13 @@ public function grouped(bool $grouped = true): static
438440
return $this;
439441
}
440442

443+
public function isGroupedValue(bool $isGroupedValue = true): static
444+
{
445+
$this->isGroupedValue = $isGroupedValue;
446+
447+
return $this;
448+
}
449+
441450
public function defaultOpenLevel(Closure|int $defaultOpenLevel = 0): static
442451
{
443452
$this->defaultOpenLevel = $defaultOpenLevel;
@@ -538,6 +547,11 @@ public function getGrouped(): bool
538547
return $this->evaluate($this->grouped);
539548
}
540549

550+
public function getIsGroupedValue(): bool
551+
{
552+
return $this->evaluate($this->isGroupedValue);
553+
}
554+
541555
public function getWithTrashed(): bool
542556
{
543557
return $this->evaluate($this->withTrashed);

0 commit comments

Comments
 (0)