diff --git a/calendar/amd/build/calendar_filter.min.js b/calendar/amd/build/calendar_filter.min.js
index 49ead88bd48..9f72034c7d4 100644
--- a/calendar/amd/build/calendar_filter.min.js
+++ b/calendar/amd/build/calendar_filter.min.js
@@ -1,2 +1,2 @@
-define ("core_calendar/calendar_filter",["jquery","core_calendar/selectors","core_calendar/events","core/str","core/templates"],function(a,b,c,d,e){var f=function(d){d.on("click",b.eventFilterItem,function(b){var c=a(b.currentTarget);g(c);b.preventDefault()});a("body").on(c.viewUpdated,function(){var c=d.find(b.eventFilterItem);c.each(function(b,c){c=a(c);if(c.data("eventtype-hidden")){var d=i(c);h(d)}})})},g=function(a){var b=i(a);b.hidden=!b.hidden;return d.get_string("eventtype"+b.eventtype,"calendar").then(function(a){b.name=a;b.icon=!0;b.key="i/"+b.eventtype+"event";b.component="core";return b}).then(function(a){return e.render("core_calendar/event_filter_key",a)}).then(function(b,c){return e.replaceNode(a,b,c)}).then(function(){h(b)})},h=function(b){M.util.js_pending("month-mini-filterChanged");a("body").trigger(c.filterChanged,{type:b.eventtype,hidden:b.hidden});M.util.js_complete("month-mini-filterChanged")},i=function(a){return{eventtype:a.data("eventtype"),hidden:a.data("eventtype-hidden")}};return{init:function init(b){b=a(b);f(b)}}});
+define ("core_calendar/calendar_filter",["jquery","core_calendar/selectors","core_calendar/events","core/str","core/templates"],function(a,b,c,d,e){var f=function(d){d.on("click",b.eventFilterItem,function(b){var c=a(b.currentTarget);g(c);b.preventDefault()});a("body").on(c.viewUpdated,function(){var c=d.find(b.eventFilterItem);c.each(function(b,c){c=a(c);if(c.data("eventtype-hidden")){var d=i(c);h(d)}})})},g=function(a){var b=i(a);b.hidden=!b.hidden;M.util.js_pending("core_calendar/calendar_filter:toggleFilter");return d.get_string("eventtype"+b.eventtype,"calendar").then(function(a){b.name=a;b.icon=!0;b.key="i/"+b.eventtype+"event";b.component="core";return b}).then(function(a){return e.render("core_calendar/event_filter_key",a)}).then(function(b,c){return e.replaceNode(a,b,c)}).then(function(){h(b);M.util.js_complete("core_calendar/calendar_filter:toggleFilter")})},h=function(b){M.util.js_pending("month-mini-filterChanged");a("body").trigger(c.filterChanged,{type:b.eventtype,hidden:b.hidden});M.util.js_complete("month-mini-filterChanged")},i=function(a){return{eventtype:a.data("eventtype"),hidden:a.data("eventtype-hidden")}};return{init:function init(b){b=a(b);f(b)}}});
//# sourceMappingURL=calendar_filter.min.js.map
diff --git a/calendar/amd/build/calendar_filter.min.js.map b/calendar/amd/build/calendar_filter.min.js.map
index 91dd1039d56..5fd11036430 100644
--- a/calendar/amd/build/calendar_filter.min.js.map
+++ b/calendar/amd/build/calendar_filter.min.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/calendar_filter.js"],"names":["define","$","CalendarSelectors","CalendarEvents","Str","Templates","registerEventListeners","root","on","eventFilterItem","e","target","currentTarget","toggleFilter","preventDefault","viewUpdated","filters","find","each","i","filter","data","getFilterData","fireFilterChangedEvent","hidden","get_string","eventtype","then","nameStr","name","icon","key","component","context","render","html","js","replaceNode","M","util","js_pending","trigger","filterChanged","type","js_complete","init"],"mappings":"AAuBAA,OAAM,iCAAC,CACH,QADG,CAEH,yBAFG,CAGH,sBAHG,CAIH,UAJG,CAKH,gBALG,CAAD,CAON,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAME,IAEMC,CAAAA,CAAsB,CAAG,SAASC,CAAT,CAAe,CACxCA,CAAI,CAACC,EAAL,CAAQ,OAAR,CAAiBN,CAAiB,CAACO,eAAnC,CAAoD,SAASC,CAAT,CAAY,CAC5D,GAAIC,CAAAA,CAAM,CAAGV,CAAC,CAACS,CAAC,CAACE,aAAH,CAAd,CAEAC,CAAY,CAACF,CAAD,CAAZ,CAEAD,CAAC,CAACI,cAAF,EACH,CAND,EAQAb,CAAC,CAAC,MAAD,CAAD,CAAUO,EAAV,CAAaL,CAAc,CAACY,WAA5B,CAAyC,UAAW,CAChD,GAAIC,CAAAA,CAAO,CAA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CiB,CAAC,CAACC,IAAF,CAAOC,UAAP,CAAkB,0BAAlB,EACAvC,CAAC,CAAC,MAAD,CAAD,CAAUwC,OAAV,CAAkBtC,CAAc,CAACuC,aAAjC,CAAgD,CAC5CC,IAAI,CAAEtB,CAAI,CAACK,SADiC,CAE5CF,MAAM,CAAEH,CAAI,CAACG,MAF+B,CAAhD,EAIAc,CAAC,CAACC,IAAF,CAAOK,WAAP,CAAmB,0BAAnB,CACH,CA/DH,CAuEMtB,CAAa,CAAG,SAASX,CAAT,CAAiB,CACjC,MAAO,CACHe,SAAS,CAAEf,CAAM,CAACU,IAAP,CAAY,WAAZ,CADR,CAEHG,MAAM,CAAEb,CAAM,CAACU,IAAP,CAAY,kBAAZ,CAFL,CAIV,CA5EH,CA8EE,MAAO,CACHwB,IAAI,CAAE,cAAStC,CAAT,CAAe,CACjBA,CAAI,CAAGN,CAAC,CAACM,CAAD,CAAR,CAEAD,CAAsB,CAACC,CAAD,CACzB,CALE,CAOV,CAlGK,CAAN","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 * This module is responsible for the calendar filter.\n *\n * @module core_calendar/calendar_filter\n * @package core_calendar\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core_calendar/selectors',\n 'core_calendar/events',\n 'core/str',\n 'core/templates',\n],\nfunction(\n $,\n CalendarSelectors,\n CalendarEvents,\n Str,\n Templates\n) {\n\n var registerEventListeners = function(root) {\n root.on('click', CalendarSelectors.eventFilterItem, function(e) {\n var target = $(e.currentTarget);\n\n toggleFilter(target);\n\n e.preventDefault();\n });\n\n $('body').on(CalendarEvents.viewUpdated, function() {\n var filters = root.find(CalendarSelectors.eventFilterItem);\n\n filters.each(function(i, filter) {\n filter = $(filter);\n if (filter.data('eventtype-hidden')) {\n var data = getFilterData(filter);\n fireFilterChangedEvent(data);\n }\n });\n });\n };\n\n var toggleFilter = function(target) {\n var data = getFilterData(target);\n\n // Toggle the hidden. We need to render the template before we change the value.\n data.hidden = !data.hidden;\n\n return Str.get_string('eventtype' + data.eventtype, 'calendar')\n .then(function(nameStr) {\n data.name = nameStr;\n data.icon = true;\n data.key = 'i/' + data.eventtype + 'event';\n data.component = 'core';\n\n return data;\n })\n .then(function(context) {\n return Templates.render('core_calendar/event_filter_key', context);\n })\n .then(function(html, js) {\n return Templates.replaceNode(target, html, js);\n })\n .then(function() {\n fireFilterChangedEvent(data);\n return;\n });\n };\n\n /**\n * Fire the filterChanged event for the specified data.\n *\n * @param {object} data The data to include\n */\n var fireFilterChangedEvent = function(data) {\n M.util.js_pending(\"month-mini-filterChanged\");\n $('body').trigger(CalendarEvents.filterChanged, {\n type: data.eventtype,\n hidden: data.hidden,\n });\n M.util.js_complete(\"month-mini-filterChanged\");\n };\n\n /**\n * Get the filter data for the specified target.\n *\n * @param {jQuery} target The target node\n * @return {Object}\n */\n var getFilterData = function(target) {\n return {\n eventtype: target.data('eventtype'),\n hidden: target.data('eventtype-hidden'),\n };\n };\n\n return {\n init: function(root) {\n root = $(root);\n\n registerEventListeners(root);\n }\n };\n});\n"],"file":"calendar_filter.min.js"}
\ No newline at end of file
+{"version":3,"sources":["../src/calendar_filter.js"],"names":["define","$","CalendarSelectors","CalendarEvents","Str","Templates","registerEventListeners","root","on","eventFilterItem","e","target","currentTarget","toggleFilter","preventDefault","viewUpdated","filters","find","each","i","filter","data","getFilterData","fireFilterChangedEvent","hidden","M","util","js_pending","get_string","eventtype","then","nameStr","name","icon","key","component","context","render","html","js","repla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jBA,CAAI,CAAGN,CAAC,CAACM,CAAD,CAAR,CAEAD,CAAsB,CAACC,CAAD,CACzB,CALE,CAOV,CApGK,CAAN","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 * This module is responsible for the calendar filter.\n *\n * @module core_calendar/calendar_filter\n * @package core_calendar\n * @copyright 2017 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core_calendar/selectors',\n 'core_calendar/events',\n 'core/str',\n 'core/templates',\n],\nfunction(\n $,\n CalendarSelectors,\n CalendarEvents,\n Str,\n Templates\n) {\n\n var registerEventListeners = function(root) {\n root.on('click', CalendarSelectors.eventFilterItem, function(e) {\n var target = $(e.currentTarget);\n\n toggleFilter(target);\n\n e.preventDefault();\n });\n\n $('body').on(CalendarEvents.viewUpdated, function() {\n var filters = root.find(CalendarSelectors.eventFilterItem);\n\n filters.each(function(i, filter) {\n filter = $(filter);\n if (filter.data('eventtype-hidden')) {\n var data = getFilterData(filter);\n fireFilterChangedEvent(data);\n }\n });\n });\n };\n\n var toggleFilter = function(target) {\n var data = getFilterData(target);\n\n // Toggle the hidden. We need to render the template before we change the value.\n data.hidden = !data.hidden;\n\n M.util.js_pending(\"core_calendar/calendar_filter:toggleFilter\");\n return Str.get_string('eventtype' + data.eventtype, 'calendar')\n .then(function(nameStr) {\n data.name = nameStr;\n data.icon = true;\n data.key = 'i/' + data.eventtype + 'event';\n data.component = 'core';\n\n return data;\n })\n .then(function(context) {\n return Templates.render('core_calendar/event_filter_key', context);\n })\n .then(function(html, js) {\n return Templates.replaceNode(target, html, js);\n })\n .then(function() {\n fireFilterChangedEvent(data);\n M.util.js_complete(\"core_calendar/calendar_filter:toggleFilter\");\n return;\n });\n };\n\n /**\n * Fire the filterChanged event for the specified data.\n *\n * @param {object} data The data to include\n */\n var fireFilterChangedEvent = function(data) {\n M.util.js_pending(\"month-mini-filterChanged\");\n $('body').trigger(CalendarEvents.filterChanged, {\n type: data.eventtype,\n hidden: data.hidden,\n });\n M.util.js_complete(\"month-mini-filterChanged\");\n };\n\n /**\n * Get the filter data for the specified target.\n *\n * @param {jQuery} target The target node\n * @return {Object}\n */\n var getFilterData = function(target) {\n return {\n eventtype: target.data('eventtype'),\n hidden: target.data('eventtype-hidden'),\n };\n };\n\n return {\n init: function(root) {\n root = $(root);\n\n registerEventListeners(root);\n }\n };\n});\n"],"file":"calendar_filter.min.js"}
\ No newline at end of file
diff --git a/calendar/amd/src/calendar_filter.js b/calendar/amd/src/calendar_filter.js
index 41dd4488e8b..415b3b3a8b6 100644
--- a/calendar/amd/src/calendar_filter.js
+++ b/calendar/amd/src/calendar_filter.js
@@ -64,6 +64,7 @@ function(
// Toggle the hidden. We need to render the template before we change the value.
data.hidden = !data.hidden;
+ M.util.js_pending("core_calendar/calendar_filter:toggleFilter");
return Str.get_string('eventtype' + data.eventtype, 'calendar')
.then(function(nameStr) {
data.name = nameStr;
@@ -81,6 +82,7 @@ function(
})
.then(function() {
fireFilterChangedEvent(data);
+ M.util.js_complete("core_calendar/calendar_filter:toggleFilter");
return;
});
};