Skip to content

Commit

Permalink
MDL-58866 core_calendar: separate color for other events, icons
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed May 19, 2020
1 parent 6f92c73 commit d268c5b
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 3 deletions.
2 changes: 1 addition & 1 deletion calendar/amd/build/selectors.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion calendar/amd/build/selectors.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions calendar/amd/src/selectors.js
Expand Up @@ -30,13 +30,15 @@ define([], function() {
course: "[data-eventtype-course]",
group: "[data-eventtype-group]",
user: "[data-eventtype-user]",
other: "[data-eventtype-other]",
},
popoverType: {
site: "[data-popover-eventtype-site]",
category: "[data-popover-eventtype-category]",
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']",
Expand Down
4 changes: 4 additions & 0 deletions calendar/classes/external/event_exporter_base.php
Expand Up @@ -288,6 +288,10 @@ protected function get_other_values(renderer_base $output) {
$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);
Expand Down
17 changes: 17 additions & 0 deletions calendar/classes/external/event_icon_exporter.php
Expand Up @@ -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;
Expand All @@ -70,6 +71,22 @@ public function __construct(event_interface $event, $related = []) {
} 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';
Expand Down
3 changes: 2 additions & 1 deletion calendar/classes/local/event/container.php
Expand Up @@ -133,7 +133,8 @@ function ($dbrow) {
}
}

// 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;
}
Expand Down
3 changes: 3 additions & 0 deletions calendar/classes/local/event/data_access/event_vault.php
Expand Up @@ -211,6 +211,9 @@ public function get_action_events_by_timesort(
return array_merge($carry, $groupings[0]);
}, []);

// Always include the site events.
$courseids = $courseids ? array_merge($courseids, [SITEID]) : $courseids;

return $this->get_events(
null,
null,
Expand Down
2 changes: 2 additions & 0 deletions calendar/lib.php
Expand Up @@ -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;
}

Expand Down Expand Up @@ -3686,6 +3687,7 @@ function calendar_get_filter_types() {
'course',
'group',
'user',
'other'
];

return array_map(function($type) {
Expand Down
2 changes: 2 additions & 0 deletions calendar/templates/event_item.mustache
Expand Up @@ -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}}"{{!
Expand Down
2 changes: 2 additions & 0 deletions calendar/templates/month_detailed.mustache
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions lang/en/calendar.php
Expand Up @@ -153,6 +153,7 @@
$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';
Expand Down
1 change: 1 addition & 0 deletions lib/classes/output/icon_system_fontawesome.php
Expand Up @@ -288,6 +288,7 @@ public function get_core_icon_map() {
'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',
Expand Down
22 changes: 22 additions & 0 deletions theme/boost/scss/moodle/calendar.scss
Expand Up @@ -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 {
Expand All @@ -27,6 +28,10 @@ $calendarEventUserColor: #dce7ec !default; // Pale blue.
background-color: $calendarEventUserColor;
}

.calendar_event_other {
background-color: $calendarEventOtherColor;
}

// Calendar restyling.
.path-calendar {
.calendartable {
Expand Down Expand Up @@ -150,6 +155,10 @@ $calendarEventUserColor: #dce7ec !default; // Pale blue.
&.calendar_event_user {
background-color: $calendarEventUserColor;
}

&.calendar_event_other {
background-color: $calendarEventOtherColor;
}
}
}
}
Expand Down Expand Up @@ -213,6 +222,10 @@ $calendarEventUserColor: #dce7ec !default; // Pale blue.
border-color: $calendarEventUserColor;
}

.calendar_event_other {
border-color: $calendarEventOtherColor;
}

.calendartable {
td,
li {
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions theme/boost/style/moodle.css
Expand Up @@ -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; }
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d268c5b

Please sign in to comment.