@event-calendar/resource-timeline
Advanced tools
Comparing version 3.6.1 to 3.6.2
{ | ||
"name": "@event-calendar/resource-timeline", | ||
"version": "3.6.1", | ||
"version": "3.6.2", | ||
"title": "Event Calendar ResourceTimeline plugin", | ||
@@ -30,5 +30,5 @@ "description": "Full-sized drag & drop event calendar with resource & timeline views", | ||
"dependencies": { | ||
"@event-calendar/core": "~3.6.1", | ||
"@event-calendar/core": "~3.6.2", | ||
"svelte": "^4.2.19" | ||
} | ||
} |
115
src/lib.js
@@ -1,3 +0,114 @@ | ||
import {createDuration} from '@event-calendar/core'; | ||
import { | ||
addDay, addDuration, | ||
cloneDate, | ||
createDuration, | ||
datesEqual, | ||
sortEventChunks, | ||
toSeconds | ||
} from '@event-calendar/core'; | ||
export function prepareEventChunks(chunks, $_viewDates, $_dayTimeLimits, $slotDuration) { | ||
let longChunks = {}; | ||
if (chunks.length) { | ||
sortEventChunks(chunks); | ||
let step = toSeconds($slotDuration); | ||
let prevChunk; | ||
for (let chunk of chunks) { | ||
let prevDayEnd; | ||
if (step) { | ||
let slots = 0; | ||
for (let i = 0; i < $_viewDates.length; ++i) { | ||
let slotTimeLimits = getSlotTimeLimits($_dayTimeLimits, $_viewDates[i]); | ||
let dayStart = addDuration(cloneDate($_viewDates[i]), slotTimeLimits.min); | ||
let dayEnd = addDuration(cloneDate($_viewDates[i]), slotTimeLimits.max); | ||
if (!chunk.date) { | ||
if (chunk.start < dayEnd) { | ||
// The first day is found | ||
chunk.date = $_viewDates[i]; | ||
if (chunk.start < dayStart) { | ||
// Adjust chunk start | ||
chunk.start = dayStart; | ||
} | ||
// Calculate offset | ||
chunk.offset = (chunk.start - dayStart) / 1000 / step; | ||
// Calculate slots | ||
if (chunk.end > dayEnd) { | ||
slots += dayEnd - chunk.start; | ||
} else { | ||
slots += chunk.end - chunk.start; | ||
break; | ||
} | ||
} | ||
} else { | ||
if (chunk.end <= dayStart) { | ||
// Adjust chunk end | ||
chunk.end = prevDayEnd; | ||
break; | ||
} | ||
// The chunk is long one | ||
let key = $_viewDates[i].getTime(); | ||
if (longChunks[key]) { | ||
longChunks[key].push(chunk); | ||
} else { | ||
longChunks[key] = [chunk]; | ||
} | ||
// Calculate slots | ||
if (chunk.end > dayEnd) { | ||
slots += dayEnd - dayStart; | ||
} else { | ||
slots += chunk.end - dayStart; | ||
break; | ||
} | ||
} | ||
prevDayEnd = dayEnd; | ||
} | ||
chunk.slots = slots / 1000 / step; | ||
} else { | ||
// Month view | ||
let days = 0; | ||
for (let i = 0; i < $_viewDates.length; ++i) { | ||
let dayStart = $_viewDates[i]; | ||
let dayEnd = addDay(cloneDate(dayStart)); | ||
if (!chunk.date) { | ||
if (chunk.start < dayEnd) { | ||
// The first day is found | ||
chunk.date = dayStart; | ||
if (chunk.start < dayStart) { | ||
// Adjust chunk start | ||
chunk.start = dayStart; | ||
} | ||
++days; | ||
} | ||
} else { | ||
if (chunk.end <= dayStart) { | ||
// Adjust chunk end | ||
chunk.end = prevDayEnd; | ||
break; | ||
} | ||
// The chunk is long one | ||
let key = dayStart.getTime(); | ||
if (longChunks[key]) { | ||
longChunks[key].push(chunk); | ||
} else { | ||
longChunks[key] = [chunk]; | ||
} | ||
++days; | ||
} | ||
prevDayEnd = dayEnd; | ||
} | ||
chunk.days = days; | ||
} | ||
if (prevChunk && datesEqual(prevChunk.date, chunk.date)) { | ||
chunk.prev = prevChunk; | ||
} | ||
prevChunk = chunk; | ||
} | ||
} | ||
return longChunks; | ||
} | ||
export function repositionEvent(chunk, dayChunks, longChunks, height, allDay) { | ||
@@ -8,3 +119,3 @@ chunk.top = 0; | ||
let key = chunk.date.getTime(); | ||
longChunks = longChunks?.[key]?.chunks ?? []; | ||
longChunks = longChunks?.[key] ?? []; | ||
let chunks = [...dayChunks, ...longChunks]; | ||
@@ -11,0 +122,0 @@ chunks.sort((a, b) => (a.top ?? 0) - (b.top ?? 0) || a.start - b.start || b.event.allDay - a.event.allDay); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174488
2765
Updated@event-calendar/core@~3.6.2