MDL-58866 core_calendar: separate color for other events, icons
authorMarina Glancy <marina@moodle.com>
Thu, 30 Apr 2020 16:55:36 +0000 (18:55 +0200)
committerMarina Glancy <marina@moodle.com>
Tue, 19 May 2020 17:04:15 +0000 (19:04 +0200)
15 files changed:
calendar/amd/build/selectors.min.js
calendar/amd/build/selectors.min.js.map
calendar/amd/src/selectors.js
calendar/classes/external/event_exporter_base.php
calendar/classes/external/event_icon_exporter.php
calendar/classes/local/event/container.php
calendar/classes/local/event/data_access/event_vault.php
calendar/lib.php
calendar/templates/event_item.mustache
calendar/templates/month_detailed.mustache
lang/en/calendar.php
lib/classes/output/icon_system_fontawesome.php
theme/boost/scss/moodle/calendar.scss
theme/boost/style/moodle.css
theme/classic/style/moodle.css

index 33e86ea..bcb161f 100644 (file)
Binary files a/calendar/amd/build/selectors.min.js and b/calendar/amd/build/selectors.min.js differ
index b37731a..cd5c94c 100644 (file)
Binary files a/calendar/amd/build/selectors.min.js.map and b/calendar/amd/build/selectors.min.js.map differ
index 80ba378..6ecbea3 100644 (file)
@@ -30,6 +30,7 @@ define([], function() {
             course: "[data-eventtype-course]",
             group: "[data-eventtype-group]",
             user: "[data-eventtype-user]",
+            other: "[data-eventtype-other]",
         },
         popoverType: {
             site: "[data-popover-eventtype-site]",
@@ -37,6 +38,7 @@ define([], function() {
             course: "[data-popover-eventtype-course]",
             group: "[data-popover-eventtype-group]",
             user: "[data-popover-eventtype-user]",
+            other: "[data-popover-eventtype-other]",
         },
         calendarPeriods: {
             month: "[data-period='month']",
index ed241f2..5342220 100644 (file)
@@ -288,6 +288,10 @@ class event_exporter_base extends exporter {
         $iconexporter = new event_icon_exporter($event, ['context' => $context]);
         $identifier = 'type' . $values['normalisedeventtype'];
         $stringexists = get_string_manager()->string_exists($identifier, 'calendar');
+        if (!$stringexists) {
+            // Property normalisedeventtype is used to build the name of the CSS class for the events.
+            $values['normalisedeventtype'] = 'other';
+        }
         $values['normalisedeventtypetext'] = $stringexists ? get_string($identifier, 'calendar') : '';
 
         $values['icon'] = $iconexporter->export($output);
index 1949a9e..1f866d8 100644 (file)
@@ -45,6 +45,7 @@ class event_icon_exporter extends exporter {
      * @param array $related The related data.
      */
     public function __construct(event_interface $event, $related = []) {
+        global $PAGE;
         $coursemodule = $event->get_course_module();
         $category = $event->get_category();
         $categoryid = $category ? $category->get('id') : null;
@@ -70,6 +71,22 @@ class event_icon_exporter extends exporter {
             } else {
                 $alttext = get_string('activityevent', 'calendar');
             }
+        } else if ($event->get_component()) {
+            // Guess the icon and the title for the component event. By default display calendar icon and the
+            // plugin name as the alttext.
+            if ($PAGE->theme->resolve_image_location($event->get_type(), $event->get_component())) {
+                $key = $event->get_type();
+                $component = $event->get_component();
+            } else {
+                $key = 'i/otherevent';
+                $component = 'core';
+            }
+
+            if (get_string_manager()->string_exists($event->get_type(), $event->get_component())) {
+                $alttext = get_string($event->get_type(), $event->get_component());
+            } else {
+                $alttext = get_string('pluginname', $event->get_component());
+            }
         } else if ($issiteevent) {
             $key = 'i/siteevent';
             $component = 'core';
index 76f7736..a820cc9 100644 (file)
@@ -133,7 +133,8 @@ class container {
                         }
                     }
 
-                    // At present we only have a bail-out check for events in course modules.
+                    // For non-module events we assume that all checks were done in core_calendar_is_event_visible callback.
+                    // For module events we also check that the course module and course itself are visible to the user.
                     if (empty($dbrow->modulename)) {
                         return false;
                     }
index 8a8c20d..7bda7bf 100644 (file)
@@ -211,6 +211,9 @@ class event_vault implements event_vault_interface {
             return array_merge($carry, $groupings[0]);
         }, []);
 
+        // Always include the site events.
+        $courseids = $courseids ? array_merge($courseids, [SITEID]) : $courseids;
+
         return $this->get_events(
             null,
             null,
index 2156628..c194636 100644 (file)
@@ -2286,6 +2286,7 @@ function calendar_edit_event_allowed($event, $manualedit = false) {
     }
 
     if ($manualedit && !empty($event->component)) {
+        // TODO possibly we can later add a callback similar to core_calendar_event_timestart_updated in the modules.
         return false;
     }
 
@@ -3686,6 +3687,7 @@ function calendar_get_filter_types() {
         'course',
         'group',
         'user',
+        'other'
     ];
 
     return array_map(function($type) {
index 9b4c160..6f30790 100644 (file)
@@ -52,6 +52,8 @@
     }} data-course-id="{{course.id}}"{{!
     }} data-event-id="{{id}}"{{!
     }} class="event m-t-1"{{!
+    }} data-event-component="{{component}}"{{!
+    }} data-event-eventtype="{{eventtype}}"{{!
     }} data-eventtype-{{normalisedeventtype}}="1"{{!
     }} data-event-title="{{name}}"{{!
     }} data-event-count="{{eventcount}}"{{!
index e1273ec..11608cd 100644 (file)
@@ -89,6 +89,8 @@
                                         {{/underway}}
                                         {{^underway}}
                                             <li data-region="event-item"
+                                                dava-event-component="{{component}}"
+                                                data-event-eventtype="{{eventtype}}"
                                                 data-eventtype-{{normalisedeventtype}}="1"
                                                 {{#draggable}}
                                                     draggable="true"
index cea9d7e..6f1c4f9 100644 (file)
@@ -153,6 +153,7 @@ $string['eventtypecategory'] = 'category';
 $string['eventtypecourse'] = 'course';
 $string['eventtypemodule'] = 'module';
 $string['eventtypegroup'] = 'group';
+$string['eventtypeother'] = 'other';
 $string['eventtypeuser'] = 'user';
 $string['hideeventtype'] = 'Hide {$a} events';
 $string['showeventtype'] = 'Show {$a} events';
index 6c1f4d5..2389dc4 100644 (file)
@@ -288,6 +288,7 @@ class icon_system_fontawesome extends icon_system_font {
             'core:i/nosubcat' => 'fa-plus-square-o',
             'core:i/notifications' => 'fa-bell',
             'core:i/open' => 'fa-folder-open',
+            'core:i/otherevent' => 'fa-calendar',
             'core:i/outcomes' => 'fa-tasks',
             'core:i/payment' => 'fa-money',
             'core:i/permissionlock' => 'fa-lock',
index 869b210..53fdb52 100644 (file)
@@ -6,6 +6,7 @@ $calendarEventCourseColor: #ffd3bd !default; // Pale red.
 $calendarEventGlobalColor: #d6f8cd !default; // Pale green.
 $calendarEventGroupColor: #fee7ae !default; // Pale yellow.
 $calendarEventUserColor: #dce7ec !default; // Pale blue.
+$calendarEventOtherColor: #ced4da !default; // Pale gray.
 
 // Calendar event background colours defined.
 .calendar_event_category {
@@ -27,6 +28,10 @@ $calendarEventUserColor: #dce7ec !default; // Pale blue.
     background-color: $calendarEventUserColor;
 }
 
+.calendar_event_other {
+    background-color: $calendarEventOtherColor;
+}
+
 // Calendar restyling.
 .path-calendar {
     .calendartable {
@@ -150,6 +155,10 @@ $calendarEventUserColor: #dce7ec !default; // Pale blue.
                             &.calendar_event_user {
                                 background-color: $calendarEventUserColor;
                             }
+
+                            &.calendar_event_other {
+                                background-color: $calendarEventOtherColor;
+                            }
                         }
                     }
                 }
@@ -213,6 +222,10 @@ $calendarEventUserColor: #dce7ec !default; // Pale blue.
             border-color: $calendarEventUserColor;
         }
 
+        .calendar_event_other {
+            border-color: $calendarEventOtherColor;
+        }
+
         .calendartable {
             td,
             li {
@@ -322,6 +335,15 @@ $calendarEventUserColor: #dce7ec !default; // Pale blue.
                     background-color: $calendarEventUserColor;
                 }
             }
+
+            &.duration_other {
+                border-top: 1px solid $calendarEventOtherColor;
+                border-bottom: 1px solid $calendarEventOtherColor;
+
+                &.duration_finish {
+                    background-color: $calendarEventOtherColor;
+                }
+            }
         }
 
         caption {
index a71a92b..205cfae 100644 (file)
@@ -12248,6 +12248,9 @@ body.h5p-embed .h5pmessages {
 .calendar_event_user {
   background-color: #dce7ec; }
 
+.calendar_event_other {
+  background-color: #ced4da; }
+
 .path-calendar .calendartable {
   width: 100%;
   table-layout: fixed; }
@@ -12332,6 +12335,8 @@ body.h5p-embed .h5pmessages {
             background-color: #fee7ae; }
           .path-calendar .maincalendar .calendarmonth ul li .badge.badge-circle.calendar_event_user {
             background-color: #dce7ec; }
+          .path-calendar .maincalendar .calendarmonth ul li .badge.badge-circle.calendar_event_other {
+            background-color: #ced4da; }
     .path-calendar .maincalendar .calendarmonth td {
       height: 5em; }
     .path-calendar .maincalendar .calendarmonth .clickable:hover {
@@ -12361,6 +12366,8 @@ body.h5p-embed .h5pmessages {
     border-color: #fee7ae; }
   .path-calendar .maincalendar .calendar_event_user {
     border-color: #dce7ec; }
+  .path-calendar .maincalendar .calendar_event_other {
+    border-color: #ced4da; }
   .path-calendar .maincalendar .calendartable td,
   .path-calendar .maincalendar .calendartable li {
     padding: 0 4px 4px 4px; }
@@ -12419,6 +12426,11 @@ body.h5p-embed .h5pmessages {
     border-bottom: 1px solid #dce7ec; }
     .block .minicalendar td.duration_user.duration_finish {
       background-color: #dce7ec; }
+  .block .minicalendar td.duration_other {
+    border-top: 1px solid #ced4da;
+    border-bottom: 1px solid #ced4da; }
+    .block .minicalendar td.duration_other.duration_finish {
+      background-color: #ced4da; }
   .block .minicalendar caption {
     font-size: inherit;
     font-weight: inherit;
index d5ea721..4b3a7c1 100644 (file)
@@ -12461,6 +12461,9 @@ body.h5p-embed .h5pmessages {
 .calendar_event_user {
   background-color: #dce7ec; }
 
+.calendar_event_other {
+  background-color: #ced4da; }
+
 .path-calendar .calendartable {
   width: 100%;
   table-layout: fixed; }
@@ -12545,6 +12548,8 @@ body.h5p-embed .h5pmessages {
             background-color: #fee7ae; }
           .path-calendar .maincalendar .calendarmonth ul li .badge.badge-circle.calendar_event_user {
             background-color: #dce7ec; }
+          .path-calendar .maincalendar .calendarmonth ul li .badge.badge-circle.calendar_event_other {
+            background-color: #ced4da; }
     .path-calendar .maincalendar .calendarmonth td {
       height: 5em; }
     .path-calendar .maincalendar .calendarmonth .clickable:hover {
@@ -12574,6 +12579,8 @@ body.h5p-embed .h5pmessages {
     border-color: #fee7ae; }
   .path-calendar .maincalendar .calendar_event_user {
     border-color: #dce7ec; }
+  .path-calendar .maincalendar .calendar_event_other {
+    border-color: #ced4da; }
   .path-calendar .maincalendar .calendartable td,
   .path-calendar .maincalendar .calendartable li {
     padding: 0 4px 4px 4px; }
@@ -12632,6 +12639,11 @@ body.h5p-embed .h5pmessages {
     border-bottom: 1px solid #dce7ec; }
     .block .minicalendar td.duration_user.duration_finish {
       background-color: #dce7ec; }
+  .block .minicalendar td.duration_other {
+    border-top: 1px solid #ced4da;
+    border-bottom: 1px solid #ced4da; }
+    .block .minicalendar td.duration_other.duration_finish {
+      background-color: #ced4da; }
   .block .minicalendar caption {
     font-size: inherit;
     font-weight: inherit;