Merge branch 'MDL-65318-master' of git://github.com/lameze/moodle
authorJun Pataleta <jun@moodle.com>
Thu, 2 May 2019 06:22:17 +0000 (14:22 +0800)
committerJun Pataleta <jun@moodle.com>
Thu, 2 May 2019 06:22:17 +0000 (14:22 +0800)
17 files changed:
calendar/amd/build/view_manager.min.js
calendar/amd/src/view_manager.js
calendar/classes/external/calendar_event_exporter.php
calendar/classes/external/event_exporter.php
calendar/classes/external/event_exporter_base.php
calendar/templates/calendar_day.mustache
calendar/templates/day_detailed.mustache
calendar/templates/event_details.mustache [new file with mode: 0644]
calendar/templates/event_item.mustache
calendar/templates/event_list.mustache
calendar/templates/event_summary_body.mustache
calendar/templates/month_detailed.mustache
calendar/templates/month_mini.mustache
calendar/templates/upcoming_mini.mustache
theme/boost/scss/moodle/calendar.scss
theme/boost/style/moodle.css
theme/classic/style/moodle.css

index dd946d4..e615028 100644 (file)
Binary files a/calendar/amd/build/view_manager.min.js and b/calendar/amd/build/view_manager.min.js differ
index 2c59a72..7043f75 100644 (file)
@@ -339,28 +339,6 @@ define([
                 .fail(Notification.exception);
         };
 
-        /**
-         * 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 normaliseEventType = function(eventType) {
-            switch (eventType) {
-                case 'user':
-                    return 'user';
-                case 'site':
-                    return 'site';
-                case 'group':
-                    return 'group';
-                case 'category':
-                    return 'category';
-                default:
-                    return 'course';
-            }
-        };
-
         /**
          * Get the CSS class to apply for the given event type.
          *
@@ -368,7 +346,7 @@ define([
          * @return {String}
          */
         var getEventTypeClassFromType = function(eventType) {
-            return 'calendar_event_' + normaliseEventType(eventType);
+            return 'calendar_event_' + eventType;
         };
 
         /**
@@ -385,12 +363,9 @@ define([
                     throw new Error('Error encountered while trying to fetch calendar event with ID: ' + eventId);
                 }
                 var eventData = getEventResponse.event;
-                typeClass = getEventTypeClassFromType(eventData.eventtype);
+                typeClass = getEventTypeClassFromType(eventData.normalisedeventtype);
 
-                return getEventType(eventData.eventtype).then(function(eventType) {
-                    eventData.eventtype = eventType;
-                    return eventData;
-                });
+                return eventData;
             }).then(function(eventData) {
                 // Build the modal parameters from the event data.
                 var modalParams = {
@@ -422,19 +397,6 @@ define([
             }).fail(Notification.exception);
         };
 
-        /**
-         * Get the event type lang string.
-         *
-         * @param {String} eventType The event type.
-         * @return {promise} The lang string promise.
-         */
-        var getEventType = function(eventType) {
-            var lang = 'type' + normaliseEventType(eventType);
-            return Str.get_string(lang, 'core_calendar').then(function(langStr) {
-                return langStr;
-            });
-        };
-
         return {
             init: function(root) {
                 registerEventListeners(root);
index f4b629f..ea32de3 100644 (file)
@@ -52,9 +52,6 @@ class calendar_event_exporter extends event_exporter_base {
             'type' => PARAM_BOOL,
             'default' => false,
         ];
-        $values['calendareventtype'] = [
-            'type' => PARAM_TEXT,
-        ];
         $values['popupname'] = [
             'type' => PARAM_RAW,
         ];
@@ -172,8 +169,6 @@ class calendar_event_exporter extends event_exporter_base {
             $values['popupname'] = get_string('eventnameandcourse', 'calendar', $eventnameparams);
         }
 
-        $values['calendareventtype'] = $this->get_calendar_event_type();
-
         if ($event->get_course_module()) {
             $values = array_merge($values, $this->get_module_timestamp_limits($event));
         } else if ($hascourse && $course->id != SITEID && empty($event->get_group())) {
index 51ee3e4..015d71a 100644 (file)
@@ -55,7 +55,6 @@ class event_exporter extends event_exporter_base {
             'type' => event_action_exporter::read_properties_definition(),
             'optional' => true,
         ];
-
         return $values;
     }
 
index d20cfb3..b3fb837 100644 (file)
@@ -236,6 +236,12 @@ class event_exporter_base extends exporter {
                 'default' => null,
                 'null' => NULL_ALLOWED
             ],
+            'normalisedeventtype' => [
+                'type' => PARAM_TEXT
+            ],
+            'normalisedeventtypetext' => [
+                'type' => PARAM_TEXT
+            ],
         ];
     }
 
@@ -254,11 +260,14 @@ class event_exporter_base extends exporter {
         $values['isactionevent'] = false;
         $values['iscourseevent'] = false;
         $values['iscategoryevent'] = false;
+        $values['normalisedeventtype'] = $event->get_type();
         if ($moduleproxy = $event->get_course_module()) {
             // We need a separate property to flag if an event is action event.
             // That's required because canedit return true but action action events cannot be edited on the calendar UI.
             // But they are considered editable because you can drag and drop the event on the month view.
             $values['isactionevent'] = true;
+            // Activity events are normalised to "look" like course events.
+            $values['normalisedeventtype'] = 'course';
         } else if ($event->get_type() == 'course') {
             $values['iscourseevent'] = true;
         } else if ($event->get_type() == 'category') {
@@ -266,6 +275,7 @@ class event_exporter_base extends exporter {
         }
         $timesort = $event->get_times()->get_sort_time()->getTimestamp();
         $iconexporter = new event_icon_exporter($event, ['context' => $context]);
+        $values['normalisedeventtypetext'] = get_string('type' . $values['normalisedeventtype'], 'calendar');
 
         $values['icon'] = $iconexporter->export($output);
 
index 7d75b57..e82e42a 100644 (file)
@@ -15,7 +15,7 @@
     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 }}
 {{!
-    @template calendar/calendar_day
+    @template core_calendar/calendar_day
 
     Calendar day view.
 
index 74d48bb..fde6b2f 100644 (file)
@@ -15,7 +15,7 @@
     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 }}
 {{!
-    @template calendar/day_detailed
+    @template core_calendar/day_detailed
 
     Calendar day view.
 
diff --git a/calendar/templates/event_details.mustache b/calendar/templates/event_details.mustache
new file mode 100644 (file)
index 0000000..86fcda4
--- /dev/null
@@ -0,0 +1,120 @@
+{{!
+    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/>.
+}}
+{{!
+    @template core_calendar/event_details
+
+    Calendar event details.
+
+    The purpose of this template is to render the event details.
+
+    This template is used in the summary modal, day and upcoming views to output event information consistently
+    across the calendar.
+
+    Classes required for JS:
+    * none
+
+    Data attributes required for JS:
+    * none
+
+    Example context (json):
+    {
+        "formattedtime": "Wednesday, 17 April, 9:27 AM",
+        "normalisedeventtype": "Group",
+        "description": "An random event description",
+        "location": "Moodle HQ",
+        "isactionevent": "true",
+        "course": {
+            "viewurl": "http://mymoodlesite/course/view.php?id=1",
+            "fullname": "Course name"
+        },
+        "source": "Ical imported",
+        "groupname": "Group 1",
+        "iscategoryevent": "true",
+        "category": {
+            "nestedname": "Category name"
+        },
+        "iscourseevent": "true",
+        "groupname": "Group name",
+        "subscription": "true",
+        "displayeventsource": "true",
+        "subscriptionname": "Subscription name",
+        "subscriptionurl": "http://subscriptionurl"
+    }
+}}
+<div class="row">
+    <div class="col-xs-1">{{#pix}} i/calendareventtime, core, {{#str}} when, core_calendar {{/str}} {{/pix}}</div>
+    <div class="col-xs-11">{{{formattedtime}}}</div>
+</div>
+<div class="row mt-1">
+    <div class="col-xs-1">{{#pix}} i/calendar, core, {{#str}} eventtype, core_calendar {{/str}} {{/pix}}</div>
+    <div class="col-xs-11">{{normalisedeventtypetext}}</div>
+</div>
+{{#description}}
+    <div class="row mt-1">
+        <div class="col-xs-1">{{#pix}} i/calendareventdescription, core, {{#str}} description {{/str}} {{/pix}}</div>
+        <div class="description-content col-xs-11">{{{.}}}</div>
+    </div>
+{{/description}}
+{{#location}}
+    <div class="row mt-1">
+        <div class="col-xs-1">{{#pix}} i/location, core, {{#str}} location {{/str}} {{/pix}}</div>
+        <div class="location-content col-xs-11">{{{.}}}</div>
+    </div>
+{{/location}}
+{{#isactionevent}}
+    <div class="row mt-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 mt-1">
+        <div class="col-xs-1">{{#pix}} i/categoryevent, core, {{#str}} category {{/str}} {{/pix}}</div>
+        <div class="col-xs-11">{{{category.nestedname}}}</div>
+    </div>
+{{/iscategoryevent}}
+{{#iscourseevent}}
+    <div class="row mt-1">
+        <div class="col-xs-1">{{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}</div>
+        <div class="col-xs-11"><a href="{{url}}">{{{course.fullname}}}</a></div>
+    </div>
+{{/iscourseevent}}
+{{#groupname}}
+    <div class="row mt-1">
+        <div class="col-xs-1">{{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}</div>
+        <div class="col-xs-11"><a href="{{url}}">{{{course.fullname}}}</a></div>
+    </div>
+    <div class="row mt-1">
+        <div class="col-xs-1">{{#pix}} i/groupevent, core, {{#str}} group {{/str}} {{/pix}}</div>
+        <div class="col-xs-11">{{{groupname}}}</div>
+    </div>
+{{/groupname}}
+{{#subscription}}
+    {{#displayeventsource}}
+        <div class="row mt-1">
+            <div class="col-xs-1">{{#pix}} i/rss, core, {{#str}} eventsource, core_calendar {{/str}} {{/pix}}</div>
+            <div class="col-xs-11">
+                {{#subscriptionurl}}
+                    <p><a href="{{subscriptionurl}}">{{#str}}subscriptionsource, core_calendar, {{{subscriptionname}}}{{/str}}</a></p>
+                {{/subscriptionurl}}
+                {{^subscriptionurl}}
+                    <p>{{#str}}subscriptionsource, core_calendar, {{{subscriptionname}}}{{/str}}</p>
+                {{/subscriptionurl}}
+            </div>
+        </div>
+    {{/displayeventsource}}
+{{/subscription}}
index 98431ea..ccbf773 100644 (file)
@@ -15,7 +15,7 @@
     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 }}
 {{!
-    @template calendar/event_item
+    @template core_calendar/event_item
 
     Calendar event item.
 
 
     Example context (json):
     {
+        "id": 1,
+        "name": "Sample event name",
+        "normalisedeventtype": "course",
+        "course": {
+            "id": 1
+        },
+        "canedit": true,
+        "candelete": true,
+        "isactionevent": true,
+        "icon": {
+            "key": "i/courseevent",
+            "component": "core",
+            "alttext": "Some course event"
+        },
+        "editurl": "#",
+        "url": "#"
     }
 }}
 <div{{!
     }} data-type="event"{{!
     }} data-course-id="{{course.id}}"{{!
     }} data-event-id="{{id}}"{{!
-    }} class="event"{{!
-    }} data-eventtype-{{calendareventtype}}="1"{{!
+    }} class="event m-t-1"{{!
+    }} data-eventtype-{{normalisedeventtype}}="1"{{!
     }} data-event-title="{{name}}"{{!
     }} data-event-count="{{eventcount}}"{{!
     }}>
-    <div class="card">
-        <div class="box card-header clearfix p-y-1">
+    <div class="card rounded">
+        <div class="box card-header clearfix calendar_event_{{normalisedeventtype}}">
             <div class="commands float-sm-right">
                 {{#canedit}}
                     {{#candelete}}
             {{#icon}}<div class="d-inline-block mt-1 align-top">{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}</div>{{/icon}}
             <div class="d-inline-block">
                 <h3 class="name d-inline-block">{{{name}}}</h3>
-                <span class="date float-sm-right mr-1">{{{formattedtime}}}</span>
-                <div class="location">{{#location}}{{{location}}}{{/location}}</div>
             </div>
         </div>
-        <div class="description card-block calendar_event_{{eventtype}}">
-            <p>{{{description}}}</p>
-            {{#iscourseevent}}
-                <div><a href="{{url}}">{{course.fullname}}</a></div>
-            {{/iscourseevent}}
-            {{> core_calendar/event_subscription}}
-            {{#isactionevent}}
-                <a href="{{url}}">{{#str}} gotoactivity, core_calendar {{/str}}</a>
-            {{/isactionevent}}
-            {{#groupname}}
-                <div><a href="{{url}}">{{{course.fullname}}}</a></div>
-                <div>{{{groupname}}}</div>
-            {{/groupname}}
+        <div class="description card-body">
+            {{> core_calendar/event_details }}
         </div>
+        {{#isactionevent}}
+            <div class="card-footer text-right bg-transparent">
+                <a href="{{url}}" class="card-link">{{#str}} gotoactivity, core_calendar {{/str}}</a>
+            </div>
+        {{/isactionevent}}
     </div>
 </div>
index f75157a..ae276ae 100644 (file)
@@ -15,7 +15,7 @@
     along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 }}
 {{!
-    @template calendar/event_list
+    @template core_calendar/event_list
 
     Calendar event list.
 
index 22d8d27..2d333b4 100644 (file)
     }} data-edit-url="{{editurl}}"{{!
     }}>
     <div class="container-fluid">
-        <div class="row">
-            <div class="col-xs-1">{{#pix}} i/calendareventtime, core, {{#str}} when, core_calendar {{/str}} {{/pix}}</div>
-            <div class="col-xs-11">{{{formattedtime}}}</div>
-        </div>
-        <div class="row mt-1">
-            <div class="col-xs-1">{{#pix}} i/calendar, core, {{#str}} eventtype, core_calendar {{/str}} {{/pix}}</div>
-            <div class="col-xs-11">{{eventtype}}</div>
-        </div>
-        {{#description}}
-        <div class="row mt-1">
-            <div class="col-xs-1">{{#pix}} i/calendareventdescription, core, {{#str}} description {{/str}} {{/pix}}</div>
-            <div class="description-content col-xs-11">{{{.}}}</div>
-        </div>
-        {{/description}}
-        {{#location}}
-        <div class="row mt-1">
-            <div class="col-xs-1">{{#pix}} i/location, core, {{#str}} location {{/str}} {{/pix}}</div>
-            <div class="location-content col-xs-11">{{{.}}}</div>
-        </div>
-        {{/location}}
-        {{#isactionevent}}
-        <div class="row mt-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 mt-1">
-            <div class="col-xs-1">{{#pix}} i/categoryevent, core, {{#str}} category {{/str}} {{/pix}}</div>
-            <div class="col-xs-11">{{{category.nestedname}}}</div>
-        </div>
-        {{/iscategoryevent}}
-        {{#iscourseevent}}
-        <div class="row mt-1">
-            <div class="col-xs-1">{{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}</div>
-            <div class="col-xs-11"><a href="{{url}}">{{{course.fullname}}}</a></div>
-        </div>
-        {{/iscourseevent}}
-        {{#groupname}}
-        <div class="row mt-1">
-            <div class="col-xs-1">{{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}</div>
-            <div class="col-xs-11"><a href="{{url}}">{{{course.fullname}}}</a></div>
-        </div>
-        <div class="row mt-1">
-            <div class="col-xs-1">{{#pix}} i/groupevent, core, {{#str}} group {{/str}} {{/pix}}</div>
-            <div class="col-xs-11">{{{groupname}}}</div>
-        </div>
-        {{/groupname}}
-        {{#subscription}}
-            {{#displayeventsource}}
-                <div class="row mt-1">
-                    <div class="col-xs-1">{{#pix}} i/rss, core, {{#str}} eventsource, core_calendar {{/str}} {{/pix}}</div>
-                    <div class="col-xs-11">
-                        {{#subscriptionurl}}
-                            <p><a href="{{subscriptionurl}}">{{#str}}subscriptionsource, core_calendar, {{{subscriptionname}}}{{/str}}</a></p>
-                        {{/subscriptionurl}}
-                        {{^subscriptionurl}}
-                            <p>{{#str}}subscriptionsource, core_calendar, {{{subscriptionname}}}{{/str}}</p>
-                        {{/subscriptionurl}}
-                    </div>
-                </div>
-            {{/displayeventsource}}
-        {{/subscription}}
+        {{> core_calendar/event_details }}
     </div>
 </div>
index 5041ca2..84ce421 100644 (file)
@@ -87,7 +87,7 @@
                                         {{/underway}}
                                         {{^underway}}
                                             <li data-region="event-item"
-                                                data-eventtype-{{calendareventtype}}="1"
+                                                data-eventtype-{{normalisedeventtype}}="1"
                                                 {{#draggable}}
                                                     draggable="true"
                                                     data-drag-type="move"
                                                 {{/draggable}}>
 
                                                 <a data-action="view-event" data-event-id="{{id}}" href="{{url}}" title="{{name}}">
-                                                    <span class="badge badge-circle calendar_event_{{calendareventtype}}">
+                                                    <span class="badge badge-circle calendar_event_{{normalisedeventtype}}">
                                                         &nbsp;
                                                     </span>
                                                     {{> core_calendar/event_icon}}
index 2a34335..b1aa06f 100644 (file)
                                 {{$nocontent}}{{#str}}eventnone, calendar{{/str}}{{/nocontent}}
                                 {{$content}}
                                     {{#events}}
-                                        <div data-popover-eventtype-{{calendareventtype}}="1">
+                                        <div data-popover-eventtype-{{normalisedeventtype}}="1">
                                             {{#modulename}}
                                                 {{#pix}} icon, {{modulename}} {{/pix}}
                                             {{/modulename}}
index 082d5bc..c952877 100644 (file)
@@ -41,7 +41,7 @@
     {{#events}}
         <div{{!
             }} class="event"{{!
-            }} data-eventtype-{{calendareventtype}}="1"{{!
+            }} data-eventtype-{{normalisedeventtype}}="1"{{!
             }} data-region="event-item"{{!
         }}>
             <span>{{#icon}}{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}{{/icon}}</span>
index 97a40a0..8326790 100644 (file)
@@ -427,14 +427,12 @@ table.calendartable caption {
     }
 }
 
-.summary-modal-container {
-    .description-content {
-        > p {
-            margin: 0;
-        }
-    }
+.location-content {
+    overflow-wrap: break-word;
+}
 
-    .location-content {
-        overflow-wrap: break-word;
+.description-content {
+    > p {
+        margin: 0;
     }
 }
index d618847..eccfaba 100644 (file)
@@ -11659,12 +11659,12 @@ table.calendartable caption {
 .day-popover-content:empty + .day-popover-alternate {
   display: block; }
 
-.summary-modal-container .description-content > p {
-  margin: 0; }
-
-.summary-modal-container .location-content {
+.location-content {
   overflow-wrap: break-word; }
 
+.description-content > p {
+  margin: 0; }
+
 /* course.less */
 /* COURSE CONTENT */
 .section-modchooser-link img {
index 663712e..5e200a1 100644 (file)
@@ -11900,12 +11900,12 @@ table.calendartable caption {
 .day-popover-content:empty + .day-popover-alternate {
   display: block; }
 
-.summary-modal-container .description-content > p {
-  margin: 0; }
-
-.summary-modal-container .location-content {
+.location-content {
   overflow-wrap: break-word; }
 
+.description-content > p {
+  margin: 0; }
+
 /* course.less */
 /* COURSE CONTENT */
 .section-modchooser-link img {