MDL-59383 core_calendar: create calendar repository AMD module
authorSimey Lameze <simey@moodle.com>
Mon, 10 Jul 2017 02:06:01 +0000 (10:06 +0800)
committerSimey Lameze <simey@moodle.com>
Tue, 11 Jul 2017 07:36:28 +0000 (15:36 +0800)
Part of MDL-59333.

calendar/amd/build/calendar_repository.min.js [new file with mode: 0644]
calendar/amd/src/calendar_repository.js [new file with mode: 0644]

diff --git a/calendar/amd/build/calendar_repository.min.js b/calendar/amd/build/calendar_repository.min.js
new file mode 100644 (file)
index 0000000..156cad8
Binary files /dev/null and b/calendar/amd/build/calendar_repository.min.js differ
diff --git a/calendar/amd/src/calendar_repository.js b/calendar/amd/src/calendar_repository.js
new file mode 100644 (file)
index 0000000..3e7a68c
--- /dev/null
@@ -0,0 +1,50 @@
+// 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/>.
+
+/**
+ * A javascript module to handle calendar ajax actions.
+ *
+ * @module     core_calendar/calendar_repository
+ * @class      repository
+ * @package    core_calendar
+ * @copyright  2017 Simey Lameze <lameze@moodle.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+define(['jquery', 'core/ajax'], function($, Ajax) {
+
+
+    /**
+     * Get a calendar event by id.
+     *
+     * @method getEventById
+     * @param {int} eventId The event id.
+     * @return {promise} Resolved with requested calendar event
+     */
+    var getEventById = function(eventId) {
+
+        var request = {
+            methodname: 'core_calendar_get_calendar_event_by_id',
+            args: {
+                eventid: eventId
+            }
+        };
+
+        return Ajax.call([request])[0];
+    };
+
+    return {
+        getEventById: getEventById
+    };
+});