MDL-67917 user: Use custom templates for participant value selection
Part of MDL-67743
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("core_user/local/participantsfilter/filter",["exports","core/form-autocomplete","./selectors","core/str"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=e(b);c=e(c);function e(a){return a&&a.__esModule?a:{default:a}}function f(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function g(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var i=a.apply(b,c);function g(a){f(i,d,e,g,h,"next",a)}function h(a){f(i,d,e,g,h,"throw",a)}g(void 0)})}}function h(a,b){if(!(a instanceof b)){throw new TypeError("Cannot call a class as a function")}}function i(a,b){for(var c=0,d;c<b.length;c++){d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;if("value"in d)d.writable=!0;Object.defineProperty(a,d.key,d)}}function j(a,b,c){if(b)i(a.prototype,b);if(c)i(a,c);return a}var k=function(a){return a.querySelectorAll(":checked")},l=function(){function a(b,c){h(this,a);this.filterType=b;this.rootNode=c;this.addValueSelector()}j(a,[{key:"tearDown",value:function tearDown(){}},{key:"addValueSelector",value:function(){var a=g(regeneratorRuntime.mark(function a(){var c,e;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:c=this.getFilterValueNode();c.innerHTML=this.getSourceDataForFilter().outerHTML;e=c.querySelector("select");a.t0=b.default;a.t1=e;a.t2="1"==e.dataset.allowCustom;a.next=8;return(0,d.get_string)("typeorselect","core_user");case 8:a.t3=a.sent;a.t4=!e.multiple;a.t0.enhance.call(a.t0,a.t1,a.t2,null,a.t3,!1,!0,null,a.t4);case 11:case"end":return a.stop();}}},a,this)}));return function addValueSelector(){return a.apply(this,arguments)}}()},{key:"getSourceDataForFilter",value:function getSourceDataForFilter(){var a=this.rootNode.querySelector(c.default.filterset.regions.datasource);return a.querySelector(c.default.data.fields.byName(this.filterType))}},{key:"getFilterValueNode",value:function getFilterValueNode(){return this.filterRoot.querySelector(c.default.filter.regions.values)}},{key:"filterRoot",get:function get(){return this.rootNode.querySelector(c.default.filter.byName(this.filterType))}},{key:"name",get:function get(){return this.filterType}},{key:"jointype",get:function get(){return this.filterRoot.querySelector(c.default.filter.fields.join).value}},{key:"rawValues",get:function get(){var a=this.getFilterValueNode(),b=a.querySelector("select");return Object.values(k(b)).map(function(a){return a.value})}},{key:"values",get:function get(){return this.rawValues.map(function(a){return parseInt(a,10)})}},{key:"filterValue",get:function get(){return{name:this.name,jointype:this.jointype,values:this.values}}}]);return a}();a.default=l;return a.default});
|
||||
define ("core_user/local/participantsfilter/filter",["exports","core/form-autocomplete","./selectors","core/str"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=e(b);c=e(c);function e(a){return a&&a.__esModule?a:{default:a}}function f(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function g(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var i=a.apply(b,c);function g(a){f(i,d,e,g,h,"next",a)}function h(a){f(i,d,e,g,h,"throw",a)}g(void 0)})}}function h(a,b){if(!(a instanceof b)){throw new TypeError("Cannot call a class as a function")}}function i(a,b){for(var c=0,d;c<b.length;c++){d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;if("value"in d)d.writable=!0;Object.defineProperty(a,d.key,d)}}function j(a,b,c){if(b)i(a.prototype,b);if(c)i(a,c);return a}var k=function(a){return a.querySelectorAll(":checked")},l=function(){function a(b,c){h(this,a);this.filterType=b;this.rootNode=c;this.addValueSelector()}j(a,[{key:"tearDown",value:function tearDown(){}},{key:"addValueSelector",value:function(){var a=g(regeneratorRuntime.mark(function a(){var c,e;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:c=this.getFilterValueNode();c.innerHTML=this.getSourceDataForFilter().outerHTML;e=c.querySelector("select");a.t0=b.default;a.t1=e;a.t2="1"==e.dataset.allowCustom;a.next=8;return(0,d.get_string)("typeorselect","core_user");case 8:a.t3=a.sent;a.t4=!e.multiple;a.t5={items:"core_user/local/participantsfilter/autocomplete_selection_items",layout:"core_user/local/participantsfilter/autocomplete_layout",selection:"core_user/local/participantsfilter/autocomplete_selection"};a.t0.enhance.call(a.t0,a.t1,a.t2,null,a.t3,!1,!0,null,a.t4,a.t5);case 12:case"end":return a.stop();}}},a,this)}));return function addValueSelector(){return a.apply(this,arguments)}}()},{key:"getSourceDataForFilter",value:function getSourceDataForFilter(){var a=this.rootNode.querySelector(c.default.filterset.regions.datasource);return a.querySelector(c.default.data.fields.byName(this.filterType))}},{key:"getFilterValueNode",value:function getFilterValueNode(){return this.filterRoot.querySelector(c.default.filter.regions.values)}},{key:"filterRoot",get:function get(){return this.rootNode.querySelector(c.default.filter.byName(this.filterType))}},{key:"name",get:function get(){return this.filterType}},{key:"jointype",get:function get(){return this.filterRoot.querySelector(c.default.filter.fields.join).value}},{key:"rawValues",get:function get(){var a=this.getFilterValueNode(),b=a.querySelector("select");return Object.values(k(b)).map(function(a){return a.value})}},{key:"values",get:function get(){return this.rawValues.map(function(a){return parseInt(a,10)})}},{key:"filterValue",get:function get(){return{name:this.name,jointype:this.jointype,values:this.values}}}]);return a}();a.default=l;return a.default});
|
||||
//# sourceMappingURL=filter.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -93,7 +93,14 @@ export default class {
|
||||
null,
|
||||
|
||||
// Close the suggestions if this is not a multi-select.
|
||||
!dataSource.multiple
|
||||
!dataSource.multiple,
|
||||
|
||||
// Template overrides.
|
||||
{
|
||||
items: 'core_user/local/participantsfilter/autocomplete_selection_items',
|
||||
layout: 'core_user/local/participantsfilter/autocomplete_layout',
|
||||
selection: 'core_user/local/participantsfilter/autocomplete_selection',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_user/local/participantsfilter/autocomplete_layout
|
||||
|
||||
Moodle template for the layout of autocomplete elements.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* data-region="form_autocomplete-input"
|
||||
* data-region="form_autocomplete-suggestions"
|
||||
* data-region="form_autocomplete-selection"
|
||||
|
||||
Context variables required for this template:
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{}
|
||||
}}
|
||||
<div data-region="form_autocomplete-input"></div>
|
||||
<div data-region="form_autocomplete-suggestions"></div>
|
||||
<div data-region="form_autocomplete-selection"></div>
|
||||
@@ -0,0 +1,49 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_user/local/participantsfilter/autocomplete_selection
|
||||
|
||||
Moodle template for the wrapper of currently selected items in an autocomplate form element.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* multiple True if this field allows multiple selections
|
||||
* selectionId The dom id of the current selection list.
|
||||
* items List of items with label and value fields (used by the partial).
|
||||
* noSelectionString String to use when no items are selected (used by the partial).
|
||||
|
||||
Example context (json):
|
||||
{ "multiple": true, "selectionId": 1, "items": [
|
||||
{ "label": "Item label with <strong>tags</strong>", "value": "5" },
|
||||
{ "label": "Another item label with <strong>tags</strong>", "value": "4" }
|
||||
], "noSelectionString": "No selection" }
|
||||
}}
|
||||
<div{{!
|
||||
}} class="d-inline-block px-2{{#multiple}} form-autocomplete-multiple{{/multiple}}"{{!
|
||||
}} id="{{selectionId}}"{{!
|
||||
}} role="list"{{!
|
||||
}} aria-atomic="true"{{!
|
||||
}}{{#multiple}} tabindex="0" aria-multiselectable="true"{{/multiple}}{{!
|
||||
}}>
|
||||
<span class="accesshide">{{#str}}selecteditems, form{{/str}}</span>
|
||||
{{> core/form_autocomplete_selection_items }}
|
||||
</div>
|
||||
@@ -0,0 +1,51 @@
|
||||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_user/local/participantsfilter/autocomplete_selection_items
|
||||
|
||||
Moodle template for the currently selected items in an autocomplete form element.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* data-value
|
||||
|
||||
Context variables required for this template:
|
||||
* items List of items with label and value fields.
|
||||
* - value Value of the selected item.
|
||||
* - label HTML representing the value.
|
||||
* noSelectionString String to use when no items are selected
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"items": [
|
||||
{ "label": "Item label with <strong>tags</strong>", "value": "5" },
|
||||
{ "label": "Another item label with <strong>tags</strong>", "value": "4" }
|
||||
],
|
||||
"noSelectionString": "No selection"
|
||||
}
|
||||
}}
|
||||
{{#items}}
|
||||
<span role="listitem" data-value="{{value}}" aria-selected="true"
|
||||
class="d-inline-block bg-dark text-white rounded font-weight-bold px-1 m-1">
|
||||
{{label}}<i class="icon fa fa-times pl-2 mr-0"></i>
|
||||
</span>
|
||||
{{/items}}
|
||||
{{^items}}
|
||||
<span class="mb-3 mr-1">{{noSelectionString}}</span>
|
||||
{{/items}}
|
||||
Reference in New Issue
Block a user