ct-gantt-core 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +29 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -8
- package/dist/index.d.ts +16 -8
- package/dist/index.js +28 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
addHours: () => addHours,
|
|
36
36
|
addPlannedDuration: () => addPlannedDuration,
|
|
37
37
|
alignPlannedDate: () => alignPlannedDate,
|
|
38
|
+
calendarIncludesWeekends: () => calendarIncludesWeekends,
|
|
38
39
|
checkCyclicDependency: () => checkCyclicDependency,
|
|
39
40
|
computeHourScale: () => computeHourScale,
|
|
40
41
|
computeImpact: () => computeImpact,
|
|
@@ -110,8 +111,13 @@ var DEFAULT_WORKLOAD_COLORS = {
|
|
|
110
111
|
var RESOURCE_COLOR_PALETTE = [DEFAULT_RESOURCE_COLORS.booking];
|
|
111
112
|
var RESOURCE_EDITOR_COLOR_OPTIONS = [
|
|
112
113
|
"#409eff",
|
|
113
|
-
"#
|
|
114
|
-
"#
|
|
114
|
+
"#66b1ff",
|
|
115
|
+
"#67c23a",
|
|
116
|
+
"#e6a23c",
|
|
117
|
+
"#f56c6c",
|
|
118
|
+
"#909399",
|
|
119
|
+
"#9b87c4",
|
|
120
|
+
"#36cfc9"
|
|
115
121
|
];
|
|
116
122
|
var EDITOR_COLOR_OPTIONS = [
|
|
117
123
|
"#409eff",
|
|
@@ -391,11 +397,14 @@ function alignPlannedDate(date, calendarId = "standard", direction = 1) {
|
|
|
391
397
|
}
|
|
392
398
|
return current;
|
|
393
399
|
}
|
|
400
|
+
function calendarIncludesWeekends(calendarId) {
|
|
401
|
+
return calendarId === "delivery";
|
|
402
|
+
}
|
|
394
403
|
function plannedDurationBetween(start, end, calendarId = "standard") {
|
|
395
404
|
const first = toDate(start);
|
|
396
405
|
const last = toDate(end);
|
|
397
406
|
if (last.getTime() < first.getTime()) return 0;
|
|
398
|
-
if (calendarId
|
|
407
|
+
if (calendarIncludesWeekends(calendarId)) return inclusiveDays(first, last);
|
|
399
408
|
let duration = 0;
|
|
400
409
|
for (let current = first; current <= last; current = addDays(current, 1)) {
|
|
401
410
|
const day = current.getDay();
|
|
@@ -982,14 +991,19 @@ function isLaneFree(laneEnd, start, hourMode) {
|
|
|
982
991
|
}
|
|
983
992
|
|
|
984
993
|
// src/engines/computeWorkload.ts
|
|
985
|
-
function computeWorkload(tasks, people, departments = [], range, groupBy, defaultCapacityPerDay, includeIdle = false, includeWeekends) {
|
|
994
|
+
function computeWorkload(tasks, people, departments = [], range, groupBy, defaultCapacityPerDay, includeIdle = false, includeWeekends, dateSource = "plan") {
|
|
986
995
|
const dated = range ?? inferRange(tasks);
|
|
987
996
|
if (!dated) return { dates: [], departments: [], ungrouped: [] };
|
|
988
997
|
const dates = datesBetween(dated.start, dated.end);
|
|
989
998
|
const dateIndex = new Map(dates.map((date, index) => [date, index]));
|
|
999
|
+
const parentIds = /* @__PURE__ */ new Set();
|
|
1000
|
+
for (const task of tasks) {
|
|
1001
|
+
if (task.parentId) parentIds.add(task.parentId);
|
|
1002
|
+
}
|
|
1003
|
+
const isCountable = (task) => task.type === "task" || task.type === "summary" && !parentIds.has(task.id);
|
|
990
1004
|
const activeIds = /* @__PURE__ */ new Set();
|
|
991
1005
|
for (const task of tasks) {
|
|
992
|
-
if (task
|
|
1006
|
+
if (!isCountable(task)) continue;
|
|
993
1007
|
for (const id of task.resources ?? []) activeIds.add(id);
|
|
994
1008
|
}
|
|
995
1009
|
const candidates = mergePeopleWithTaskResources(people, tasks);
|
|
@@ -997,7 +1011,7 @@ function computeWorkload(tasks, people, departments = [], range, groupBy, defaul
|
|
|
997
1011
|
const rows = new Map(members.map((person) => [person.id, createPerson(person, dates, defaultCapacityPerDay)]));
|
|
998
1012
|
const tasksByPerson = /* @__PURE__ */ new Map();
|
|
999
1013
|
for (const task of tasks) {
|
|
1000
|
-
if (task
|
|
1014
|
+
if (!isCountable(task)) continue;
|
|
1001
1015
|
for (const id of task.resources ?? []) {
|
|
1002
1016
|
const list = tasksByPerson.get(id);
|
|
1003
1017
|
if (list) list.push(task);
|
|
@@ -1005,10 +1019,10 @@ function computeWorkload(tasks, people, departments = [], range, groupBy, defaul
|
|
|
1005
1019
|
}
|
|
1006
1020
|
}
|
|
1007
1021
|
for (const task of tasks) {
|
|
1008
|
-
if (task
|
|
1022
|
+
if (!isCountable(task)) continue;
|
|
1009
1023
|
const ids = task.resources ?? [];
|
|
1010
1024
|
if (!ids.length) continue;
|
|
1011
|
-
const values = task.dailyWorkloads ?? averageTaskWorkload(task, includeWeekends);
|
|
1025
|
+
const values = task.dailyWorkloads ?? averageTaskWorkload(task, includeWeekends, dateSource);
|
|
1012
1026
|
for (const personId of ids) {
|
|
1013
1027
|
const row = rows.get(personId);
|
|
1014
1028
|
if (!row) continue;
|
|
@@ -1069,15 +1083,17 @@ function datesBetween(start, end) {
|
|
|
1069
1083
|
for (let date = toDate(start); date <= toDate(end); date = addDays(date, 1)) values.push(formatDate(date));
|
|
1070
1084
|
return values;
|
|
1071
1085
|
}
|
|
1072
|
-
function averageTaskWorkload(task, includeWeekends) {
|
|
1073
|
-
const
|
|
1074
|
-
const
|
|
1086
|
+
function averageTaskWorkload(task, includeWeekends, dateSource = "plan") {
|
|
1087
|
+
const sourceStart = dateSource === "actual" ? task.actual.start : task.plan.start;
|
|
1088
|
+
const sourceEnd = dateSource === "actual" ? task.actual.end : task.plan.end;
|
|
1089
|
+
const allDates = datesBetween(sourceStart, sourceEnd);
|
|
1075
1090
|
const workdays = allDates.filter((date) => {
|
|
1076
1091
|
const day = toDate(date).getDay();
|
|
1077
1092
|
return day !== 0 && day !== 6;
|
|
1078
1093
|
});
|
|
1079
|
-
const withWeekends = includeWeekends ?? task.calendarId
|
|
1094
|
+
const withWeekends = task.includeWeekends ?? includeWeekends ?? calendarIncludesWeekends(task.calendarId);
|
|
1080
1095
|
const dates = withWeekends ? allDates : workdays;
|
|
1096
|
+
const total = task.workload ?? dates.length * 8;
|
|
1081
1097
|
const hours = dates.length ? total / dates.length : 0;
|
|
1082
1098
|
return Object.fromEntries(dates.map((date) => [date, hours]));
|
|
1083
1099
|
}
|
|
@@ -1532,6 +1548,7 @@ function createGanttEngine(options = {}) {
|
|
|
1532
1548
|
addHours,
|
|
1533
1549
|
addPlannedDuration,
|
|
1534
1550
|
alignPlannedDate,
|
|
1551
|
+
calendarIncludesWeekends,
|
|
1535
1552
|
checkCyclicDependency,
|
|
1536
1553
|
computeHourScale,
|
|
1537
1554
|
computeImpact,
|