MDL-60046 user: Apply user filters immediately.

This commit is contained in:
Damyon Wiese 2017-09-22 14:53:27 +08:00
parent b3cfb01316
commit e39df1faeb
3 changed files with 12 additions and 2 deletions

View File

@ -1 +1 @@
define(["jquery","core/form-autocomplete","core/str","core/notification"],function(a,b,c,d){var e={UNIFIED_FILTERS:"#unified-filters"},f=function(){var a=[{key:"userfilterplaceholder",component:"moodle"},{key:"nofiltersapplied",component:"moodle"}];c.get_strings(a).done(function(a){var c=a[0],d=a[1];b.enhance(e.UNIFIED_FILTERS,!0,"core_user/unified_filter_datasource",c,!1,!0,d,!0)}).fail(d.exception)};return{init:function(){f()}}});
define(["jquery","core/form-autocomplete","core/str","core/notification"],function(a,b,c,d){var e={UNIFIED_FILTERS:"#unified-filters"},f=function(){var f=[{key:"userfilterplaceholder",component:"moodle"},{key:"nofiltersapplied",component:"moodle"}];c.get_strings(f).done(function(a){var c=a[0],d=a[1];b.enhance(e.UNIFIED_FILTERS,!0,"core_user/unified_filter_datasource",c,!1,!0,d,!0)}).fail(d.exception);var g=a(e.UNIFIED_FILTERS).val();a(e.UNIFIED_FILTERS).on("change",function(){var b=a(this).val();g.join(",")!=b.join(",")&&this.form.submit(),g=b})};return{init:function(){f()}}});

View File

@ -51,12 +51,23 @@ define(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'],
component: 'moodle'
}
];
Str.get_strings(stringkeys).done(function(langstrings) {
var placeholder = langstrings[0];
var noSelectionString = langstrings[1];
Autocomplete.enhance(SELECTORS.UNIFIED_FILTERS, true, 'core_user/unified_filter_datasource', placeholder,
false, true, noSelectionString, true);
}).fail(Notification.exception);
var last = $(SELECTORS.UNIFIED_FILTERS).val();
$(SELECTORS.UNIFIED_FILTERS).on('change', function() {
var current = $(this).val();
if (last.join(',') != current.join(',')) {
this.form.submit();
}
last = current;
});
};
return /** @alias module:core/form-autocomplete */ {

View File

@ -58,7 +58,6 @@
<option value="{{value}}" {{#selected}}selected="selected"{{/selected}}>{{{label}}}</option>
{{/filteroptions}}
</select>
<input type="submit" class="btn btn-primary" id="user-filter-button" value={{#quote}}{{#str}}filter{{/str}}{{/quote}}>
</form>
{{#js}}
require(['core_user/unified_filter'], function(Filter) {