mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 12:09:21 +00:00
Can delete day
This commit is contained in:
parent
5fec0aa24c
commit
1adf0fb872
@ -56,11 +56,33 @@ class ForezPresenceHelper {
|
|||||||
* @param {number} day
|
* @param {number} day
|
||||||
*/
|
*/
|
||||||
static async DelDay(groupID, year, month, day) {
|
static async DelDay(groupID, year, month, day) {
|
||||||
await ws("forez_presence/add_day", {
|
await ws("forez_presence/del_day", {
|
||||||
group: groupID,
|
group: groupID,
|
||||||
year: year,
|
year: year,
|
||||||
month: month,
|
month: month,
|
||||||
day: day
|
day: day
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async UpdateEvents(groupID, oldStart, oldEnd, newStart, newEnd) {
|
||||||
|
const newDays = new Set(getDaysOfRange(newStart, newEnd).map(el => el.getTime()));
|
||||||
|
const oldDays = new Set(getDaysOfRange(oldStart, oldEnd).map(el => el.getTime()));
|
||||||
|
|
||||||
|
for (const el of newDays) {
|
||||||
|
if(oldDays.has(el)) {
|
||||||
|
newDays.delete(el)
|
||||||
|
oldDays.delete(el)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(const newEl of newDays) {
|
||||||
|
const date = new Date(newEl);
|
||||||
|
await this.AddDay(groupID, date.getFullYear(), date.getMonth() + 1, date.getDate())
|
||||||
|
}
|
||||||
|
|
||||||
|
for(const oldEl of oldDays) {
|
||||||
|
const date = new Date(oldEl);
|
||||||
|
await this.DelDay(groupID, date.getFullYear(), date.getMonth() + 1, date.getDate())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -48,19 +48,13 @@ class GroupPresencePage {
|
|||||||
events: calEvents,
|
events: calEvents,
|
||||||
|
|
||||||
// Update events
|
// Update events
|
||||||
eventResize: function(info) {
|
eventResize: async function(info) {
|
||||||
const newDays = new Set(getDaysOfRange(info.event.start, info.event.end).map(el => el.getTime()));
|
try {
|
||||||
const oldDays = new Set(getDaysOfRange(info.oldEvent.start, info.oldEvent.end).map(el => el.getTime()));
|
await ForezPresenceHelper.UpdateEvents(group.id, info.oldEvent.start, info.oldEvent.end, info.event.start, info.event.end)
|
||||||
|
} catch(e) {
|
||||||
for (const el of newDays) {
|
console.error(e);
|
||||||
if(oldDays.has(el)) {
|
notify(tr("Failed to update presence!"), "danger")
|
||||||
newDays.delete(el)
|
|
||||||
oldDays.delete(el)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info("add", newDays)
|
|
||||||
console.info("del", oldDays)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user