diff --git a/assets/js/pages/groups/pages/presence.js b/assets/js/pages/groups/pages/presence.js index 97be100b..98835698 100644 --- a/assets/js/pages/groups/pages/presence.js +++ b/assets/js/pages/groups/pages/presence.js @@ -36,6 +36,8 @@ class GroupPresencePage { description: users.get(e.userID).fullName } }) + + let lastClick = null; const calendarTarget = el.querySelector(".calendar"); const calendar = new FullCalendar.Calendar(calendarTarget, { @@ -55,6 +57,22 @@ class GroupPresencePage { console.error(e); notify(tr("Failed to update presence!"), "danger") } + }, + + // Add new event + dateClick: async function(info) { + if (lastClick == null || new Date().getTime() - lastClick.getTime() > 500) + { + lastClick = new Date() + return; + } + + try { + await ForezPresenceHelper.AddDay(group.id, info.date.getFullYear(), info.date.getMonth() + 1, info.date.getDate()) + } catch(e) { + console.error(e); + notify(tr("Failed to update presence!"), "danger") + } } }); diff --git a/assets/templates/pages/groups/pages/presence.html b/assets/templates/pages/groups/pages/presence.html index 5bcf8a11..22ae7712 100644 --- a/assets/templates/pages/groups/pages/presence.html +++ b/assets/templates/pages/groups/pages/presence.html @@ -7,6 +7,8 @@
tr("Double-click to add or remove days of presence")
+