Skip to content

Commit 9f42ad5

Browse files
author
NarrowsProjects
committed
feat: update radioFilterModel with defaultIsEmpty argument
1 parent 86eb3b7 commit 9f42ad5

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

lib/public/components/Filters/common/RadioButtonFilterModel.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,24 @@ export class RadioButtonFilterModel extends SelectionModel {
2222
*
2323
* @param {SelectionOption[]} [availableOptions] the list of possible operators
2424
* @param {function} [setDefault] function that selects the default from the list of available options. Selects first entry by default
25+
* @param {boolean} [defaultIsEmpty] if true, the default selection will be treated as empty
2526
*/
26-
constructor(availableOptions, setDefault = (options) => [options[0]]) {
27+
constructor(availableOptions, setDefault = (options) => [options[0]], defaultIsEmpty = true) {
2728
super({
2829
availableOptions,
2930
defaultSelection: setDefault(availableOptions),
3031
multiple: false,
3132
allowEmpty: false,
3233
});
34+
35+
this._defaultIsEmpty = defaultIsEmpty;
36+
}
37+
38+
get isEmpty() {
39+
if (this._defaultIsEmpty) {
40+
return this.hasOnlyDefaultSelection();
41+
}
42+
43+
return false;
3344
}
3445
}

0 commit comments

Comments
 (0)