Steps in the right direction for animated date change
This commit is contained in:
parent
5e966ddea2
commit
f50f5ad53b
7 changed files with 378 additions and 37 deletions
|
|
@ -113,6 +113,44 @@ export class DataManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter events to only include those within the specified period
|
||||
*/
|
||||
public filterEventsForPeriod(events: CalendarEvent[], period: Period): CalendarEvent[] {
|
||||
const startDate = new Date(period.start);
|
||||
const endDate = new Date(period.end);
|
||||
|
||||
return events.filter(event => {
|
||||
const eventStart = new Date(event.start);
|
||||
const eventEnd = new Date(event.end);
|
||||
|
||||
// Include event if it overlaps with the period
|
||||
return eventStart <= endDate && eventEnd >= startDate;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events filtered by period and optionally by all-day status
|
||||
*/
|
||||
public getFilteredEvents(period: Period, excludeAllDay: boolean = false): CalendarEvent[] {
|
||||
const cacheKey = `${period.start}-${period.end}`;
|
||||
const cachedData = this.cache.get(cacheKey);
|
||||
|
||||
if (!cachedData) {
|
||||
console.warn('DataManager: No cached data found for period', period);
|
||||
return [];
|
||||
}
|
||||
|
||||
let filteredEvents = this.filterEventsForPeriod(cachedData.events, period);
|
||||
|
||||
if (excludeAllDay) {
|
||||
filteredEvents = filteredEvents.filter(event => !event.allDay);
|
||||
console.log(`DataManager: Filtered out all-day events, ${filteredEvents.length} non-all-day events remaining`);
|
||||
}
|
||||
|
||||
return filteredEvents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new event
|
||||
*/
|
||||
|
|
@ -270,7 +308,7 @@ export class DataManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generate mock data for testing
|
||||
* Generate mock data for testing - only generates events within the specified period
|
||||
*/
|
||||
private getMockData(period: Period): EventData {
|
||||
const events: CalendarEvent[] = [];
|
||||
|
|
@ -282,11 +320,13 @@ export class DataManager {
|
|||
milestone: ['Project Deadline', 'Release Day', 'Demo Day']
|
||||
};
|
||||
|
||||
// Parse dates
|
||||
// Parse dates - only generate events within this exact period
|
||||
const startDate = new Date(period.start);
|
||||
const endDate = new Date(period.end);
|
||||
|
||||
// Generate some events for each day
|
||||
console.log(`DataManager: Generating mock events for period ${period.start} to ${period.end}`);
|
||||
|
||||
// Generate some events for each day within the period
|
||||
for (let d = new Date(startDate); d <= endDate; d.setDate(d.getDate() + 1)) {
|
||||
// Skip weekends for most events
|
||||
const dayOfWeek = d.getDay();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue