Can remove events

This commit is contained in:
Pierre HUBERT 2021-04-21 18:38:28 +02:00
parent f5557d81e0
commit 983f26fee5
2 changed files with 33 additions and 7 deletions

View File

@ -49,8 +49,8 @@ class GroupPresencePage {
presences.forEach((e) => e.end = addOneDay(e.date)); presences.forEach((e) => e.end = addOneDay(e.date));
console.log(presences)
// Merge contiguous presence days
for(let i = 0; i < presences.length; i++) { for(let i = 0; i < presences.length; i++) {
while(true) { while(true) {
if (presences.length == i + 1) if (presences.length == i + 1)
@ -88,7 +88,7 @@ class GroupPresencePage {
} }
}, },
// Update events // Update events size
eventResize: async function(info) { eventResize: async function(info) {
try { try {
await ForezPresenceHelper.UpdateEvents(group.id, info.oldEvent.start, info.oldEvent.end, info.event.start, info.event.end) await ForezPresenceHelper.UpdateEvents(group.id, info.oldEvent.start, info.oldEvent.end, info.event.start, info.event.end)
@ -98,6 +98,16 @@ class GroupPresencePage {
} }
}, },
// 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 // Add new event
dateClick: async function(info) { dateClick: async function(info) {
if (lastClick == null || new Date().getTime() - lastClick.getTime() > 500) if (lastClick == null || new Date().getTime() - lastClick.getTime() > 500)
@ -114,7 +124,25 @@ class GroupPresencePage {
console.error(e); console.error(e);
notify(tr("Failed to update presence!"), "danger") 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() calendar.render()

View File

@ -6,11 +6,9 @@
<h3 class="box-title">tr("Presence in Forez")</h3> <h3 class="box-title">tr("Presence in Forez")</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<p>tr("Double-click to add or remove days of presence")</p>
<div class="calendar"></div> <div class="calendar"></div>
<p>tr("Tip: Double-click to add or remove days of presence")</p>
</div> </div>
</div> </div>
</div> </div>