MDL-58866 core_calendar: separate color for other events, icons

This commit is contained in:
Marina Glancy 2020-04-30 18:55:36 +02:00
parent 6f92c731e7
commit d268c5bac3
15 changed files with 84 additions and 3 deletions

View File

@ -1,2 +1,2 @@
define ("core_calendar/selectors",[],function(){return{eventFilterItem:"[data-action='filter-event-type']",eventType:{site:"[data-eventtype-site]",category:"[data-eventtype-category]",course:"[data-eventtype-course]",group:"[data-eventtype-group]",user:"[data-eventtype-user]"},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]"},calendarPeriods:{month:"[data-period='month']"},courseSelector:"select[name=\"course\"]",viewSelector:"div[data-region=\"view-selector\"]",actions:{create:"[data-action=\"new-event-button\"]",edit:"[data-action=\"edit\"]",remove:"[data-action=\"delete\"]",viewEvent:"[data-action=\"view-event\"]"},elements:{courseSelector:"select[name=\"course\"]"},today:".today",day:"[data-region=\"day\"]",calendarMain:"[data-region=\"calendar\"]",wrapper:".calendarwrapper",eventItem:"[data-type=\"event\"]",links:{navLink:".calendarwrapper .arrow_link",eventLink:"[data-region='event-item']",miniDayLink:"[data-region='mini-day-link']"},containers:{loadingIcon:"[data-region=\"overlay-icon-container\"]"}}});
define ("core_calendar/selectors",[],function(){return{eventFilterItem:"[data-action='filter-event-type']",eventType:{site:"[data-eventtype-site]",category:"[data-eventtype-category]",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']"},courseSelector:"select[name=\"course\"]",viewSelector:"div[data-region=\"view-selector\"]",actions:{create:"[data-action=\"new-event-button\"]",edit:"[data-action=\"edit\"]",remove:"[data-action=\"delete\"]",viewEvent:"[data-action=\"view-event\"]"},elements:{courseSelector:"select[name=\"course\"]"},today:".today",day:"[data-region=\"day\"]",calendarMain:"[data-region=\"calendar\"]",wrapper:".calendarwrapper",eventItem:"[data-type=\"event\"]",links:{navLink:".calendarwrapper .arrow_link",eventLink:"[data-region='event-item']",miniDayLink:"[data-region='mini-day-link']"},containers:{loadingIcon:"[data-region=\"overlay-icon-container\"]"}}});
//# sourceMappingURL=selectors.min.js.map

View File

@ -1 +1 @@
{"version":3,"sources":["../src/selectors.js"],"names":["define","eventFilterItem","eventType","site","category","course","group","user","popoverType","calendarPeriods","month","courseSelector","viewSelector","actions","create","edit","remove","viewEvent","elements","today","day","calendarMain","wrapper","eventItem","links","navLink","eventLink","miniDayLink","containers","loadingIcon"],"mappings":"AAuBAA,OAAM,2BAAC,EAAD,CAAK,UAAW,CAClB,MAAO,CACHC,eAAe,CAAE,mCADd,CAEHC,SAAS,CAAE,CACPC,IAAI,CAAE,uBADC,CAEPC,QAAQ,CAAE,2BAFH,CAGPC,MAAM,CAAE,yBAHD,CAIPC,KAAK,CAAE,wBAJA,CAKPC,IAAI,CAAE,uBALC,CAFR,CASHC,WAAW,CAAE,CACTL,IAAI,CAAE,+BADG,CAETC,QAAQ,CAAE,mCAFD,CAGTC,MAAM,CAAE,iCAHC,CAITC,KAAK,CAAE,gCAJE,CAKTC,IAAI,CAAE,+BALG,CATV,CAgBHE,eAAe,CAAE,CACbC,KAAK,CAAE,uBADM,CAhBd,CAmBHC,cAAc,CAAE,yBAnBb,CAoBHC,YAAY,CAAE,oCApBX,CAqBHC,OAAO,CAAE,CACLC,MAAM,CAAE,oCADH,CAELC,IAAI,CAAE,wBAFD,CAGLC,MAAM,CAAE,0BAHH,CAILC,SAAS,CAAE,8BAJN,CArBN,CA2BHC,QAAQ,CAAE,CACNP,cAAc,CAAE,yBADV,CA3BP,CA8BHQ,KAAK,CAAE,QA9BJ,CA+BHC,GAAG,CAAE,uBA/BF,CAgCHC,YAAY,CAAE,4BAhCX,CAiCHC,OAAO,CAAE,kBAjCN,CAkCHC,SAAS,CAAE,uBAlCR,CAmCHC,KAAK,CAAE,CACHC,OAAO,CAAE,8BADN,CAEHC,SAAS,CAAE,4BAFR,CAGHC,WAAW,CAAE,+BAHV,CAnCJ,CAwCHC,UAAU,CAAE,CACRC,WAAW,CAAE,0CADL,CAxCT,CA4CV,CA7CK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * This module is responsible for the calendar filter.\n *\n * @module core_calendar/calendar_selectors\n * @package core_calendar\n * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n eventFilterItem: \"[data-action='filter-event-type']\",\n eventType: {\n site: \"[data-eventtype-site]\",\n category: \"[data-eventtype-category]\",\n course: \"[data-eventtype-course]\",\n group: \"[data-eventtype-group]\",\n user: \"[data-eventtype-user]\",\n },\n popoverType: {\n site: \"[data-popover-eventtype-site]\",\n category: \"[data-popover-eventtype-category]\",\n course: \"[data-popover-eventtype-course]\",\n group: \"[data-popover-eventtype-group]\",\n user: \"[data-popover-eventtype-user]\",\n },\n calendarPeriods: {\n month: \"[data-period='month']\",\n },\n courseSelector: 'select[name=\"course\"]',\n viewSelector: 'div[data-region=\"view-selector\"]',\n actions: {\n create: '[data-action=\"new-event-button\"]',\n edit: '[data-action=\"edit\"]',\n remove: '[data-action=\"delete\"]',\n viewEvent: '[data-action=\"view-event\"]',\n },\n elements: {\n courseSelector: 'select[name=\"course\"]',\n },\n today: '.today',\n day: '[data-region=\"day\"]',\n calendarMain: '[data-region=\"calendar\"]',\n wrapper: '.calendarwrapper',\n eventItem: '[data-type=\"event\"]',\n links: {\n navLink: '.calendarwrapper .arrow_link',\n eventLink: \"[data-region='event-item']\",\n miniDayLink: \"[data-region='mini-day-link']\",\n },\n containers: {\n loadingIcon: '[data-region=\"overlay-icon-container\"]',\n },\n };\n});\n"],"file":"selectors.min.js"}
{"version":3,"sources":["../src/selectors.js"],"names":["define","eventFilterItem","eventType","site","category","course","group","user","other","popoverType","calendarPeriods","month","courseSelector","viewSelector","actions","create","edit","remove","viewEvent","elements","today","day","calendarMain","wrapper","eventItem","links","navLink","eventLink","miniDayLink","containers","loadingIcon"],"mappings":"AAuBAA,OAAM,2BAAC,EAAD,CAAK,UAAW,CAClB,MAAO,CACHC,eAAe,CAAE,mCADd,CAEHC,SAAS,CAAE,CACPC,IAAI,CAAE,uBADC,CAEPC,QAAQ,CAAE,2BAFH,CAGPC,MAAM,CAAE,yBAHD,CAIPC,KAAK,CAAE,wBAJA,CAKPC,IAAI,CAAE,uBALC,CAMPC,KAAK,CAAE,wBANA,CAFR,CAUHC,WAAW,CAAE,CACTN,IAAI,CAAE,+BADG,CAETC,QAAQ,CAAE,mCAFD,CAGTC,MAAM,CAAE,iCAHC,CAITC,KAAK,CAAE,gCAJE,CAKTC,IAAI,CAAE,+BALG,CAMTC,KAAK,CAAE,gCANE,CAVV,CAkBHE,eAAe,CAAE,CACbC,KAAK,CAAE,uBADM,CAlBd,CAqBHC,cAAc,CAAE,yBArBb,CAsBHC,YAAY,CAAE,oCAtBX,CAuBHC,OAAO,CAAE,CACLC,MAAM,CAAE,oCADH,CAELC,IAAI,CAAE,wBAFD,CAGLC,MAAM,CAAE,0BAHH,CAILC,SAAS,CAAE,8BAJN,CAvBN,CA6BHC,QAAQ,CAAE,CACNP,cAAc,CAAE,yBADV,CA7BP,CAgCHQ,KAAK,CAAE,QAhCJ,CAiCHC,GAAG,CAAE,uBAjCF,CAkCHC,YAAY,CAAE,4BAlCX,CAmCHC,OAAO,CAAE,kBAnCN,CAoCHC,SAAS,CAAE,uBApCR,CAqCHC,KAAK,CAAE,CACHC,OAAO,CAAE,8BADN,CAEHC,SAAS,CAAE,4BAFR,CAGHC,WAAW,CAAE,+BAHV,CArCJ,CA0CHC,UAAU,CAAE,CACRC,WAAW,CAAE,0CADL,CA1CT,CA8CV,CA/CK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * This module is responsible for the calendar filter.\n *\n * @module core_calendar/calendar_selectors\n * @package core_calendar\n * @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([], function() {\n return {\n eventFilterItem: \"[data-action='filter-event-type']\",\n eventType: {\n site: \"[data-eventtype-site]\",\n category: \"[data-eventtype-category]\",\n course: \"[data-eventtype-course]\",\n group: \"[data-eventtype-group]\",\n user: \"[data-eventtype-user]\",\n other: \"[data-eventtype-other]\",\n },\n popoverType: {\n site: \"[data-popover-eventtype-site]\",\n category: \"[data-popover-eventtype-category]\",\n course: \"[data-popover-eventtype-course]\",\n group: \"[data-popover-eventtype-group]\",\n user: \"[data-popover-eventtype-user]\",\n other: \"[data-popover-eventtype-other]\",\n },\n calendarPeriods: {\n month: \"[data-period='month']\",\n },\n courseSelector: 'select[name=\"course\"]',\n viewSelector: 'div[data-region=\"view-selector\"]',\n actions: {\n create: '[data-action=\"new-event-button\"]',\n edit: '[data-action=\"edit\"]',\n remove: '[data-action=\"delete\"]',\n viewEvent: '[data-action=\"view-event\"]',\n },\n elements: {\n courseSelector: 'select[name=\"course\"]',\n },\n today: '.today',\n day: '[data-region=\"day\"]',\n calendarMain: '[data-region=\"calendar\"]',\n wrapper: '.calendarwrapper',\n eventItem: '[data-type=\"event\"]',\n links: {\n navLink: '.calendarwrapper .arrow_link',\n eventLink: \"[data-region='event-item']\",\n miniDayLink: \"[data-region='mini-day-link']\",\n },\n containers: {\n loadingIcon: '[data-region=\"overlay-icon-container\"]',\n },\n };\n});\n"],"file":"selectors.min.js"}

View 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']",

View 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);

View 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';

View 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;
}

View 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,

View 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) {

View 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}}"{{!

View 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"

View 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';

View 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',

View 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 {

View 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;

View 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;