MDL-60700 calendar: normalise event type in summmary modal render
authorRyan Wyllie <ryan@moodle.com>
Mon, 6 Nov 2017 06:54:25 +0000 (06:54 +0000)
committerRyan Wyllie <ryan@moodle.com>
Tue, 7 Nov 2017 02:08:00 +0000 (02:08 +0000)
calendar/amd/build/view_manager.min.js
calendar/amd/src/view_manager.js
calendar/templates/event_summary_body.mustache

index 7313a59..7a451fb 100644 (file)
Binary files a/calendar/amd/build/view_manager.min.js and b/calendar/amd/build/view_manager.min.js differ
index 4c29f20..299aece 100644 (file)
@@ -339,28 +339,37 @@ define([
         };
 
         /**
-         * Get the CSS class to apply for the given event type.
+         * Convert the given event type into one of either user, site,
+         * group, category, or course.
          *
          * @param {String} eventType The calendar event type
          * @return {String}
          */
-        var getEventTypeClassFromType = function(eventType) {
+        var normaliseEventType = function(eventType) {
             switch (eventType) {
                 case 'user':
-                    return 'calendar_event_user';
+                    return 'user';
                 case 'site':
-                    return 'calendar_event_site';
+                    return 'site';
                 case 'group':
-                    return 'calendar_event_group';
+                    return 'group';
                 case 'category':
-                    return 'calendar_event_category';
-                case 'course':
-                    return 'calendar_event_course';
+                    return 'category';
                 default:
-                    return 'calendar_event_course';
+                    return 'course';
             }
         };
 
+        /**
+         * Get the CSS class to apply for the given event type.
+         *
+         * @param {String} eventType The calendar event type
+         * @return {String}
+         */
+        var getEventTypeClassFromType = function(eventType) {
+            return 'calendar_event_' + normaliseEventType(eventType);
+        };
+
         /**
          * Render the event summary modal.
          *
@@ -419,7 +428,7 @@ define([
          * @return {promise} The lang string promise.
          */
         var getEventType = function(eventType) {
-            var lang = 'type' + eventType;
+            var lang = 'type' + normaliseEventType(eventType);
             return Str.get_string(lang, 'core_calendar').then(function(langStr) {
                 return langStr;
             });
index 0770cc5..f176f9e 100644 (file)
             <div class="col-xs-11">{{{.}}}</div>
         </div>
         {{/description}}
+        {{#isactionevent}}
+        <div class="row m-t-1">
+            <div class="col-xs-1">{{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}</div>
+            <div class="col-xs-11"><a href="{{course.viewurl}}">{{{course.fullname}}}</a></div>
+        </div>
+        {{/isactionevent}}
         {{#iscategoryevent}}
         <div class="row m-t-1">
             <div class="col-xs-1">{{#pix}} i/categoryevent, core, {{#str}} category {{/str}} {{/pix}}</div>