feat: associate events with resource IDs
This commit is contained in:
parent
788694dae5
commit
433568751c
1 changed files with 18 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import STATIC_LOCATIONS from './static-ens-locations.json';
|
||||||
|
|
||||||
// https://stackoverflow.com/a/35970186
|
// https://stackoverflow.com/a/35970186
|
||||||
function invertColor(hex) {
|
function invertColor(hex) {
|
||||||
if (hex.indexOf('#') === 0) {
|
if (hex.indexOf('#') === 0) {
|
||||||
|
@ -231,6 +233,18 @@ class Calendar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findLocationId(location) {
|
||||||
|
// TODO: Perform ad-hoc patches of location so it can be better associated.
|
||||||
|
// Strip '(Jourdan)'
|
||||||
|
// Relocate room number
|
||||||
|
|
||||||
|
const result = Object.entries(STATIC_LOCATIONS).find(([building, rooms]) => rooms.includes(location));
|
||||||
|
|
||||||
|
if (result === undefined) return undefined;
|
||||||
|
const [building, _] = result;
|
||||||
|
return `${building}-${location}`;
|
||||||
|
}
|
||||||
|
|
||||||
function fcEventFromjCalEvent(cal) {
|
function fcEventFromjCalEvent(cal) {
|
||||||
return function (evt) {
|
return function (evt) {
|
||||||
const start = new Date(evt.dtstart)
|
const start = new Date(evt.dtstart)
|
||||||
|
@ -249,6 +263,10 @@ function fcEventFromjCalEvent(cal) {
|
||||||
fcEvent.description = evt.description
|
fcEvent.description = evt.description
|
||||||
fcEvent.location = evt.location || cal.default_location
|
fcEvent.location = evt.location || cal.default_location
|
||||||
|
|
||||||
|
if (fcEvent.location) {
|
||||||
|
fcEvent.resourceId = findLocationId(fcEvent.location);
|
||||||
|
}
|
||||||
|
|
||||||
if (evt.status) {
|
if (evt.status) {
|
||||||
fcEvent.status = evt.status
|
fcEvent.status = evt.status
|
||||||
fcEvent.classNames = [`st-${evt.status.toLowerCase()}`]
|
fcEvent.classNames = [`st-${evt.status.toLowerCase()}`]
|
||||||
|
|
Loading…
Reference in a new issue