Commit e77b46e3 authored by Leon Tappe's avatar Leon Tappe 🔥
Browse files

declutter calendar for users and fix loading times

parent f74e1554
......@@ -59,7 +59,7 @@ async function setupLandingCalendar() {
}
_calendars.landing = new FullCalendar.Calendar($("#landing_calendar_fc")[0], {
plugins: [ 'dayGrid', 'timeGrid', 'list' ],
plugins: ['dayGrid', 'timeGrid', 'list'],
locale: 'de',
firstDay: 1,
weekNumberCalculation: 'ISO',
......@@ -98,32 +98,32 @@ async function setupLandingCalendar() {
$(info.el).attr('title', info.event._def.extendedProps.room.shortname + " - " + info.event._def.extendedProps.reservation.subject + " (" + info.event._def.extendedProps.reservation.contact.name + ")"); // Because jqueryui wants a title attr, even though we are overwriting this below with our custom tooltip
$(info.el).tooltip({
content: "<b>" + info.event._def.extendedProps.reservation.subject + "</b><br />" + info.event._def.extendedProps.room.longname + " (" + info.event._def.extendedProps.room.location + ")" +
(info.event._def.extendedProps.reservation.confirmed === 1 ? '<br /><br /><b>BEST&Auml;TIGT</b>' : '') +
(info.event._def.extendedProps.reservation.denied === 1 ? '<br /><br /><b>ABGELEHNT</b>' : '') +
"<br /><br /><b>Zeitraum " + (info.event._def.extendedProps.room.room_type === 1 ? "Lernsprint" : (info.event._def.extendedProps.room.room_type === 5 ? "StudySpace" : "Veranstaltung")) + ":</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.to) +
(info.view.type !== "timeGridWeek" && _validateDate(info.event._def.extendedProps.reservation.preparation.from) ?
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to)
: "") +
"<br /><br /><b>Buchender:</b><br />" +
info.event._def.extendedProps.reservation.contact.name + "<br />" +
"📧 " + info.event._def.extendedProps.reservation.contact.email + "<br />" +
"📞 " + info.event._def.extendedProps.reservation.contact.phone +
(info.event._def.extendedProps.reservation.contact.web !== "" ? "<br />🌍 " + _truncString(info.event._def.extendedProps.reservation.contact.web, 32, '') : '') +
"<br /><br /><b>Kommentar:</b><br />" +
_truncString(info.event._def.extendedProps.reservation.comments.user, 80, " [\u2026]<br /><i>Anklicken zum Weiterlesen</i>"),
(info.event._def.extendedProps.reservation.confirmed === 1 ? '<br /><br /><b>BEST&Auml;TIGT</b>' : '') +
(info.event._def.extendedProps.reservation.denied === 1 ? '<br /><br /><b>ABGELEHNT</b>' : '') +
"<br /><br /><b>Zeitraum " + (info.event._def.extendedProps.room.room_type === 1 ? "Lernsprint" : (info.event._def.extendedProps.room.room_type === 5 ? "StudySpace" : "Veranstaltung")) + ":</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.to) +
(info.view.type !== "timeGridWeek" && _validateDate(info.event._def.extendedProps.reservation.preparation.from) ?
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to)
: "") +
"<br /><br /><b>Buchender:</b><br />" +
info.event._def.extendedProps.reservation.contact.name + "<br />" +
"📧 " + info.event._def.extendedProps.reservation.contact.email + "<br />" +
"📞 " + info.event._def.extendedProps.reservation.contact.phone +
(info.event._def.extendedProps.reservation.contact.web !== "" ? "<br />🌍 " + _truncString(info.event._def.extendedProps.reservation.contact.web, 32, '') : '') +
"<br /><br /><b>Kommentar:</b><br />" +
_truncString(info.event._def.extendedProps.reservation.comments.user, 80, " [\u2026]<br /><i>Anklicken zum Weiterlesen</i>"),
track: true
});
} else if (info.event._def.extendedProps.timeslot === "preparation") {
$(info.el).attr('title', info.event._def.extendedProps.room.shortname + " - " + info.event._def.extendedProps.reservation.subject + " (" + info.event._def.extendedProps.reservation.contact.name + ")"); // Because jqueryui wants a title attr, even though we are overwriting this below with our custom tooltip
$(info.el).tooltip({
content: "<b>" + info.event._def.extendedProps.reservation.subject + "</b>" +
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to),
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to),
track: true
});
}
......@@ -146,7 +146,7 @@ async function setupFrontendCalendar() {
}
_calendars.frontend = new FullCalendar.Calendar($("#frontend_calendar_fc")[0], {
plugins: [ 'dayGrid', 'timeGrid', 'list', 'interaction' ],
plugins: ['dayGrid', 'timeGrid', 'list', 'interaction'],
locale: 'de',
firstDay: 1,
weekNumberCalculation: 'ISO',
......@@ -172,23 +172,23 @@ async function setupFrontendCalendar() {
$(info.el).attr('title', info.event._def.extendedProps.room.shortname + " - " + info.event._def.extendedProps.reservation.id); // Because jqueryui wants a title attr, even though we are overwriting this below with our custom tooltip
$(info.el).tooltip({
content: "<b>Buchung Nr. " + info.event._def.extendedProps.reservation.id + "</b><br />" + info.event._def.extendedProps.room.longname + " (" + info.event._def.extendedProps.room.location + ")" +
(info.event._def.extendedProps.reservation.confirmed === 1 ? '<br /><br /><b>BEST&Auml;TIGT</b>' : '') +
(info.event._def.extendedProps.reservation.denied === 1 ? '<br /><br /><b>ABGELEHNT</b>' : '') +
(info.view.type === "dayGridMonth" && _validateDate(info.event._def.extendedProps.reservation.preparation.from) ? "<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to) : "") +
"<br /><br /><b>Zeitraum " + (info.event._def.extendedProps.room.room_type === 1 ? "Lernsprint" : (info.event._def.extendedProps.room.room_type === 5 ? "StudySpace" : "Veranstaltung")) + ":</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.to),
(info.event._def.extendedProps.reservation.confirmed === 1 ? '<br /><br /><b>BEST&Auml;TIGT</b>' : '') +
(info.event._def.extendedProps.reservation.denied === 1 ? '<br /><br /><b>ABGELEHNT</b>' : '') +
(info.view.type === "dayGridMonth" && _validateDate(info.event._def.extendedProps.reservation.preparation.from) ? "<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to) : "") +
"<br /><br /><b>Zeitraum " + (info.event._def.extendedProps.room.room_type === 1 ? "Lernsprint" : (info.event._def.extendedProps.room.room_type === 5 ? "StudySpace" : "Veranstaltung")) + ":</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.to),
track: true
});
} else if (info.event._def.extendedProps.timeslot === "preparation") {
$(info.el).attr('title', info.event._def.extendedProps.room.shortname + " - " + info.event._def.extendedProps.reservation.id); // Because jqueryui wants a title attr, even though we are overwriting this below with our custom tooltip
$(info.el).tooltip({
content: "<b>Buchung Nr. " + info.event._def.extendedProps.reservation.id + "</b>" +
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to),
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to),
track: true
});
}
......@@ -209,7 +209,7 @@ async function setupFrontendCalendar() {
*/
function fillLandingCalendar() {
const view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _calendars.landing.view;
const callback = arguments.length > 1 && arguments[1] !== undefined && typeof arguments[1] === "function" ? arguments[1] : () => {};
const callback = arguments.length > 1 && arguments[1] !== undefined && typeof arguments[1] === "function" ? arguments[1] : () => { };
if (_currentTab === "#landing_page") {
_calendars.landing.batchRendering(() => $.each(_calendars.landing.getEvents(), (i, e) => e.remove()));
......@@ -217,13 +217,18 @@ function fillLandingCalendar() {
let rooms = [];
let selected_room = -1;
if ((selected_room = parseInt($("#landing_calendar_room").val())) !== -1) {
rooms = [ selected_room ];
if (_loggedInUser.admin > 1) {
if ((selected_room = parseInt($("#landing_calendar_room").val())) !== -1) {
rooms = [selected_room];
} else {
rooms = _loggedInUser.admin > 1 ? _rooms : _rooms.filter((r) => _loggedInUser.roles.includes(r.room_type));
rooms = rooms.map((r) => r.id);
}
} else {
rooms = _loggedInUser.admin > 1 ? _rooms : _rooms.filter((r) => _loggedInUser.roles.includes(r.room_type));
rooms = rooms.map((r) => r.id);
rooms = [1, 2];
}
let asyncs_done = 0;
_callBackend({
......@@ -249,7 +254,7 @@ function fillLandingCalendar() {
_calendars.landing.batchRendering(() => {
$.each(_events.unconfirmed, (i, e) => {
_calendars.landing.addEvent({
title: e.room.room_type === 5 ? 'StudySpace - ' + e.contact.name : e.room.shortname.substring(0,3).toUpperCase() + " - " + e.subject + " (" + e.contact.name + ")",
title: e.room.room_type === 5 ? 'StudySpace - ' + e.contact.name : e.room.shortname.substring(0, 3).toUpperCase() + " - " + e.subject + " (" + e.contact.name + ")",
start: dayjs(e.event.from).$d,
end: dayjs(e.event.to).$d,
color: e.room.calendar_color,
......@@ -312,7 +317,7 @@ function fillLandingCalendar() {
_calendars.landing.batchRendering(() => {
$.each(_events.confirmed, (i, e) => {
_calendars.landing.addEvent({
title: e.room.room_type === 5 ? 'StudySpace - ' + e.contact.name : e.room.shortname.substring(0,3).toUpperCase() + " - " + e.subject + " (" + e.contact.name + ")",
title: e.room.room_type === 5 ? 'StudySpace - ' + e.contact.name : e.room.shortname.substring(0, 3).toUpperCase() + " - " + e.subject + " (" + e.contact.name + ")",
start: dayjs(e.event.from).$d,
end: dayjs(e.event.to).$d,
color: e.room.calendar_color_confirmed,
......@@ -359,7 +364,7 @@ function fillLandingCalendar() {
*/
function fillFrontendCalendar() {
const view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _calendars.frontend.view;
const callback = arguments.length > 1 && arguments[1] !== undefined && typeof arguments[1] === "function" ? arguments[1] : () => {};
const callback = arguments.length > 1 && arguments[1] !== undefined && typeof arguments[1] === "function" ? arguments[1] : () => { };
if (_currentTab === "#frontend") {
_calendars.frontend.batchRendering(() => $.each(_calendars.frontend.getEvents(), (i, e) => e.remove()));
......@@ -367,10 +372,14 @@ function fillFrontendCalendar() {
let rooms = [];
let selected_room = -1;
if ((selected_room = parseInt($("#new_reservation_room").val())) !== -1) {
rooms = [ selected_room ];
if (_loggedInUser.admin > 1) {
if ((selected_room = parseInt($("#new_reservation_room").val())) !== -1) {
rooms = [selected_room];
} else {
rooms = _rooms.map((r) => r.id);
}
} else {
rooms = _rooms.map((r) => r.id);
rooms = [1, 2];
}
let asyncs_done = 0;
......@@ -400,7 +409,7 @@ function fillFrontendCalendar() {
$.each(_frontendEvents.unconfirmed, (i, e) => {
_calendars.frontend.addEvent({
title: e.room.shortname.substring(0,3).toUpperCase() + " - #" + e.id,
title: e.room.shortname.substring(0, 3).toUpperCase() + " - #" + e.id,
start: dayjs(e.event.from).$d,
end: dayjs(e.event.to).$d,
color: e.room.calendar_color,
......@@ -463,7 +472,7 @@ function fillFrontendCalendar() {
_frontendEvents.confirmed = _.uniq(_.union(r_tmp, r.content), false, (e) => e.id);
$.each(_frontendEvents.confirmed, (i, e) => {
_calendars.frontend.addEvent({
title: e.room.shortname.substring(0,3).toUpperCase() + " - #" + e.id,
title: e.room.shortname.substring(0, 3).toUpperCase() + " - #" + e.id,
start: dayjs(e.event.from).$d,
end: dayjs(e.event.to).$d,
color: e.room.calendar_color_confirmed,
......
......@@ -150,7 +150,7 @@ function detectRoomSelection() {
$("#frontend_calendar_header_suffix").empty();
}
fillFrontendCalendar();
//fillFrontendCalendar();
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment