mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 04:09:20 +00:00
Process dates
This commit is contained in:
parent
dac00ccf3a
commit
5fec0aa24c
@ -101,4 +101,22 @@ const ComunicDate = {
|
||||
},
|
||||
}
|
||||
|
||||
ComunicWeb.common.date = ComunicDate;
|
||||
ComunicWeb.common.date = ComunicDate;
|
||||
|
||||
/**
|
||||
* Get all the days of a specified range
|
||||
*
|
||||
* @param {Date} start
|
||||
* @param {Date} end (exclusive)
|
||||
*/
|
||||
function getDaysOfRange(start, end) {
|
||||
let curr = start;
|
||||
let list = [];
|
||||
|
||||
while (curr < end) {
|
||||
list.push(curr);
|
||||
curr = new Date(curr.getTime() + 1000*60*60*24);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
@ -29,4 +29,38 @@ class ForezPresenceHelper {
|
||||
return new Presence(...infos)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a day of presence
|
||||
*
|
||||
* @param {number} groupID
|
||||
* @param {number} year
|
||||
* @param {number} month
|
||||
* @param {number} day
|
||||
*/
|
||||
static async AddDay(groupID, year, month, day) {
|
||||
await ws("forez_presence/add_day", {
|
||||
group: groupID,
|
||||
year: year,
|
||||
month: month,
|
||||
day: day
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a day of presence
|
||||
*
|
||||
* @param {number} groupID
|
||||
* @param {number} year
|
||||
* @param {number} month
|
||||
* @param {number} day
|
||||
*/
|
||||
static async DelDay(groupID, year, month, day) {
|
||||
await ws("forez_presence/add_day", {
|
||||
group: groupID,
|
||||
year: year,
|
||||
month: month,
|
||||
day: day
|
||||
})
|
||||
}
|
||||
}
|
@ -24,19 +24,6 @@ class GroupPresencePage {
|
||||
target.appendChild(el);
|
||||
|
||||
|
||||
Vue.createApp({
|
||||
|
||||
data: () => {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
}
|
||||
|
||||
}).mount(el);
|
||||
|
||||
|
||||
const calEvents = presence.map((e) => {
|
||||
return {
|
||||
@ -44,7 +31,7 @@ class GroupPresencePage {
|
||||
start: new Date(e.year, e.month - 1, e.day),
|
||||
backgroundColor: "#0073b7", //Blue
|
||||
borderColor: "#0073b7", //Blue
|
||||
editable: false,
|
||||
editable: e.userID == userID(),
|
||||
allDay: true,
|
||||
description: users.get(e.userID).fullName
|
||||
}
|
||||
@ -59,6 +46,22 @@ class GroupPresencePage {
|
||||
},
|
||||
initialView: 'dayGridMonth',
|
||||
events: calEvents,
|
||||
|
||||
// Update events
|
||||
eventResize: function(info) {
|
||||
const newDays = new Set(getDaysOfRange(info.event.start, info.event.end).map(el => el.getTime()));
|
||||
const oldDays = new Set(getDaysOfRange(info.oldEvent.start, info.oldEvent.end).map(el => el.getTime()));
|
||||
|
||||
for (const el of newDays) {
|
||||
if(oldDays.has(el)) {
|
||||
newDays.delete(el)
|
||||
oldDays.delete(el)
|
||||
}
|
||||
}
|
||||
|
||||
console.info("add", newDays)
|
||||
console.info("del", oldDays)
|
||||
}
|
||||
});
|
||||
|
||||
calendar.render()
|
||||
|
Loading…
Reference in New Issue
Block a user