feat(platform): checkpoint current implementation state
This commit is contained in:
@@ -21,6 +21,34 @@ export interface VacationBlockInfo {
|
||||
width: number;
|
||||
}
|
||||
|
||||
export function buildVacationBlocksByResource(
|
||||
vacationsByResource: Map<string, VacationEntry[]>,
|
||||
showVacations: boolean,
|
||||
toLeft: (date: Date) => number,
|
||||
toWidth: (start: Date, end: Date) => number,
|
||||
cellWidth: number,
|
||||
totalCanvasWidth: number,
|
||||
) {
|
||||
if (!showVacations) return new Map<string, VacationBlockInfo[]>();
|
||||
|
||||
const result = new Map<string, VacationBlockInfo[]>();
|
||||
for (const [resourceId, vacations] of vacationsByResource) {
|
||||
const blocks: VacationBlockInfo[] = [];
|
||||
for (const vacation of vacations) {
|
||||
const start = new Date(vacation.startDate);
|
||||
const end = new Date(vacation.endDate);
|
||||
const left = toLeft(start);
|
||||
const width = Math.max(cellWidth, toWidth(start, end));
|
||||
if (width <= 0 || left >= totalCanvasWidth) continue;
|
||||
blocks.push({ vacation, left, width });
|
||||
}
|
||||
if (blocks.length > 0) {
|
||||
result.set(resourceId, blocks);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ─── Vacation block overlays ─────────────────────────────────────────────────
|
||||
|
||||
export function renderVacationBlocks(blocks: VacationBlockInfo[], rowHeight: number) {
|
||||
@@ -92,8 +120,9 @@ export function renderOverbookingBlink(
|
||||
allocs: TimelineAssignmentEntry[],
|
||||
dates: Date[],
|
||||
CELL_WIDTH: number,
|
||||
capacityHoursByDay?: number[],
|
||||
bookingFactorsByDay?: number[],
|
||||
) {
|
||||
const REF_H = 8;
|
||||
const overbooked: number[] = [];
|
||||
|
||||
for (let i = 0; i < dates.length; i++) {
|
||||
@@ -106,9 +135,11 @@ export function renderOverbookingBlink(
|
||||
s.setHours(0, 0, 0, 0);
|
||||
const e = new Date(a.endDate);
|
||||
e.setHours(0, 0, 0, 0);
|
||||
if (t >= s.getTime() && t <= e.getTime()) totalH += a.hoursPerDay;
|
||||
if (t >= s.getTime() && t <= e.getTime()) {
|
||||
totalH += a.hoursPerDay * (bookingFactorsByDay?.[i] ?? 1);
|
||||
}
|
||||
}
|
||||
if (totalH > REF_H) overbooked.push(i);
|
||||
if (totalH > (capacityHoursByDay?.[i] ?? 8)) overbooked.push(i);
|
||||
}
|
||||
|
||||
if (overbooked.length === 0) return null;
|
||||
|
||||
Reference in New Issue
Block a user