From d7779bd653f364db141c212a2de4457bc1c431c6 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 21 Apr 2021 18:02:03 +0200 Subject: [PATCH] Can add events --- assets/js/pages/groups/pages/presence.js | 18 ++++++++++++++++++ .../templates/pages/groups/pages/presence.html | 2 ++ 2 files changed, 20 insertions(+) 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")

+