mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Start to merge entries
This commit is contained in:
		@@ -103,6 +103,15 @@ const ComunicDate = {
 | 
			
		||||
 | 
			
		||||
ComunicWeb.common.date = ComunicDate;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Add a day to a date
 | 
			
		||||
 * 
 | 
			
		||||
 * @param {Date} date Target date
 | 
			
		||||
 */
 | 
			
		||||
function addOneDay(date) {
 | 
			
		||||
	return new Date(date.getTime() + 1000*60*60*24);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get all the days of a specified range
 | 
			
		||||
 * 
 | 
			
		||||
@@ -115,7 +124,7 @@ function getDaysOfRange(start, end) {
 | 
			
		||||
 | 
			
		||||
	while (curr < end) {
 | 
			
		||||
		list.push(curr);
 | 
			
		||||
		curr = new Date(curr.getTime() + 1000*60*60*24);
 | 
			
		||||
		curr = addOneDay(curr);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return list;
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,10 @@ class Presence {
 | 
			
		||||
        this.month = month;
 | 
			
		||||
        this.day = day;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    get date() {
 | 
			
		||||
         return new Date(this.year, this.month - 1, this.day);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -34,19 +34,53 @@ class GroupPresencePage {
 | 
			
		||||
            // Data source
 | 
			
		||||
            events: async function(info, success, failure) {
 | 
			
		||||
                try {
 | 
			
		||||
                    const presence = await ForezPresenceHelper.GetList(group.id);
 | 
			
		||||
                    const users = await getUsers([...new Set(presence.map(e => e.userID))]);
 | 
			
		||||
                    success(presence.map((e) => {
 | 
			
		||||
                    let presences = await ForezPresenceHelper.GetList(group.id);
 | 
			
		||||
                    const users = await getUsers([...new Set(presences.map(e => e.userID))]);
 | 
			
		||||
                    
 | 
			
		||||
                    presences.sort((one, two) => {
 | 
			
		||||
                        if (one.userID < two.userID)
 | 
			
		||||
                            return -1;
 | 
			
		||||
                        
 | 
			
		||||
                        if (one.userID > two.userID)
 | 
			
		||||
                            return 1;
 | 
			
		||||
                        
 | 
			
		||||
                        return one.date - two.date;
 | 
			
		||||
                    })
 | 
			
		||||
 | 
			
		||||
                    presences.forEach((e) => e.end = addOneDay(e.date));
 | 
			
		||||
 | 
			
		||||
                    console.log(presences)
 | 
			
		||||
 | 
			
		||||
                    for(let i = 0; i < presences.length; i++) {
 | 
			
		||||
                        while(true) {
 | 
			
		||||
                            if (presences.length == i + 1)
 | 
			
		||||
                                break;
 | 
			
		||||
                            
 | 
			
		||||
                            let curr = presences[i];
 | 
			
		||||
                            let next = presences[i + 1];
 | 
			
		||||
 | 
			
		||||
                            if(curr.userID != next.userID || curr.year != next.year || curr.month != next.month || curr.day != next.day - 1)
 | 
			
		||||
                                break;
 | 
			
		||||
                            
 | 
			
		||||
                            curr.end = next.end;
 | 
			
		||||
                            presences.splice(i + 1, 1)
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    const events = presences.map((e) => {
 | 
			
		||||
                        return {
 | 
			
		||||
                            title: users.get(e.userID).fullName,
 | 
			
		||||
                            start: new Date(e.year, e.month - 1, e.day),
 | 
			
		||||
                            start: e.date,
 | 
			
		||||
                            end: e.end,
 | 
			
		||||
                            backgroundColor: "#0073b7", //Blue
 | 
			
		||||
                            borderColor: "#0073b7", //Blue
 | 
			
		||||
                            editable: e.userID == userID(),
 | 
			
		||||
                            allDay: true,
 | 
			
		||||
                            description: users.get(e.userID).fullName
 | 
			
		||||
                        }
 | 
			
		||||
                    }));
 | 
			
		||||
                    });
 | 
			
		||||
                    
 | 
			
		||||
                    success(events);
 | 
			
		||||
                    
 | 
			
		||||
                } catch(e) {
 | 
			
		||||
                    console.error(e);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user