diff --git a/assets/js/pages/groups/pages/presence.js b/assets/js/pages/groups/pages/presence.js index a39e7cb7..d64388a0 100644 --- a/assets/js/pages/groups/pages/presence.js +++ b/assets/js/pages/groups/pages/presence.js @@ -49,8 +49,8 @@ class GroupPresencePage { presences.forEach((e) => e.end = addOneDay(e.date)); - console.log(presences) - + + // Merge contiguous presence days for(let i = 0; i < presences.length; i++) { while(true) { if (presences.length == i + 1) @@ -88,7 +88,7 @@ class GroupPresencePage { } }, - // Update events + // Update events size eventResize: async function(info) { try { await ForezPresenceHelper.UpdateEvents(group.id, info.oldEvent.start, info.oldEvent.end, info.event.start, info.event.end) @@ -97,6 +97,16 @@ class GroupPresencePage { notify(tr("Failed to update presence!"), "danger") } }, + + // Drag event + eventDrop: async function(info) { + try { + await ForezPresenceHelper.UpdateEvents(group.id, info.oldEvent.start, info.oldEvent.end, info.event.start, info.event.end) + } catch(e) { + console.error(e); + notify(tr("Failed to update presence!"), "danger") + } + }, // Add new event dateClick: async function(info) { @@ -114,7 +124,25 @@ class GroupPresencePage { console.error(e); notify(tr("Failed to update presence!"), "danger") } - } + }, + + // Delete event + eventClick: async function(info) { + if (lastClick == null || new Date().getTime() - lastClick.getTime() > 500) + { + lastClick = new Date() + return; + } + + try { + await ForezPresenceHelper.UpdateEvents(group.id, info.event.start, info.event.end, new Date(), new Date(new Date().getTime() - 1)) + + calendar.getEventSources()[0].refetch() + } catch(e) { + console.error(e); + notify(tr("Failed to update presence!"), "danger") + } + }, }); calendar.render() diff --git a/assets/templates/pages/groups/pages/presence.html b/assets/templates/pages/groups/pages/presence.html index 22ae7712..ecf65576 100644 --- a/assets/templates/pages/groups/pages/presence.html +++ b/assets/templates/pages/groups/pages/presence.html @@ -6,11 +6,9 @@
tr("Double-click to add or remove days of presence")
- +tr("Tip: Double-click to add or remove days of presence")