{"version":3,"file":"calendar_events_repository.min.js","sources":["https:\/\/elearning.unito.it\/ecm\/blocks\/timeline\/amd\/src\/calendar_events_repository.js"],"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 * A javascript module to retrieve calendar events from the server.\n *\n * @module block_timeline\/calendar_events_repository\n * @copyright 2018 Ryan Wyllie \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\ndefine(['jquery', 'core\/ajax', 'core\/notification'], function($, Ajax, Notification) {\n\n var DEFAULT_LIMIT = 20;\n\n \/**\n * Retrieve a list of calendar events for the logged in user for the\n * given course.\n *\n * Valid args are:\n * int courseid Only get events for this course\n * int starttime Only get events after this time\n * int endtime Only get events before this time\n * int limit Limit the number of results returned\n * int aftereventid Offset the result set from the given id\n *\n * @method queryByCourse\n * @param {object} args The request arguments\n * @return {promise} Resolved with an array of the calendar events\n *\/\n var queryByCourse = function(args) {\n if (!args.hasOwnProperty('limit')) {\n args.limit = DEFAULT_LIMIT;\n }\n\n args.limitnum = args.limit;\n delete args.limit;\n\n if (args.hasOwnProperty('starttime')) {\n args.timesortfrom = args.starttime;\n delete args.starttime;\n }\n\n if (args.hasOwnProperty('endtime')) {\n args.timesortto = args.endtime;\n delete args.endtime;\n }\n\n var request = {\n methodname: 'core_calendar_get_action_events_by_course',\n args: args\n };\n\n var promise = Ajax.call([request])[0];\n\n promise.fail(Notification.exception);\n\n return promise;\n };\n\n \/**\n * Retrieve a list of calendar events for the given courses for the\n * logged in user.\n *\n * Valid args are:\n * array courseids Get events for these courses\n * int starttime Only get events after this time\n * int endtime Only get events before this time\n * int limit Limit the number of results returned\n *\n * @method queryByCourses\n * @param {object} args The request arguments\n * @return {promise} Resolved with an array of the calendar events\n *\/\n var queryByCourses = function(args) {\n if (!args.hasOwnProperty('limit')) {\n \/\/ This is intentionally smaller than the default limit.\n args.limit = 10;\n }\n\n args.limitnum = args.limit;\n delete args.limit;\n\n if (args.hasOwnProperty('starttime')) {\n args.timesortfrom = args.starttime;\n delete args.starttime;\n }\n\n if (args.hasOwnProperty('endtime')) {\n args.timesortto = args.endtime;\n delete args.endtime;\n }\n\n var request = {\n methodname: 'core_calendar_get_action_events_by_courses',\n args: args\n };\n\n var promise = Ajax.call([request])[0];\n\n promise.fail(Notification.exception);\n\n return promise;\n };\n\n \/**\n * Retrieve a list of calendar events for the logged in user after the given\n * time.\n *\n * Valid args are:\n * int starttime Only get events after this time\n * int endtime Only get events before this time\n * int limit Limit the number of results returned\n * int aftereventid Offset the result set from the given id\n *\n * @method queryByTime\n * @param {object} args The request arguments\n * @return {promise} Resolved with an array of the calendar events\n *\/\n var queryByTime = function(args) {\n if (!args.hasOwnProperty('limit')) {\n args.limit = DEFAULT_LIMIT;\n }\n\n args.limitnum = args.limit;\n delete args.limit;\n\n if (args.hasOwnProperty('starttime')) {\n args.timesortfrom = args.starttime;\n delete args.starttime;\n }\n\n if (args.hasOwnProperty('endtime')) {\n args.timesortto = args.endtime;\n delete args.endtime;\n }\n \/\/ Don't show events related to courses that the user is suspended in.\n args.limittononsuspendedevents = true;\n\n var request = {\n methodname: 'core_calendar_get_action_events_by_timesort',\n args: args\n };\n\n var promise = Ajax.call([request])[0];\n\n promise.fail(Notification.exception);\n\n return promise;\n };\n\n return {\n queryByTime: queryByTime,\n queryByCourse: queryByCourse,\n queryByCourses: queryByCourses,\n };\n});\n"],"names":["define","$","Ajax","Notification","queryByTime","args","hasOwnProperty","limit","limitnum","timesortfrom","starttime","timesortto","endtime","limittononsuspendedevents","request","methodname","promise","call","fail","exception","queryByCourse","queryByCourses"],"mappings":";;;;;;;AAsBAA,mDAAO,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,oBA4I5D,CACHC,YAjCc,SAASC,MAClBA,KAAKC,eAAe,WACrBD,KAAKE,MA5GO,IA+GhBF,KAAKG,SAAWH,KAAKE,aACdF,KAAKE,MAERF,KAAKC,eAAe,eACpBD,KAAKI,aAAeJ,KAAKK,iBAClBL,KAAKK,WAGZL,KAAKC,eAAe,aACpBD,KAAKM,WAAaN,KAAKO,eAChBP,KAAKO,SAGhBP,KAAKQ,2BAA4B,MAE7BC,QAAU,CACVC,WAAY,8CACZV,KAAMA,MAGNW,QAAUd,KAAKe,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKf,aAAagB,WAEnBH,SAKPI,cA3HgB,SAASf,MACpBA,KAAKC,eAAe,WACrBD,KAAKE,MAnBO,IAsBhBF,KAAKG,SAAWH,KAAKE,aACdF,KAAKE,MAERF,KAAKC,eAAe,eACpBD,KAAKI,aAAeJ,KAAKK,iBAClBL,KAAKK,WAGZL,KAAKC,eAAe,aACpBD,KAAKM,WAAaN,KAAKO,eAChBP,KAAKO,aAGZE,QAAU,CACVC,WAAY,4CACZV,KAAMA,MAGNW,QAAUd,KAAKe,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKf,aAAagB,WAEnBH,SAiGPK,eAhFiB,SAAShB,MACrBA,KAAKC,eAAe,WAErBD,KAAKE,MAAQ,IAGjBF,KAAKG,SAAWH,KAAKE,aACdF,KAAKE,MAERF,KAAKC,eAAe,eACpBD,KAAKI,aAAeJ,KAAKK,iBAClBL,KAAKK,WAGZL,KAAKC,eAAe,aACpBD,KAAKM,WAAaN,KAAKO,eAChBP,KAAKO,aAGZE,QAAU,CACVC,WAAY,6CACZV,KAAMA,MAGNW,QAAUd,KAAKe,KAAK,CAACH,UAAU,UAEnCE,QAAQE,KAAKf,aAAagB,WAEnBH"}