diff --git a/lib/amd/build/datafilter/filtertypes/binary.min.js b/lib/amd/build/datafilter/filtertypes/binary.min.js
index 98fc1526147..8b5f9d330ce 100644
--- a/lib/amd/build/datafilter/filtertypes/binary.min.js
+++ b/lib/amd/build/datafilter/filtertypes/binary.min.js
@@ -1,3 +1,3 @@
-define("core/datafilter/filtertypes/binary",["exports","core/datafilter/filtertype","core/datafilter/selectors","core/templates","core/str"],(function(_exports,_filtertype,_selectors,_templates,_str){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_filtertype=_interopRequireDefault(_filtertype),_selectors=_interopRequireDefault(_selectors),_templates=_interopRequireDefault(_templates);class _default extends _filtertype.default{constructor(){super(...arguments),_defineProperty(this,"optionOne",void 0),_defineProperty(this,"optionTwo",void 0)}async addValueSelector(initialValues){return[this.optionOne,this.optionTwo]=await this.getTextValues(),this.displayBinarySelection(initialValues)}getTextValues(){return(0,_str.get_strings)([{key:"no"},{key:"yes"}])}async displayBinarySelection(){let initialValues=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const specificFilterSet=this.rootNode.querySelector(_selectors.default.filter.byName(this.filterType)),sourceDataNode=this.getSourceDataForFilter(),context={filtertype:this.filterType,title:sourceDataNode.getAttribute("data-field-title"),required:sourceDataNode.dataset.required,options:[{text:this.optionOne,value:0,selected:0===initialValues[0]},{text:this.optionTwo,value:1,selected:1===initialValues[0]}]};return _templates.default.render("core/datafilter/filtertypes/binary_selector",context).then(((binaryUi,js)=>_templates.default.replaceNodeContents(specificFilterSet.querySelector(_selectors.default.filter.regions.values),binaryUi,js)))}get values(){return this.filterRoot.querySelector('[data-filterfield="'.concat(this.name,'"]')).value}}return _exports.default=_default,_exports.default}));
+define("core/datafilter/filtertypes/binary",["exports","core/datafilter/filtertype","core/datafilter/selectors","core/templates","core/str"],(function(_exports,_filtertype,_selectors,_templates,_str){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_filtertype=_interopRequireDefault(_filtertype),_selectors=_interopRequireDefault(_selectors),_templates=_interopRequireDefault(_templates);class _default extends _filtertype.default{constructor(){super(...arguments),_defineProperty(this,"optionOne",void 0),_defineProperty(this,"optionTwo",void 0)}async addValueSelector(initialValues){return[this.optionOne,this.optionTwo]=await this.getTextValues(),this.displayBinarySelection(initialValues[0])}getTextValues(){return(0,_str.get_strings)([{key:"no"},{key:"yes"}])}async displayBinarySelection(){let initialValue=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const specificFilterSet=this.rootNode.querySelector(_selectors.default.filter.byName(this.filterType)),sourceDataNode=this.getSourceDataForFilter(),context={filtertype:this.filterType,title:sourceDataNode.getAttribute("data-field-title"),required:sourceDataNode.dataset.required,options:[{text:this.optionOne,value:0,selected:0===initialValue},{text:this.optionTwo,value:1,selected:1===initialValue}]};return _templates.default.render("core/datafilter/filtertypes/binary_selector",context).then(((binaryUi,js)=>_templates.default.replaceNodeContents(specificFilterSet.querySelector(_selectors.default.filter.regions.values),binaryUi,js)))}get values(){return[parseInt(this.filterRoot.querySelector('[data-filterfield="'.concat(this.name,'"]')).value)]}}return _exports.default=_default,_exports.default}));
//# sourceMappingURL=binary.min.js.map
\ No newline at end of file
diff --git a/lib/amd/build/datafilter/filtertypes/binary.min.js.map b/lib/amd/build/datafilter/filtertypes/binary.min.js.map
index b41d8295796..45a15087d69 100644
--- a/lib/amd/build/datafilter/filtertypes/binary.min.js.map
+++ b/lib/amd/build/datafilter/filtertypes/binary.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"binary.min.js","sources":["../../../src/datafilter/filtertypes/binary.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Base filter for binary selector ie: (Yes / No).\n *\n * @module core/datafilter/filtertypes/binary\n * @author 2022 Ghaly Marc-Alexandre \n * @copyright 2022 Catalyst IT Australia Pty Ltd\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Filter from 'core/datafilter/filtertype';\nimport Selectors from 'core/datafilter/selectors';\nimport Templates from 'core/templates';\nimport {get_strings as getStrings} from 'core/str';\n\nexport default class extends Filter {\n\n /**\n * Text string for the first binary option.\n *\n * This option (and {@see optionTwo}) are set by {@see getTextValues()}. The base class will set default values,\n * a subclass can override the method to define its own option.\n *\n * @type {String}\n */\n optionOne;\n\n /**\n * Text string for the second binary option.\n *\n * @type {String}\n */\n optionTwo;\n\n /**\n * Add the value selector to the filter row.\n *\n * @param {Array} initialValues The default value for the filter.\n */\n async addValueSelector(initialValues) {\n [this.optionOne, this.optionTwo] = await this.getTextValues();\n return this.displayBinarySelection(initialValues);\n }\n\n /**\n * Fetch text values for select options.\n *\n * Subclasses should override this method to set their own options.\n *\n * @returns {Promise}\n */\n getTextValues() {\n return getStrings([{key: 'no'}, {key: 'yes'}]);\n }\n\n /**\n * Renders yes/no select input with proper selection.\n *\n * @param {Array} initialValues The default value for the filter.\n */\n async displayBinarySelection(initialValues = []) {\n // We specify a specific filterset in case there are multiple filtering condition - avoiding glitches.\n const specificFilterSet = this.rootNode.querySelector(Selectors.filter.byName(this.filterType));\n const sourceDataNode = this.getSourceDataForFilter();\n const context = {\n filtertype: this.filterType,\n title: sourceDataNode.getAttribute('data-field-title'),\n required: sourceDataNode.dataset.required,\n options: [\n {\n text: this.optionOne,\n value: 0,\n selected: initialValues[0] === 0,\n },\n {\n text: this.optionTwo,\n value: 1,\n selected: initialValues[0] === 1,\n },\n ]\n };\n return Templates.render('core/datafilter/filtertypes/binary_selector', context)\n .then((binaryUi, js) => {\n return Templates.replaceNodeContents(specificFilterSet.querySelector(Selectors.filter.regions.values), binaryUi, js);\n });\n }\n\n /**\n * Get the list of raw values for this filter type.\n *\n * @returns {Array}\n */\n get values() {\n return this.filterRoot.querySelector(`[data-filterfield=\"${this.name}\"]`).value;\n }\n\n}\n"],"names":["Filter","initialValues","this","optionOne","optionTwo","getTextValues","displayBinarySelection","key","specificFilterSet","rootNode","querySelector","Selectors","filter","byName","filterType","sourceDataNode","getSourceDataForFilter","context","filtertype","title","getAttribute","required","dataset","options","text","value","selected","Templates","render","then","binaryUi","js","replaceNodeContents","regions","values","filterRoot","name"],"mappings":"irBA6B6BA,+JAwBFC,sBAClBC,KAAKC,UAAWD,KAAKE,iBAAmBF,KAAKG,gBACvCH,KAAKI,uBAAuBL,eAUvCI,uBACW,oBAAW,CAAC,CAACE,IAAK,MAAO,CAACA,IAAK,4CAQbN,qEAAgB,SAEnCO,kBAAoBN,KAAKO,SAASC,cAAcC,mBAAUC,OAAOC,OAAOX,KAAKY,aAC7EC,eAAiBb,KAAKc,yBACtBC,QAAU,CACZC,WAAYhB,KAAKY,WACjBK,MAAOJ,eAAeK,aAAa,oBACnCC,SAAUN,eAAeO,QAAQD,SACjCE,QAAS,CACL,CACIC,KAAMtB,KAAKC,UACXsB,MAAO,EACPC,SAA+B,IAArBzB,cAAc,IAE5B,CACIuB,KAAMtB,KAAKE,UACXqB,MAAO,EACPC,SAA+B,IAArBzB,cAAc,aAI7B0B,mBAAUC,OAAO,8CAA+CX,SACtEY,MAAK,CAACC,SAAUC,KACNJ,mBAAUK,oBAAoBxB,kBAAkBE,cAAcC,mBAAUC,OAAOqB,QAAQC,QAASJ,SAAUC,MASrHG,oBACOhC,KAAKiC,WAAWzB,2CAAoCR,KAAKkC,YAAUX"}
\ No newline at end of file
+{"version":3,"file":"binary.min.js","sources":["../../../src/datafilter/filtertypes/binary.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Base filter for binary selector ie: (Yes / No).\n *\n * @module core/datafilter/filtertypes/binary\n * @author 2022 Ghaly Marc-Alexandre \n * @copyright 2022 Catalyst IT Australia Pty Ltd\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Filter from 'core/datafilter/filtertype';\nimport Selectors from 'core/datafilter/selectors';\nimport Templates from 'core/templates';\nimport {get_strings as getStrings} from 'core/str';\n\nexport default class extends Filter {\n\n /**\n * Text string for the first binary option.\n *\n * This option (and {@see optionTwo}) are set by {@see getTextValues()}. The base class will set default values,\n * a subclass can override the method to define its own option.\n *\n * @type {String}\n */\n optionOne;\n\n /**\n * Text string for the second binary option.\n *\n * @type {String}\n */\n optionTwo;\n\n /**\n * Add the value selector to the filter row.\n *\n * @param {Array} initialValues The default value for the filter.\n */\n async addValueSelector(initialValues) {\n [this.optionOne, this.optionTwo] = await this.getTextValues();\n return this.displayBinarySelection(initialValues[0]);\n }\n\n /**\n * Fetch text values for select options.\n *\n * Subclasses should override this method to set their own options.\n *\n * @returns {Promise}\n */\n getTextValues() {\n return getStrings([{key: 'no'}, {key: 'yes'}]);\n }\n\n /**\n * Renders yes/no select input with proper selection.\n *\n * @param {Number} initialValue The default value for the filter.\n */\n async displayBinarySelection(initialValue = 0) {\n // We specify a specific filterset in case there are multiple filtering condition - avoiding glitches.\n const specificFilterSet = this.rootNode.querySelector(Selectors.filter.byName(this.filterType));\n const sourceDataNode = this.getSourceDataForFilter();\n const context = {\n filtertype: this.filterType,\n title: sourceDataNode.getAttribute('data-field-title'),\n required: sourceDataNode.dataset.required,\n options: [\n {\n text: this.optionOne,\n value: 0,\n selected: initialValue === 0,\n },\n {\n text: this.optionTwo,\n value: 1,\n selected: initialValue === 1,\n },\n ]\n };\n return Templates.render('core/datafilter/filtertypes/binary_selector', context)\n .then((binaryUi, js) => {\n return Templates.replaceNodeContents(specificFilterSet.querySelector(Selectors.filter.regions.values), binaryUi, js);\n });\n }\n\n /**\n * Get the list of raw values for this filter type.\n *\n * @returns {Array}\n */\n get values() {\n return [parseInt(this.filterRoot.querySelector(`[data-filterfield=\"${this.name}\"]`).value)];\n }\n\n}\n"],"names":["Filter","initialValues","this","optionOne","optionTwo","getTextValues","displayBinarySelection","key","initialValue","specificFilterSet","rootNode","querySelector","Selectors","filter","byName","filterType","sourceDataNode","getSourceDataForFilter","context","filtertype","title","getAttribute","required","dataset","options","text","value","selected","Templates","render","then","binaryUi","js","replaceNodeContents","regions","values","parseInt","filterRoot","name"],"mappings":"irBA6B6BA,+JAwBFC,sBAClBC,KAAKC,UAAWD,KAAKE,iBAAmBF,KAAKG,gBACvCH,KAAKI,uBAAuBL,cAAc,IAUrDI,uBACW,oBAAW,CAAC,CAACE,IAAK,MAAO,CAACA,IAAK,4CAQbC,oEAAe,QAElCC,kBAAoBP,KAAKQ,SAASC,cAAcC,mBAAUC,OAAOC,OAAOZ,KAAKa,aAC7EC,eAAiBd,KAAKe,yBACtBC,QAAU,CACZC,WAAYjB,KAAKa,WACjBK,MAAOJ,eAAeK,aAAa,oBACnCC,SAAUN,eAAeO,QAAQD,SACjCE,QAAS,CACL,CACIC,KAAMvB,KAAKC,UACXuB,MAAO,EACPC,SAA2B,IAAjBnB,cAEd,CACIiB,KAAMvB,KAAKE,UACXsB,MAAO,EACPC,SAA2B,IAAjBnB,uBAIfoB,mBAAUC,OAAO,8CAA+CX,SACtEY,MAAK,CAACC,SAAUC,KACNJ,mBAAUK,oBAAoBxB,kBAAkBE,cAAcC,mBAAUC,OAAOqB,QAAQC,QAASJ,SAAUC,MASrHG,mBACO,CAACC,SAASlC,KAAKmC,WAAW1B,2CAAoCT,KAAKoC,YAAUZ"}
\ No newline at end of file
diff --git a/lib/amd/src/datafilter/filtertypes/binary.js b/lib/amd/src/datafilter/filtertypes/binary.js
index 6f577d13806..732c9729ae3 100644
--- a/lib/amd/src/datafilter/filtertypes/binary.js
+++ b/lib/amd/src/datafilter/filtertypes/binary.js
@@ -53,7 +53,7 @@ export default class extends Filter {
*/
async addValueSelector(initialValues) {
[this.optionOne, this.optionTwo] = await this.getTextValues();
- return this.displayBinarySelection(initialValues);
+ return this.displayBinarySelection(initialValues[0]);
}
/**
@@ -70,9 +70,9 @@ export default class extends Filter {
/**
* Renders yes/no select input with proper selection.
*
- * @param {Array} initialValues The default value for the filter.
+ * @param {Number} initialValue The default value for the filter.
*/
- async displayBinarySelection(initialValues = []) {
+ async displayBinarySelection(initialValue = 0) {
// We specify a specific filterset in case there are multiple filtering condition - avoiding glitches.
const specificFilterSet = this.rootNode.querySelector(Selectors.filter.byName(this.filterType));
const sourceDataNode = this.getSourceDataForFilter();
@@ -84,12 +84,12 @@ export default class extends Filter {
{
text: this.optionOne,
value: 0,
- selected: initialValues[0] === 0,
+ selected: initialValue === 0,
},
{
text: this.optionTwo,
value: 1,
- selected: initialValues[0] === 1,
+ selected: initialValue === 1,
},
]
};
@@ -105,7 +105,7 @@ export default class extends Filter {
* @returns {Array}
*/
get values() {
- return this.filterRoot.querySelector(`[data-filterfield="${this.name}"]`).value;
+ return [parseInt(this.filterRoot.querySelector(`[data-filterfield="${this.name}"]`).value)];
}
}
diff --git a/lib/templates/datafilter/filtertypes/binary_selector.mustache b/lib/templates/datafilter/filtertypes/binary_selector.mustache
index 6d48da0920f..6e1ba5b6bbe 100644
--- a/lib/templates/datafilter/filtertypes/binary_selector.mustache
+++ b/lib/templates/datafilter/filtertypes/binary_selector.mustache
@@ -38,7 +38,13 @@
}}