Can add events

This commit is contained in:
Pierre HUBERT 2021-04-21 18:02:03 +02:00
parent 1adf0fb872
commit d7779bd653
2 changed files with 20 additions and 0 deletions

View File

@ -37,6 +37,8 @@ class GroupPresencePage {
}
})
let lastClick = null;
const calendarTarget = el.querySelector(".calendar");
const calendar = new FullCalendar.Calendar(calendarTarget, {
headerToolbar: {
@ -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")
}
}
});

View File

@ -7,6 +7,8 @@
</div>
<div class="box-body">
<p>tr("Double-click to add or remove days of presence")</p>
<div class="calendar"></div>
</div>