From 21ad9531d069af41b43369a7bba7e5eb7ca69e6a Mon Sep 17 00:00:00 2001 From: David Matamoros Date: Mon, 2 Sep 2019 14:42:24 +0200 Subject: [PATCH] MDL-66354 core_calendar: Notices in error.log on calendar events --- calendar/amd/build/calendar_filter.min.js | 2 +- calendar/amd/build/calendar_filter.min.js.map | 2 +- calendar/amd/src/calendar_filter.js | 3 +++ calendar/lib.php | 3 +++ calendar/templates/event_icon.mustache | 2 +- calendar/templates/month_mini.mustache | 7 +------ 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/calendar/amd/build/calendar_filter.min.js b/calendar/amd/build/calendar_filter.min.js index 6a9f95d2202..49ead88bd48 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;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;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)}}}); //# 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 68ce74d5dab..91dd1039d56 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","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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CAAD,CAEzB,CAfM,CAgBV,CA9CH,CAqDME,CAAsB,CAAG,SAASF,CAAT,CAAe,CACxCc,CAAC,CAACC,IAAF,CAAOC,UAAP,CAAkB,0BAAlB,EACApC,CAAC,CAAC,MAAD,CAAD,CAAUqC,OAAV,CAAkBnC,CAAc,CAACoC,aAAjC,CAAgD,CAC5CC,IAAI,CAAEnB,CAAI,CAACK,SADiC,CAE5CF,MAAM,CAAEH,CAAI,CAACG,MAF+B,CAAhD,EAIAW,CAAC,CAACC,IAAF,CAAOK,WAAP,CAAmB,0BAAnB,CACH,CA5DH,CAoEMnB,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,CAzEH,CA2EE,MAAO,CACHqB,IAAI,CAAE,cAASnC,CAAT,CAAe,CACjBA,CAAI,CAAGN,CAAC,CAACM,CAAD,CAAR,CAEAD,CAAsB,CAACC,CAAD,CACzB,CALE,CAOV,CA/FK,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\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","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,CAAGT,CAAI,CAACU,IAAL,CAAUf,CAAiB,CAACO,eAA5B,CAAd,CAEAO,CAAO,CAACE,IAAR,CAAa,SAASC,CAAT,CAAYC,CAAZ,CAAoB,CAC7BA,CAAM,CAAGnB,CAAC,CAACmB,CAAD,CAAV,CACA,GAAIA,CAAM,CAACC,IAAP,CAAY,kBAAZ,CAAJ,CAAqC,CACjC,GAAIA,CAAAA,CAAI,CAAGC,CAAa,CAACF,CAAD,CAAxB,CACAG,CAAsB,CAACF,CAAD,CACzB,CACJ,CAND,CAOH,CAVD,CAWH,CAtBH,CAwBMR,CAAY,CAAG,SAASF,CAAT,CAAiB,CAChC,GAAIU,CAAAA,CAAI,CAAGC,CAAa,CAACX,CAAD,CAAxB,CAGAU,CAAI,CAACG,MAAL,CAAc,CAACH,CAAI,CAACG,MAApB,CAEA,MAAOpB,CAAAA,CAAG,CAACqB,UAAJ,CAAe,YAAcJ,CAAI,CAACK,SAAlC,CAA6C,UAA7C,EACNC,IADM,CACD,SAASC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AAN","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 diff --git a/calendar/amd/src/calendar_filter.js b/calendar/amd/src/calendar_filter.js index 622dafd890c..41dd4488e8b 100644 --- a/calendar/amd/src/calendar_filter.js +++ b/calendar/amd/src/calendar_filter.js @@ -67,6 +67,9 @@ function( return Str.get_string('eventtype' + data.eventtype, 'calendar') .then(function(nameStr) { data.name = nameStr; + data.icon = true; + data.key = 'i/' + data.eventtype + 'event'; + data.component = 'core'; return data; }) diff --git a/calendar/lib.php b/calendar/lib.php index 608bb6edbba..831c0cedd46 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -3672,6 +3672,9 @@ function calendar_get_filter_types() { return [ 'eventtype' => $type, 'name' => get_string("eventtype{$type}", "calendar"), + 'icon' => true, + 'key' => 'i/' . $type . 'event', + 'component' => 'core' ]; }, $types); } diff --git a/calendar/templates/event_icon.mustache b/calendar/templates/event_icon.mustache index fb88bd6c6ea..ea61b32cf93 100644 --- a/calendar/templates/event_icon.mustache +++ b/calendar/templates/event_icon.mustache @@ -37,5 +37,5 @@ {{#pix}} icon, {{modulename}} {{/pix}} {{/modulename}} {{^modulename}} - {{#pix}} i/{{eventtype}}event, core {{/pix}} + {{#icon}}{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}{{/icon}} {{/modulename}} diff --git a/calendar/templates/month_mini.mustache b/calendar/templates/month_mini.mustache index b1aa06f1b14..cb3e22974c0 100644 --- a/calendar/templates/month_mini.mustache +++ b/calendar/templates/month_mini.mustache @@ -136,12 +136,7 @@ {{$content}} {{#events}}
- {{#modulename}} - {{#pix}} icon, {{modulename}} {{/pix}} - {{/modulename}} - {{^modulename}} - {{#pix}} i/{{eventtype}}event, core {{/pix}} - {{/modulename}} + {{> core_calendar/event_icon}} {{{popupname}}}
{{/events}}