Skip to content

Commit

Permalink
Merge branch 'MDL-67743-master-final' of git://github.com/andrewnicol…
Browse files Browse the repository at this point in the history
…s/moodle
  • Loading branch information
junpataleta committed May 27, 2020
2 parents 5a0d8a7 + 6cb3444 commit d5eec2a
Show file tree
Hide file tree
Showing 40 changed files with 1,716 additions and 28 deletions.
14 changes: 14 additions & 0 deletions lang/en/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,19 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['addcondition'] = 'Add condition';
$string['adverbfor_and'] = 'and';
$string['adverbfor_andnot'] = 'and';
$string['adverbfor_or'] = 'or';
$string['applyfilters'] = 'Apply filters';
$string['clearfilterrow'] = 'Remove filter row';
$string['clearfilters'] = 'Clear filters';
$string['countparticipantsfound'] = '{$a} participants found';
$string['filtersetmatchdescription'] = 'How multiple filters should be combined';
$string['match'] = 'Match';
$string['matchofthefollowing'] = 'of the following:';
$string['placeholdertypeorselect'] = 'Type or select...';
$string['placeholdertype'] = 'Type...';
$string['privacy:courserequestpath'] = 'Requested courses';
$string['privacy:descriptionpath'] = 'Profile description';
$string['privacy:devicespath'] = 'User devices';
Expand Down Expand Up @@ -126,6 +138,8 @@
$string['privacy:profileimagespath'] = 'Profile images';
$string['privacy:privatefilespath'] = 'Private files';
$string['privacy:sessionpath'] = 'Session data';
$string['filterbykeyword'] = 'Keyword';
$string['selectfiltertype'] = 'Select';
$string['target:upcomingactivitiesdue'] = 'Upcoming activities due';
$string['target:upcomingactivitiesdue_help'] = 'This target generates reminders for upcoming activities due.';
$string['target:upcomingactivitiesdueinfo'] = 'All upcoming activities due insights are listed here. These students have received these insights directly.';
2 changes: 1 addition & 1 deletion lib/amd/build/form-autocomplete.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/amd/build/form-autocomplete.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/amd/build/templates.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/amd/build/templates.min.js.map

Large diffs are not rendered by default.

44 changes: 30 additions & 14 deletions lib/amd/src/form-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function($, log, str, templates, notification, LoadingIcon) {
});
var context = $.extend({items: items}, options, state);
// Render the template.
return templates.render('core/form_autocomplete_selection_items', context)
return templates.render(options.templates.items, context)
.then(function(html, js) {
// Add it to the page.
templates.replaceNodeContents(newSelection, html, js);
Expand Down Expand Up @@ -970,10 +970,11 @@ function($, log, str, templates, notification, LoadingIcon) {
* @param {Boolean} showSuggestions - If suggestions should be shown
* @param {String} noSelectionString - Text to display when there is no selection
* @param {Boolean} closeSuggestionsOnSelect - Whether to close the suggestions immediately after making a selection.
* @param {Object} templateOverrides A set of templates to use instead of the standard templates
* @return {Promise}
*/
enhance: function(selector, tags, ajax, placeholder, caseSensitive, showSuggestions, noSelectionString,
closeSuggestionsOnSelect) {
closeSuggestionsOnSelect, templateOverrides) {
// Set some default values.
var options = {
selector: selector,
Expand All @@ -982,7 +983,14 @@ function($, log, str, templates, notification, LoadingIcon) {
placeholder: placeholder,
caseSensitive: false,
showSuggestions: true,
noSelectionString: noSelectionString
noSelectionString: noSelectionString,
templates: $.extend({
input: 'core/form_autocomplete_input',
items: 'core/form_autocomplete_selection_items',
layout: 'core/form_autocomplete_layout',
selection: 'core/form_autocomplete_selection',
suggestions: 'core/form_autocomplete_suggestions',
}, templateOverrides),
};
var pendingKey = 'autocomplete-setup-' + selector;
M.util.js_pending(pendingKey);
Expand Down Expand Up @@ -1058,27 +1066,35 @@ function($, log, str, templates, notification, LoadingIcon) {
// Collect rendered inline JS to be executed once the HTML is shown.
var collectedjs = '';

var renderInput = templates.render('core/form_autocomplete_input', context).then(function(html, js) {
var renderLayout = templates.render(options.templates.layout, {})
.then(function(html) {
return $(html);
});

var renderInput = templates.render(options.templates.input, context).then(function(html, js) {
collectedjs += js;
return html;
return $(html);
});

var renderDatalist = templates.render('core/form_autocomplete_suggestions', context).then(function(html, js) {
var renderDatalist = templates.render(options.templates.suggestions, context).then(function(html, js) {
collectedjs += js;
return html;
return $(html);
});

var renderSelection = templates.render('core/form_autocomplete_selection', context).then(function(html, js) {
var renderSelection = templates.render(options.templates.selection, context).then(function(html, js) {
collectedjs += js;
return html;
return $(html);
});

return $.when(renderInput, renderDatalist, renderSelection)
.then(function(input, suggestions, selection) {
return $.when(renderLayout, renderInput, renderDatalist, renderSelection)
.then(function(layout, input, suggestions, selection) {
originalSelect.hide();
originalSelect.after(suggestions);
originalSelect.after(input);
originalSelect.after(selection);
var container = originalSelect.parent();

container.append(layout);
container.find('[data-region="form_autocomplete-input"]').replaceWith(input);
container.find('[data-region="form_autocomplete-suggestions"]').replaceWith(suggestions);
container.find('[data-region="form_autocomplete-selection"]').replaceWith(selection);

templates.runTemplateJS(collectedjs);

Expand Down
33 changes: 27 additions & 6 deletions lib/amd/src/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ define([
* @param {String} newHTML - HTML to insert / replace.
* @param {String} newJS - Javascript to run after the insertion.
* @param {Boolean} replaceChildNodes - Replace only the childnodes, alternative is to replace the entire node.
* @return {Array} The list of new DOM Nodes
*/
var domReplace = function(element, newHTML, newJS, replaceChildNodes) {
var replaceNode = $(element);
Expand Down Expand Up @@ -904,7 +905,11 @@ define([
runTemplateJS(newJS);
// Notify all filters about the new content.
event.notifyFilterContentUpdated(newNodes);

return newNodes.get();
}

return [];
};

/**
Expand Down Expand Up @@ -1043,17 +1048,23 @@ define([
* @param {jQuery|String} element - Element or selector to prepend HTML to
* @param {String} html - HTML to prepend
* @param {String} js - Javascript to run after we prepend the html
* @return {Array} The list of new DOM Nodes
*/
var domPrepend = function(element, html, js) {
var node = $(element);
if (node.length) {
// Prepend the html.
node.prepend(html);
var newContent = $(html);
node.prepend(newContent);
// Run any javascript associated with the new HTML.
runTemplateJS(js);
// Notify all filters about the new content.
event.notifyFilterContentUpdated(node);

return newContent.get();
}

return [];
};

/**
Expand All @@ -1064,17 +1075,23 @@ define([
* @param {jQuery|String} element - Element or selector to append HTML to
* @param {String} html - HTML to append
* @param {String} js - Javascript to run after we append the html
* @return {Array} The list of new DOM Nodes
*/
var domAppend = function(element, html, js) {
var node = $(element);
if (node.length) {
// Append the html.
node.append(html);
var newContent = $(html);
node.append(newContent);
// Run any javascript associated with the new HTML.
runTemplateJS(js);
// Notify all filters about the new content.
event.notifyFilterContentUpdated(node);

return newContent.get();
}

return [];
};

return /** @alias module:core/templates */ {
Expand Down Expand Up @@ -1175,9 +1192,10 @@ define([
* @param {JQuery} element - Element or selector to replace.
* @param {String} newHTML - HTML to insert / replace.
* @param {String} newJS - Javascript to run after the insertion.
* @return {Array} The list of new DOM Nodes
*/
replaceNodeContents: function(element, newHTML, newJS) {
domReplace(element, newHTML, newJS, true);
return domReplace(element, newHTML, newJS, true);
},

/**
Expand All @@ -1187,9 +1205,10 @@ define([
* @param {JQuery} element - Element or selector to replace.
* @param {String} newHTML - HTML to insert / replace.
* @param {String} newJS - Javascript to run after the insertion.
* @return {Array} The list of new DOM Nodes
*/
replaceNode: function(element, newHTML, newJS) {
domReplace(element, newHTML, newJS, false);
return domReplace(element, newHTML, newJS, false);
},

/**
Expand All @@ -1199,9 +1218,10 @@ define([
* @param {jQuery|String} element - Element or selector to prepend HTML to
* @param {String} html - HTML to prepend
* @param {String} js - Javascript to run after we prepend the html
* @return {Array} The list of new DOM Nodes
*/
prependNodeContents: function(element, html, js) {
domPrepend(element, html, js);
return domPrepend(element, html, js);
},

/**
Expand All @@ -1211,9 +1231,10 @@ define([
* @param {jQuery|String} element - Element or selector to append HTML to
* @param {String} html - HTML to append
* @param {String} js - Javascript to run after we append the html
* @return {Array} The list of new DOM Nodes
*/
appendNodeContents: function(element, html, js) {
domAppend(element, html, js);
return domAppend(element, html, js);
},
};
});
1 change: 1 addition & 0 deletions lib/table/classes/external/dynamic/fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public static function execute(
}

$filterset = new $filtersetclass();
$filterset->set_join_type($jointype);
foreach ($filters as $rawfilter) {
$filterset->add_filter_from_params(
$rawfilter['name'],
Expand Down
2 changes: 1 addition & 1 deletion lib/tablelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ public function set_sortdata(array $sortdata): void {
$this->sortdata = [];
foreach ($sortdata as $sortitem) {
if (!array_key_exists($sortitem['sortby'], $this->sortdata)) {
$this->sortdata[$sortitem['sortby']] = $sortitem['sortorder'];
$this->sortdata[$sortitem['sortby']] = (int) $sortitem['sortorder'];
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/templates/form_autocomplete_input.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
{ "inputID": 1, "suggestionsId": 2, "selectionId": 3, "downArrowId": 4, "placeholder": "Select something" }
}}
{{#showSuggestions}}
<div class="d-inline-block position-relative">
<div class="d-md-inline-block mr-md-2 position-relative">
<input type="text" id="{{inputId}}" class="form-control" list="{{suggestionsId}}" placeholder="{{placeholder}}" role="combobox" aria-expanded="false" autocomplete="off" autocorrect="off" autocapitalize="off" aria-autocomplete="list" aria-owns="{{suggestionsId}} {{selectionId}}" {{#tags}}data-tags="1"{{/tags}}/>
<span class="form-autocomplete-downarrow position-absolute p-1" id="{{downArrowId}}">&#x25BC;</span>
</div>
{{/showSuggestions}}
{{^showSuggestions}}
<input type="text" id="{{inputId}}" placeholder="{{placeholder}}" role="textbox" aria-owns="{{selectionId}}" {{#tags}}data-tags="1"{{/tags}}/>
<div class="d-md-inline-block mr-md-2">
<input type="text" id="{{inputId}}" class="form-control" placeholder="{{placeholder}}" role="textbox" aria-owns="{{selectionId}}" {{#tags}}data-tags="1"{{/tags}}/>
</div>
{{/showSuggestions}}

{{#js}}
Expand Down
38 changes: 38 additions & 0 deletions lib/templates/form_autocomplete_layout.mustache
Original file line number Diff line number Diff line change
@@ -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/form_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-selection"></div>
<div data-region="form_autocomplete-input"></div>
<div data-region="form_autocomplete-suggestions"></div>
6 changes: 6 additions & 0 deletions theme/boost/scss/moodle/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2462,6 +2462,12 @@ body.h5p-embed {
height: 1.5rem;
}

.border-radius {
@if $enable-rounded {
@include border-radius($card-border-radius);
}
}

// Emoji picker.
$picker-width: 350px !default;
$picker-width-xs: 320px !default;
Expand Down
11 changes: 11 additions & 0 deletions theme/boost/scss/moodle/user.scss
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,14 @@
.user-enroller-panel {
width: 600px;
}

[data-filterverbfor],
[data-filterregion="filter"]:last-child [data-filterregion="joinadverb"] {
display: none;
}

[data-filterverb="0"] [data-filterverbfor="0"],
[data-filterverb="1"] [data-filterverbfor="1"],
[data-filterverb="2"] [data-filterverbfor="2"] {
display: block;
}
9 changes: 9 additions & 0 deletions theme/boost/style/moodle.css
Original file line number Diff line number Diff line change
Expand Up @@ -16042,6 +16042,15 @@ body.path-question-type .mform fieldset.hidden {
.user-enroller-panel {
width: 600px; }

[data-filterverbfor],
[data-filterregion="filter"]:last-child [data-filterregion="joinadverb"] {
display: none; }

[data-filterverb="0"] [data-filterverbfor="0"],
[data-filterverb="1"] [data-filterverbfor="1"],
[data-filterverb="2"] [data-filterverbfor="2"] {
display: block; }

.search-results .result {
margin-left: 0;
margin-right: 0; }
Expand Down
12 changes: 12 additions & 0 deletions theme/classic/style/moodle.css
Original file line number Diff line number Diff line change
Expand Up @@ -11859,6 +11859,9 @@ body.h5p-embed .h5pmessages {
color: #343a40;
height: 1.5rem; }

.border-radius {
border-radius: 0.25rem; }

.emoji-picker {
width: 350px;
height: 400px; }
Expand Down Expand Up @@ -16266,6 +16269,15 @@ body.path-question-type .mform fieldset.hidden {
.user-enroller-panel {
width: 600px; }

[data-filterverbfor],
[data-filterregion="filter"]:last-child [data-filterregion="joinadverb"] {
display: none; }

[data-filterverb="0"] [data-filterverbfor="0"],
[data-filterverb="1"] [data-filterverbfor="1"],
[data-filterverb="2"] [data-filterverbfor="2"] {
display: block; }

.search-results .result {
margin-left: 0;
margin-right: 0; }
Expand Down
2 changes: 2 additions & 0 deletions user/amd/build/local/participantsfilter/filter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d5eec2a

Please sign in to comment.