You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -595,35 +595,52 @@ These types can be used to determine how the filter scope should be displayed.
595
595
596
596
<div class="columned-list">
597
597
598
-
- [Group](#group-scope)
598
+
- [Button Group](#button-group-scope)
599
599
- [Checkbox](#checkbox-scope)
600
-
- [Switch](#switch-scope)
601
600
- [Date](#date-scope)
602
601
- [Date range](#date-range-scope)
602
+
- [Dropdown](#dropdown-scope)
603
+
- [Group](#group-scope)
603
604
- [Number](#number-scope)
604
605
- [Number range](#number-range-scope)
606
+
- [Switch](#switch-scope)
605
607
- [Text](#text-scope)
606
608
607
609
</div>
608
610
609
-
### Group scope
611
+
### Button Group scope
610
612
611
-
`group` - filters the list by a group of items, usually by a related model and requires a `nameFrom` or `options` definition. Eg: Status name as open, closed, etc.
613
+
`button-group`– displays a row of buttons where only one option may be selected at a time. Ideal for small, mutually exclusive option sets (e.g., status filters like All / Active / Archived).
612
614
613
615
```yaml
614
616
status:
615
617
label: Status
616
-
type: group
617
-
conditions: status in (:filtered)
618
-
default:
619
-
pending: Pending
618
+
type: button-group
619
+
default: active
620
+
conditions: status = :filtered
621
+
options:
622
+
all: All
620
623
active: Active
624
+
archived: Archived
625
+
```
626
+
627
+
If a button is clicked again while it is already selected, it will deselect unless required: true is specified:
628
+
629
+
```yaml
630
+
status:
631
+
label: Status
632
+
type: button-group
633
+
required: true
634
+
default: active
635
+
conditions: status = :filtered
621
636
options:
622
-
pending: Pending
623
637
active: Active
638
+
pending: Pending
624
639
closed: Closed
625
640
```
626
641
642
+
Supports dynamic options using a method name or `modelClass` with `nameFrom`, same as [`group`](#group-scope).
643
+
627
644
### Checkbox scope
628
645
629
646
`checkbox`- used as a binary checkbox to apply a predefined condition or query to the list, either on or off. Use 0 for off and 1 for on for default value
@@ -636,42 +653,42 @@ published:
636
653
conditions: is_published <> true
637
654
```
638
655
639
-
### Switch scope
640
-
641
-
`switch`- used as a switch to toggle between two predefined conditions or queries to the list, either indeterminate, on or off. Use 0 for off, 1 for indeterminate and 2 for on for default value
656
+
### Dropdown scope
642
657
643
-
Using conditions:
658
+
`dropdown`- displays a compact single-select dropdown menu. Ideal for filtering by a single value from a short or medium-sized list, with an optional placeholder-like entry when no value is selected.
644
659
645
660
```yaml
646
-
approved:
647
-
label: Approved
648
-
type: switch
649
-
default: 1
650
-
conditions:
651
-
- is_approved <> true
652
-
- is_approved = true
661
+
status:
662
+
type: dropdown
663
+
emptyOption: Select status
664
+
default: active
665
+
conditions: status = :filtered
666
+
options:
667
+
all: All
668
+
active: Active
669
+
archived: Archived
653
670
```
654
671
655
-
Using a scope method:
672
+
You can also populate options dynamically:
656
673
657
674
```yaml
658
-
approved:
659
-
label: Approved
660
-
type: switch
661
-
default: 0
662
-
scope: isApproved
675
+
country:
676
+
type: dropdown
677
+
emptyOption: Select country
678
+
modelClass: Winter\Test\Models\Location
679
+
nameFrom: name
680
+
conditions: country_id = :filtered
663
681
```
664
682
665
-
```php
666
-
public function scopeIsApproved($query, $state)
667
-
{
668
-
return match ($state) {
669
-
'0' => $query,
670
-
'1' => $query->where('is_approved', false),
671
-
'2' => $query->where('is_approved', true),
672
-
}
673
-
}
674
-
```
683
+
Supported options:
684
+
685
+
- `emptyOption`: The placeholder text for an unselected state (acts like a "none" or prompt).
686
+
- `default`: The default selected value.
687
+
- `options`: Static array or method name on modelClass for dynamic options.
688
+
- `modelClass` + `nameFrom`: Dynamically populate options from a model.
689
+
- `required`: (optional) Prevents deselecting the current value.
690
+
691
+
> **NOTE:** When `required: true` is set, the `emptyOption` will be ignored. If no `default` is specified, the first available option will be automatically selected.
675
692
676
693
### Date scope
677
694
@@ -750,6 +767,24 @@ published_at:
750
767
751
768
> **NOTE:** the `ignoreTimezone` option also applies to the `date` filter type as well.
752
769
770
+
### Group scope
771
+
772
+
`group` - filters the list by a group of items, usually by a related model and requires a `nameFrom` or `options` definition. Eg: Status name as open, closed, etc.
773
+
774
+
```yaml
775
+
status:
776
+
label: Status
777
+
type: group
778
+
conditions: status in (:filtered)
779
+
default:
780
+
pending: Pending
781
+
active: Active
782
+
options:
783
+
pending: Pending
784
+
active: Active
785
+
closed: Closed
786
+
```
787
+
753
788
### Number scope
754
789
755
790
`number`- displays input for a single number to be entered. The value is available to be used in the conditions property as `:filtered`.
@@ -788,6 +823,43 @@ visitors:
788
823
conditions: visitors >= ':min' and visitors <= ':max'
789
824
```
790
825
826
+
### Switch scope
827
+
828
+
`switch`- used as a switch to toggle between two predefined conditions or queries to the list, either indeterminate, on or off. Use 0 for off, 1 for indeterminate and 2 for on for default value
829
+
830
+
Using conditions:
831
+
832
+
```yaml
833
+
approved:
834
+
label: Approved
835
+
type: switch
836
+
default: 1
837
+
conditions:
838
+
- is_approved <> true
839
+
- is_approved = true
840
+
```
841
+
842
+
Using a scope method:
843
+
844
+
```yaml
845
+
approved:
846
+
label: Approved
847
+
type: switch
848
+
default: 0
849
+
scope: isApproved
850
+
```
851
+
852
+
```php
853
+
public function scopeIsApproved($query, $state)
854
+
{
855
+
return match ($state) {
856
+
'0' => $query,
857
+
'1' => $query->where('is_approved', false),
858
+
'2' => $query->where('is_approved', true),
859
+
}
860
+
}
861
+
```
862
+
791
863
### Text scope
792
864
793
865
`text` - display text input for a string to be entered. You can specify a `size` attribute that will be injected in the input size attribute (default: 10).
0 commit comments