gantt-task-react-powern 0.6.20 → 0.6.22
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/components/calendar/calendar.d.ts +2 -1
- package/dist/components/gantt/task-gantt-content.d.ts +2 -1
- package/dist/components/grid/grid-body.d.ts +3 -1
- package/dist/components/task-item/bar/bar-display.d.ts +4 -0
- package/dist/helpers/bar-helper.d.ts +1 -0
- package/dist/helpers/calendar-helper.d.ts +49 -0
- package/dist/helpers/date-helper.d.ts +1 -1
- package/dist/index.css +21 -0
- package/dist/index.js +679 -201
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +679 -201
- package/dist/index.modern.js.map +1 -1
- package/dist/types/bar-task.d.ts +8 -0
- package/dist/types/public-types.d.ts +13 -0
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -105,9 +105,23 @@ var startOfDate = function startOfDate(date, scale) {
|
|
|
105
105
|
var newDate = new Date(date.getFullYear(), shouldReset("year") ? 0 : date.getMonth(), shouldReset("month") ? 1 : date.getDate(), shouldReset("day") ? 0 : date.getHours(), shouldReset("hour") ? 0 : date.getMinutes(), shouldReset("minute") ? 0 : date.getSeconds(), shouldReset("second") ? 0 : date.getMilliseconds());
|
|
106
106
|
return newDate;
|
|
107
107
|
};
|
|
108
|
-
|
|
108
|
+
|
|
109
|
+
var getFiscalQuarterStartDate = function getFiscalQuarterStartDate(date, quarterStart) {
|
|
110
|
+
var month = date.getMonth();
|
|
111
|
+
var offset = (month - quarterStart + 12) % 12;
|
|
112
|
+
var qStartMonth = (quarterStart + Math.floor(offset / 3) * 3) % 12;
|
|
113
|
+
var year = date.getFullYear();
|
|
114
|
+
if (qStartMonth > month) year -= 1;
|
|
115
|
+
return new Date(year, qStartMonth, 1);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount, quarterStart) {
|
|
109
119
|
var _tasks$, _tasks$2, _tasks$3, _tasks$4;
|
|
110
120
|
|
|
121
|
+
if (quarterStart === void 0) {
|
|
122
|
+
quarterStart = 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
111
125
|
var newStartDate = ((_tasks$ = tasks[0]) === null || _tasks$ === void 0 ? void 0 : _tasks$.start.getTime()) !== 0 ? ((_tasks$2 = tasks[0]) === null || _tasks$2 === void 0 ? void 0 : _tasks$2.start) || new Date() : new Date();
|
|
112
126
|
var newEndDate = ((_tasks$3 = tasks[0]) === null || _tasks$3 === void 0 ? void 0 : _tasks$3.end.getTime()) !== 0 ? ((_tasks$4 = tasks[0]) === null || _tasks$4 === void 0 ? void 0 : _tasks$4.end) || new Date() : new Date();
|
|
113
127
|
|
|
@@ -140,11 +154,14 @@ var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount) {
|
|
|
140
154
|
break;
|
|
141
155
|
|
|
142
156
|
case ViewMode.Quarter:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
{
|
|
158
|
+
newStartDate = addToDate(newStartDate, -1 * preStepsCount, "year");
|
|
159
|
+
newStartDate = getFiscalQuarterStartDate(newStartDate, quarterStart);
|
|
160
|
+
newEndDate = addToDate(newEndDate, 1, "year");
|
|
161
|
+
var endQStart = getFiscalQuarterStartDate(newEndDate, quarterStart);
|
|
162
|
+
newEndDate = endQStart < newEndDate ? addToDate(endQStart, 3, "month") : endQStart;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
148
165
|
|
|
149
166
|
case ViewMode.Month:
|
|
150
167
|
newStartDate = addToDate(newStartDate, -1 * preStepsCount, "month");
|
|
@@ -235,13 +252,6 @@ var seedDates = function seedDates(startDate, endDate, viewMode) {
|
|
|
235
252
|
|
|
236
253
|
return dates;
|
|
237
254
|
};
|
|
238
|
-
var getLocaleMonth = function getLocaleMonth(date, locale) {
|
|
239
|
-
var bottomValue = getCachedDateTimeFormat(locale, {
|
|
240
|
-
month: "long"
|
|
241
|
-
}).format(date);
|
|
242
|
-
bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
|
|
243
|
-
return bottomValue;
|
|
244
|
-
};
|
|
245
255
|
var getLocalDayOfWeek = function getLocalDayOfWeek(date, locale, format) {
|
|
246
256
|
var bottomValue = getCachedDateTimeFormat(locale, {
|
|
247
257
|
weekday: format
|
|
@@ -256,26 +266,6 @@ var getMonday = function getMonday(date) {
|
|
|
256
266
|
return new Date(date.setDate(diff));
|
|
257
267
|
};
|
|
258
268
|
|
|
259
|
-
var getWeekNumberISO8601 = function getWeekNumberISO8601(date) {
|
|
260
|
-
var tmpDate = new Date(date.valueOf());
|
|
261
|
-
var dayNumber = (tmpDate.getDay() + 6) % 7;
|
|
262
|
-
tmpDate.setDate(tmpDate.getDate() - dayNumber + 3);
|
|
263
|
-
var firstThursday = tmpDate.valueOf();
|
|
264
|
-
tmpDate.setMonth(0, 1);
|
|
265
|
-
|
|
266
|
-
if (tmpDate.getDay() !== 4) {
|
|
267
|
-
tmpDate.setMonth(0, 1 + (4 - tmpDate.getDay() + 7) % 7);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
var weekNumber = (1 + Math.ceil((firstThursday - tmpDate.valueOf()) / 604800000)).toString();
|
|
271
|
-
|
|
272
|
-
if (weekNumber.length === 1) {
|
|
273
|
-
return "0" + weekNumber;
|
|
274
|
-
} else {
|
|
275
|
-
return weekNumber;
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
|
|
279
269
|
var styles = {"ganttTable":"_3_ygE","ganttTable_Header":"_1nBOt","ganttTable_HeaderSeparator":"_2eZzQ","ganttTable_HeaderItem":"_WuQ0f"};
|
|
280
270
|
|
|
281
271
|
var TaskListHeaderDefault = function TaskListHeaderDefault(_ref) {
|
|
@@ -1099,9 +1089,133 @@ var TaskList = function TaskList(_ref) {
|
|
|
1099
1089
|
}, React.createElement(TaskListTable, Object.assign({}, tableProps))))));
|
|
1100
1090
|
};
|
|
1101
1091
|
|
|
1102
|
-
|
|
1092
|
+
function parseTimeToMinutes(t) {
|
|
1093
|
+
var parts = t.split(":").map(Number);
|
|
1094
|
+
return parts[0] * 60 + parts[1] + (parts[2] ? parts[2] / 60 : 0);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
function toDateString(date) {
|
|
1098
|
+
var y = date.getFullYear();
|
|
1099
|
+
var m = String(date.getMonth() + 1).padStart(2, "0");
|
|
1100
|
+
var d = String(date.getDate()).padStart(2, "0");
|
|
1101
|
+
return y + "-" + m + "-" + d;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
function isHoliday(date, cal) {
|
|
1105
|
+
return cal.holidays.includes(toDateString(date));
|
|
1106
|
+
}
|
|
1107
|
+
function isOffDay(date, cal) {
|
|
1108
|
+
return cal.off_days.includes(date.getDay()) || isHoliday(date, cal);
|
|
1109
|
+
}
|
|
1110
|
+
function getShiftsForDay(date, cal) {
|
|
1111
|
+
if (isOffDay(date, cal)) return [];
|
|
1112
|
+
return cal.shifts.map(function (_ref) {
|
|
1113
|
+
var s = _ref[0],
|
|
1114
|
+
e = _ref[1];
|
|
1115
|
+
return {
|
|
1116
|
+
start: parseTimeToMinutes(s),
|
|
1117
|
+
end: parseTimeToMinutes(e)
|
|
1118
|
+
};
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
function getWorkingIntervals(start, end, cal) {
|
|
1122
|
+
if (start >= end) return [];
|
|
1123
|
+
var intervals = [];
|
|
1124
|
+
var cursor = new Date(start);
|
|
1125
|
+
cursor.setHours(0, 0, 0, 0);
|
|
1126
|
+
|
|
1127
|
+
while (cursor <= end) {
|
|
1128
|
+
var shifts = getShiftsForDay(cursor, cal);
|
|
1129
|
+
|
|
1130
|
+
for (var _iterator = _createForOfIteratorHelperLoose(shifts), _step; !(_step = _iterator()).done;) {
|
|
1131
|
+
var shift = _step.value;
|
|
1132
|
+
var shiftStart = new Date(cursor);
|
|
1133
|
+
shiftStart.setHours(Math.floor(shift.start / 60), Math.floor(shift.start % 60), Math.round(shift.start % 1 * 60), 0);
|
|
1134
|
+
var shiftEnd = new Date(cursor);
|
|
1135
|
+
shiftEnd.setHours(Math.floor(shift.end / 60), Math.floor(shift.end % 60), Math.round(shift.end % 1 * 60), 0);
|
|
1136
|
+
var intervalStart = shiftStart < start ? start : shiftStart;
|
|
1137
|
+
var intervalEnd = shiftEnd > end ? end : shiftEnd;
|
|
1138
|
+
|
|
1139
|
+
if (intervalStart < intervalEnd) {
|
|
1140
|
+
intervals.push({
|
|
1141
|
+
start: intervalStart,
|
|
1142
|
+
end: intervalEnd
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
cursor.setDate(cursor.getDate() + 1);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
return intervals;
|
|
1151
|
+
}
|
|
1152
|
+
function snapToWorkingTime(date, cal, direction) {
|
|
1153
|
+
var MAX_DAYS = 60;
|
|
1154
|
+
var result = new Date(date);
|
|
1155
|
+
|
|
1156
|
+
for (var attempt = 0; attempt < MAX_DAYS * 24 * 60; attempt++) {
|
|
1157
|
+
var dayStart = new Date(result);
|
|
1158
|
+
dayStart.setHours(0, 0, 0, 0);
|
|
1159
|
+
var shifts = getShiftsForDay(dayStart, cal);
|
|
1160
|
+
|
|
1161
|
+
if (shifts.length > 0) {
|
|
1162
|
+
if (direction === "forward") {
|
|
1163
|
+
var currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
|
|
1164
|
+
|
|
1165
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(shifts), _step2; !(_step2 = _iterator2()).done;) {
|
|
1166
|
+
var shift = _step2.value;
|
|
1167
|
+
|
|
1168
|
+
if (currentMins <= shift.end) {
|
|
1169
|
+
if (currentMins < shift.start) {
|
|
1170
|
+
result.setHours(Math.floor(shift.start / 60), Math.round(shift.start % 60), 0, 0);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
return result;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
result.setDate(result.getDate() + 1);
|
|
1178
|
+
result.setHours(0, 0, 0, 0);
|
|
1179
|
+
} else {
|
|
1180
|
+
var _currentMins = result.getHours() * 60 + result.getMinutes() + result.getSeconds() / 60;
|
|
1181
|
+
|
|
1182
|
+
for (var i = shifts.length - 1; i >= 0; i--) {
|
|
1183
|
+
if (_currentMins >= shifts[i].start) {
|
|
1184
|
+
if (_currentMins > shifts[i].end) {
|
|
1185
|
+
result.setHours(Math.floor(shifts[i].end / 60), Math.round(shifts[i].end % 60), 0, 0);
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
return result;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
result.setDate(result.getDate() - 1);
|
|
1193
|
+
result.setHours(23, 59, 59, 0);
|
|
1194
|
+
}
|
|
1195
|
+
} else {
|
|
1196
|
+
if (direction === "forward") {
|
|
1197
|
+
result.setDate(result.getDate() + 1);
|
|
1198
|
+
result.setHours(0, 0, 0, 0);
|
|
1199
|
+
} else {
|
|
1200
|
+
result.setDate(result.getDate() - 1);
|
|
1201
|
+
result.setHours(23, 59, 59, 0);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
return date;
|
|
1207
|
+
}
|
|
1208
|
+
function getQuarterNumber(date, quarterStart) {
|
|
1209
|
+
var month = date.getMonth();
|
|
1210
|
+
var offset = (month - quarterStart + 12) % 12;
|
|
1211
|
+
return Math.floor(offset / 3) + 1;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
var styles$5 = {"gridRow":"_2dZTy","gridRowLookAhead":"_2RRca","gridRowLine":"_3rUKi","gridTick":"_RuwuK","gridTickDashed":"_Zh9jh","darkerGridRow":"_2M-tt"};
|
|
1103
1215
|
|
|
1104
1216
|
var GridBody = function GridBody(_ref) {
|
|
1217
|
+
var _projectCalendar$week;
|
|
1218
|
+
|
|
1105
1219
|
var tasks = _ref.tasks,
|
|
1106
1220
|
scheduleType = _ref.scheduleType,
|
|
1107
1221
|
dates = _ref.dates,
|
|
@@ -1114,7 +1228,9 @@ var GridBody = function GridBody(_ref) {
|
|
|
1114
1228
|
_ref$virtualItems = _ref.virtualItems,
|
|
1115
1229
|
virtualItems = _ref$virtualItems === void 0 ? [] : _ref$virtualItems,
|
|
1116
1230
|
visibleStartY = _ref.visibleStartY,
|
|
1117
|
-
visibleEndY = _ref.visibleEndY
|
|
1231
|
+
visibleEndY = _ref.visibleEndY,
|
|
1232
|
+
projectCalendar = _ref.projectCalendar,
|
|
1233
|
+
viewMode = _ref.viewMode;
|
|
1118
1234
|
var visibleHeight = visibleEndY - visibleStartY;
|
|
1119
1235
|
var now = new Date();
|
|
1120
1236
|
var items = virtualItems.length > 0 ? virtualItems : tasks.map(function (_, i) {
|
|
@@ -1127,7 +1243,8 @@ var GridBody = function GridBody(_ref) {
|
|
|
1127
1243
|
};
|
|
1128
1244
|
});
|
|
1129
1245
|
|
|
1130
|
-
var
|
|
1246
|
+
var isDayOff = function isDayOff(date) {
|
|
1247
|
+
if (projectCalendar) return isOffDay(date, projectCalendar);
|
|
1131
1248
|
var d = date.getDay();
|
|
1132
1249
|
return d === 0 || d === 6;
|
|
1133
1250
|
};
|
|
@@ -1147,7 +1264,8 @@ var GridBody = function GridBody(_ref) {
|
|
|
1147
1264
|
};
|
|
1148
1265
|
|
|
1149
1266
|
var todayRects = [];
|
|
1150
|
-
var
|
|
1267
|
+
var offDayRects = [];
|
|
1268
|
+
var weekStartDay = (_projectCalendar$week = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) != null ? _projectCalendar$week : 1;
|
|
1151
1269
|
|
|
1152
1270
|
for (var i = 0, x = 0; i < dates.length; i++, x += columnWidth) {
|
|
1153
1271
|
if (isTodayColumn(i)) {
|
|
@@ -1161,26 +1279,57 @@ var GridBody = function GridBody(_ref) {
|
|
|
1161
1279
|
}));
|
|
1162
1280
|
}
|
|
1163
1281
|
|
|
1164
|
-
if (
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1282
|
+
if (viewMode !== ViewMode.Month && viewMode !== ViewMode.Quarter) {
|
|
1283
|
+
var _dates;
|
|
1284
|
+
|
|
1285
|
+
var pEnd = (_dates = dates[i + 1]) != null ? _dates : addToDate(dates[i], 1, "day");
|
|
1286
|
+
var periodMs = pEnd.getTime() - dates[i].getTime();
|
|
1287
|
+
|
|
1288
|
+
if (periodMs > 0) {
|
|
1289
|
+
var cursor = new Date(dates[i]);
|
|
1290
|
+
cursor.setHours(0, 0, 0, 0);
|
|
1291
|
+
|
|
1292
|
+
while (cursor.getTime() < pEnd.getTime()) {
|
|
1293
|
+
if (isDayOff(cursor)) {
|
|
1294
|
+
var ds = cursor.getTime() - dates[i].getTime();
|
|
1295
|
+
var de = ds + 86400000;
|
|
1296
|
+
var startFrac = Math.max(0, ds) / periodMs;
|
|
1297
|
+
var endFrac = Math.min(periodMs, de) / periodMs;
|
|
1298
|
+
var rw = (endFrac - startFrac) * columnWidth;
|
|
1299
|
+
|
|
1300
|
+
if (rw > 0.5) {
|
|
1301
|
+
offDayRects.push(React.createElement("rect", {
|
|
1302
|
+
key: "offday-" + i + "-" + cursor.getTime(),
|
|
1303
|
+
x: x + startFrac * columnWidth,
|
|
1304
|
+
y: visibleStartY,
|
|
1305
|
+
width: rw,
|
|
1306
|
+
height: visibleHeight,
|
|
1307
|
+
fill: weekendColor
|
|
1308
|
+
}));
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
cursor.setDate(cursor.getDate() + 1);
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1173
1315
|
}
|
|
1174
1316
|
}
|
|
1175
1317
|
|
|
1176
|
-
var
|
|
1318
|
+
var isDayView = viewMode === ViewMode.Day;
|
|
1319
|
+
var tickLines = dates.map(function (date, i) {
|
|
1320
|
+
var tickClass = styles$5.gridTick;
|
|
1321
|
+
|
|
1322
|
+
if (isDayView) {
|
|
1323
|
+
tickClass = date.getDay() === weekStartDay ? styles$5.gridTick : styles$5.gridTickDashed;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1177
1326
|
return React.createElement("line", {
|
|
1178
1327
|
key: "tick-" + i,
|
|
1179
1328
|
x1: i * columnWidth,
|
|
1180
1329
|
y1: visibleStartY,
|
|
1181
1330
|
x2: i * columnWidth,
|
|
1182
1331
|
y2: visibleEndY,
|
|
1183
|
-
className:
|
|
1332
|
+
className: tickClass
|
|
1184
1333
|
});
|
|
1185
1334
|
});
|
|
1186
1335
|
var rowBackgrounds = [];
|
|
@@ -1226,10 +1375,10 @@ var GridBody = function GridBody(_ref) {
|
|
|
1226
1375
|
}, rowBackgrounds), React.createElement("g", {
|
|
1227
1376
|
className: "rowLines"
|
|
1228
1377
|
}, rowLines), React.createElement("g", {
|
|
1378
|
+
className: "offdays"
|
|
1379
|
+
}, offDayRects), React.createElement("g", {
|
|
1229
1380
|
className: "ticks"
|
|
1230
|
-
}, tickLines),
|
|
1231
|
-
className: "weekend"
|
|
1232
|
-
}, weekendRects), React.createElement("g", {
|
|
1381
|
+
}, tickLines), React.createElement("g", {
|
|
1233
1382
|
className: "today"
|
|
1234
1383
|
}, todayRects));
|
|
1235
1384
|
};
|
|
@@ -1240,7 +1389,7 @@ var Grid = function Grid(props) {
|
|
|
1240
1389
|
}, React.createElement(GridBody, Object.assign({}, props)));
|
|
1241
1390
|
};
|
|
1242
1391
|
|
|
1243
|
-
var styles$6 = {"calendarBottomText":"_9w8d5","calendarTopTick":"_1rLuZ","calendarTopText":"_2q1Kt","calendarHeader":"_35nLX","textAnchorStart":"_2Shd-","textAnchorMiddle":"_2XXW4","textAnchorEnd":"_3GdnC"};
|
|
1392
|
+
var styles$6 = {"calendarBottomText":"_9w8d5","calendarTopTick":"_1rLuZ","calendarTickSolid":"_2X-yN","calendarTickDashed":"_2BaXZ","calendarOffDayHeader":"_24p-y","calendarTopText":"_2q1Kt","calendarHeader":"_35nLX","textAnchorStart":"_2Shd-","textAnchorMiddle":"_2XXW4","textAnchorEnd":"_3GdnC"};
|
|
1244
1393
|
|
|
1245
1394
|
var TopPartOfCalendar = function TopPartOfCalendar(_ref) {
|
|
1246
1395
|
var value = _ref.value,
|
|
@@ -1277,7 +1426,14 @@ var Calendar = function Calendar(_ref) {
|
|
|
1277
1426
|
headerHeight = _ref.headerHeight,
|
|
1278
1427
|
columnWidth = _ref.columnWidth,
|
|
1279
1428
|
fontFamily = _ref.fontFamily,
|
|
1280
|
-
fontSize = _ref.fontSize
|
|
1429
|
+
fontSize = _ref.fontSize,
|
|
1430
|
+
projectCalendar = _ref.projectCalendar;
|
|
1431
|
+
|
|
1432
|
+
var shortMonth = function shortMonth(date) {
|
|
1433
|
+
return date.toLocaleString(locale, {
|
|
1434
|
+
month: "short"
|
|
1435
|
+
});
|
|
1436
|
+
};
|
|
1281
1437
|
|
|
1282
1438
|
var getCalendarValuesForYear = function getCalendarValuesForYear() {
|
|
1283
1439
|
var topValues = [];
|
|
@@ -1320,93 +1476,150 @@ var Calendar = function Calendar(_ref) {
|
|
|
1320
1476
|
};
|
|
1321
1477
|
|
|
1322
1478
|
var getCalendarValuesForQuarter = function getCalendarValuesForQuarter() {
|
|
1479
|
+
var _projectCalendar$quar;
|
|
1480
|
+
|
|
1323
1481
|
var topValues = [];
|
|
1324
1482
|
var bottomValues = [];
|
|
1325
|
-
var
|
|
1483
|
+
var offDayRects = [];
|
|
1484
|
+
var quarterStart = (_projectCalendar$quar = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar : 0;
|
|
1485
|
+
var rowH = headerHeight / 3;
|
|
1326
1486
|
|
|
1327
1487
|
for (var i = 0; i < dateSetup.dates.length; i++) {
|
|
1328
1488
|
var date = dateSetup.dates[i];
|
|
1329
|
-
var
|
|
1330
|
-
|
|
1489
|
+
var qNum = getQuarterNumber(date, quarterStart);
|
|
1490
|
+
|
|
1491
|
+
for (var m = 0; m < 3; m++) {
|
|
1492
|
+
var monthDate = addToDate(date, m, "month");
|
|
1493
|
+
bottomValues.push(React.createElement("text", {
|
|
1494
|
+
key: "qmonth-" + i + "-" + m,
|
|
1495
|
+
y: headerHeight * 0.9,
|
|
1496
|
+
x: columnWidth * i + columnWidth * (m * 2 + 1) / 6,
|
|
1497
|
+
className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
|
|
1498
|
+
}, shortMonth(monthDate)));
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1331
1501
|
bottomValues.push(React.createElement("text", {
|
|
1332
|
-
key:
|
|
1333
|
-
y:
|
|
1502
|
+
key: "qlabel-" + i,
|
|
1503
|
+
y: rowH * 1.6,
|
|
1334
1504
|
x: columnWidth * i + columnWidth * 0.5,
|
|
1335
|
-
className: styles$6.
|
|
1336
|
-
},
|
|
1505
|
+
className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
|
|
1506
|
+
}, "Qtr " + qNum));
|
|
1507
|
+
bottomValues.push(React.createElement("line", {
|
|
1508
|
+
key: "qsep-" + i,
|
|
1509
|
+
x1: columnWidth * i,
|
|
1510
|
+
y1: rowH,
|
|
1511
|
+
x2: columnWidth * i,
|
|
1512
|
+
y2: headerHeight,
|
|
1513
|
+
className: styles$6.calendarTopTick
|
|
1514
|
+
}));
|
|
1515
|
+
|
|
1516
|
+
if (i === 0) {
|
|
1517
|
+
bottomValues.push(React.createElement("line", {
|
|
1518
|
+
key: "qhsep1",
|
|
1519
|
+
x1: 0,
|
|
1520
|
+
y1: rowH,
|
|
1521
|
+
x2: columnWidth * dateSetup.dates.length,
|
|
1522
|
+
y2: rowH,
|
|
1523
|
+
className: styles$6.calendarTopTick
|
|
1524
|
+
}));
|
|
1525
|
+
bottomValues.push(React.createElement("line", {
|
|
1526
|
+
key: "qhsep2",
|
|
1527
|
+
x1: 0,
|
|
1528
|
+
y1: rowH * 2,
|
|
1529
|
+
x2: columnWidth * dateSetup.dates.length,
|
|
1530
|
+
y2: rowH * 2,
|
|
1531
|
+
className: styles$6.calendarTopTick
|
|
1532
|
+
}));
|
|
1533
|
+
}
|
|
1337
1534
|
|
|
1338
1535
|
if (i === 0 || date.getFullYear() !== dateSetup.dates[i - 1].getFullYear()) {
|
|
1339
1536
|
var topValue = date.getFullYear().toString();
|
|
1340
|
-
var
|
|
1537
|
+
var span = 0;
|
|
1341
1538
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
} else {
|
|
1345
|
-
xText = (3 + i - quarter) * columnWidth;
|
|
1539
|
+
for (var j = i; j < dateSetup.dates.length && dateSetup.dates[j].getFullYear() === date.getFullYear(); j++) {
|
|
1540
|
+
span++;
|
|
1346
1541
|
}
|
|
1347
1542
|
|
|
1543
|
+
var xText = columnWidth * i + columnWidth * span / 2;
|
|
1348
1544
|
topValues.push(React.createElement(TopPartOfCalendar, {
|
|
1349
|
-
key: topValue,
|
|
1545
|
+
key: topValue + i,
|
|
1350
1546
|
value: topValue,
|
|
1351
1547
|
x1Line: columnWidth * i,
|
|
1352
1548
|
y1Line: 0,
|
|
1353
|
-
y2Line:
|
|
1549
|
+
y2Line: rowH,
|
|
1354
1550
|
xText: xText,
|
|
1355
|
-
yText:
|
|
1551
|
+
yText: rowH * 0.7,
|
|
1552
|
+
textAnchor: "middle"
|
|
1356
1553
|
}));
|
|
1357
1554
|
}
|
|
1358
1555
|
}
|
|
1359
1556
|
|
|
1360
|
-
return [topValues, bottomValues];
|
|
1557
|
+
return [topValues, bottomValues, offDayRects];
|
|
1361
1558
|
};
|
|
1362
1559
|
|
|
1363
1560
|
var getCalendarValuesForMonth = function getCalendarValuesForMonth() {
|
|
1561
|
+
var _projectCalendar$quar2;
|
|
1562
|
+
|
|
1364
1563
|
var topValues = [];
|
|
1365
1564
|
var bottomValues = [];
|
|
1565
|
+
var offDayRects = [];
|
|
1366
1566
|
var topDefaultHeight = headerHeight * 0.5;
|
|
1567
|
+
var quarterStart = (_projectCalendar$quar2 = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.quarter_start) != null ? _projectCalendar$quar2 : 0;
|
|
1367
1568
|
|
|
1368
1569
|
for (var i = 0; i < dateSetup.dates.length; i++) {
|
|
1369
1570
|
var date = dateSetup.dates[i];
|
|
1370
|
-
var bottomValue = date
|
|
1371
|
-
month: "short"
|
|
1372
|
-
});
|
|
1571
|
+
var bottomValue = shortMonth(date);
|
|
1373
1572
|
bottomValues.push(React.createElement("text", {
|
|
1374
|
-
key: bottomValue + date.getFullYear(),
|
|
1573
|
+
key: bottomValue + date.getFullYear() + i,
|
|
1375
1574
|
y: headerHeight * 0.8,
|
|
1376
1575
|
x: columnWidth * i + columnWidth * 0.5,
|
|
1377
|
-
className: styles$6.calendarTopText + " " + styles$6.
|
|
1576
|
+
className: styles$6.calendarTopText + " " + styles$6.textAnchorMiddle
|
|
1378
1577
|
}, bottomValue));
|
|
1578
|
+
var qNum = getQuarterNumber(date, quarterStart);
|
|
1579
|
+
var prevDate = i > 0 ? dateSetup.dates[i - 1] : null;
|
|
1580
|
+
var prevQNum = prevDate ? getQuarterNumber(prevDate, quarterStart) : -1;
|
|
1581
|
+
var isNewQuarter = i === 0 || qNum !== prevQNum || date.getFullYear() !== (prevDate ? prevDate.getFullYear() : -1);
|
|
1379
1582
|
|
|
1380
|
-
if (
|
|
1381
|
-
var topValue = date.getFullYear()
|
|
1382
|
-
var
|
|
1583
|
+
if (isNewQuarter) {
|
|
1584
|
+
var topValue = "Qtr " + qNum + ", " + date.getFullYear();
|
|
1585
|
+
var span = 0;
|
|
1383
1586
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
} else {
|
|
1387
|
-
xText = (6 + i - date.getMonth()) * columnWidth;
|
|
1587
|
+
for (var j = i; j < dateSetup.dates.length && getQuarterNumber(dateSetup.dates[j], quarterStart) === qNum && dateSetup.dates[j].getFullYear() === date.getFullYear(); j++) {
|
|
1588
|
+
span++;
|
|
1388
1589
|
}
|
|
1389
1590
|
|
|
1390
|
-
|
|
1591
|
+
var xText = rtl ? columnWidth * i + columnWidth * span * 0.5 + columnWidth : columnWidth * i + columnWidth * span / 2;
|
|
1391
1592
|
topValues.push(React.createElement(TopPartOfCalendar, {
|
|
1392
|
-
key: topValue,
|
|
1593
|
+
key: topValue + i,
|
|
1393
1594
|
value: topValue,
|
|
1394
1595
|
x1Line: columnWidth * i,
|
|
1395
1596
|
y1Line: 0,
|
|
1396
1597
|
y2Line: topDefaultHeight,
|
|
1397
1598
|
xText: xText,
|
|
1398
|
-
yText: topDefaultHeight * 0.
|
|
1399
|
-
textAnchor: "
|
|
1599
|
+
yText: topDefaultHeight * 0.7,
|
|
1600
|
+
textAnchor: "middle"
|
|
1400
1601
|
}));
|
|
1602
|
+
|
|
1603
|
+
if (i > 0) {
|
|
1604
|
+
bottomValues.push(React.createElement("line", {
|
|
1605
|
+
key: "qbound-" + i,
|
|
1606
|
+
x1: columnWidth * i,
|
|
1607
|
+
y1: topDefaultHeight,
|
|
1608
|
+
x2: columnWidth * i,
|
|
1609
|
+
y2: headerHeight,
|
|
1610
|
+
className: styles$6.calendarTopTick
|
|
1611
|
+
}));
|
|
1612
|
+
}
|
|
1401
1613
|
}
|
|
1402
1614
|
}
|
|
1403
1615
|
|
|
1404
|
-
return [topValues, bottomValues];
|
|
1616
|
+
return [topValues, bottomValues, offDayRects];
|
|
1405
1617
|
};
|
|
1406
1618
|
|
|
1407
1619
|
var getCalendarValuesForWeek = function getCalendarValuesForWeek() {
|
|
1408
1620
|
var topValues = [];
|
|
1409
1621
|
var bottomValues = [];
|
|
1622
|
+
var offDayRects = [];
|
|
1410
1623
|
var weeksCount = 1;
|
|
1411
1624
|
var topDefaultHeight = headerHeight * 0.5;
|
|
1412
1625
|
var dates = dateSetup.dates;
|
|
@@ -1416,10 +1629,10 @@ var Calendar = function Calendar(_ref) {
|
|
|
1416
1629
|
var topValue = "";
|
|
1417
1630
|
|
|
1418
1631
|
if (i === 0 || date.getMonth() !== dates[i - 1].getMonth()) {
|
|
1419
|
-
topValue =
|
|
1632
|
+
topValue = shortMonth(date) + " " + date.getFullYear();
|
|
1420
1633
|
}
|
|
1421
1634
|
|
|
1422
|
-
var bottomValue =
|
|
1635
|
+
var bottomValue = date.getDate().toString();
|
|
1423
1636
|
bottomValues.push(React.createElement("text", {
|
|
1424
1637
|
key: date.getTime(),
|
|
1425
1638
|
y: headerHeight * 0.8,
|
|
@@ -1430,7 +1643,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
1430
1643
|
if (topValue) {
|
|
1431
1644
|
if (i !== dates.length - 1) {
|
|
1432
1645
|
topValues.push(React.createElement(TopPartOfCalendar, {
|
|
1433
|
-
key: topValue,
|
|
1646
|
+
key: topValue + i,
|
|
1434
1647
|
value: topValue,
|
|
1435
1648
|
x1Line: columnWidth * i + weeksCount * columnWidth,
|
|
1436
1649
|
y1Line: 0,
|
|
@@ -1447,18 +1660,32 @@ var Calendar = function Calendar(_ref) {
|
|
|
1447
1660
|
weeksCount++;
|
|
1448
1661
|
}
|
|
1449
1662
|
|
|
1450
|
-
return [topValues, bottomValues];
|
|
1663
|
+
return [topValues, bottomValues, offDayRects];
|
|
1451
1664
|
};
|
|
1452
1665
|
|
|
1453
1666
|
var getCalendarValuesForDay = function getCalendarValuesForDay() {
|
|
1667
|
+
var _projectCalendar$week;
|
|
1668
|
+
|
|
1454
1669
|
var topValues = [];
|
|
1455
1670
|
var bottomValues = [];
|
|
1671
|
+
var offDayRects = [];
|
|
1672
|
+
var tickLines = [];
|
|
1456
1673
|
var topDefaultHeight = headerHeight * 0.5;
|
|
1457
1674
|
var dates = dateSetup.dates;
|
|
1675
|
+
var weekStartDay = (_projectCalendar$week = projectCalendar === null || projectCalendar === void 0 ? void 0 : projectCalendar.week_start) != null ? _projectCalendar$week : 1;
|
|
1458
1676
|
|
|
1459
1677
|
for (var i = 0; i < dates.length; i++) {
|
|
1460
1678
|
var date = dates[i];
|
|
1461
|
-
var
|
|
1679
|
+
var isWeekStart = date.getDay() === weekStartDay;
|
|
1680
|
+
tickLines.push(React.createElement("line", {
|
|
1681
|
+
key: "tick-day-" + i,
|
|
1682
|
+
x1: columnWidth * i,
|
|
1683
|
+
y1: topDefaultHeight,
|
|
1684
|
+
x2: columnWidth * i,
|
|
1685
|
+
y2: headerHeight,
|
|
1686
|
+
className: isWeekStart ? styles$6.calendarTickSolid : styles$6.calendarTickDashed
|
|
1687
|
+
}));
|
|
1688
|
+
var bottomValue = columnWidth > 55 ? getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate() : getLocalDayOfWeek(date, locale, "narrow") + "," + date.getDate();
|
|
1462
1689
|
bottomValues.push(React.createElement("text", {
|
|
1463
1690
|
key: date.getTime(),
|
|
1464
1691
|
y: headerHeight * 0.8,
|
|
@@ -1467,9 +1694,9 @@ var Calendar = function Calendar(_ref) {
|
|
|
1467
1694
|
}, bottomValue));
|
|
1468
1695
|
|
|
1469
1696
|
if (i + 1 !== dates.length && date.getMonth() !== dates[i + 1].getMonth()) {
|
|
1470
|
-
var topValue =
|
|
1697
|
+
var topValue = shortMonth(date) + " " + date.getFullYear();
|
|
1471
1698
|
topValues.push(React.createElement(TopPartOfCalendar, {
|
|
1472
|
-
key: topValue +
|
|
1699
|
+
key: topValue + i,
|
|
1473
1700
|
value: topValue,
|
|
1474
1701
|
x1Line: columnWidth * (i + 1),
|
|
1475
1702
|
y1Line: 0,
|
|
@@ -1480,10 +1707,10 @@ var Calendar = function Calendar(_ref) {
|
|
|
1480
1707
|
}
|
|
1481
1708
|
|
|
1482
1709
|
if (i + 1 === dates.length) {
|
|
1483
|
-
var _topValue =
|
|
1710
|
+
var _topValue = shortMonth(date) + " " + date.getFullYear();
|
|
1484
1711
|
|
|
1485
1712
|
topValues.push(React.createElement(TopPartOfCalendar, {
|
|
1486
|
-
key: _topValue +
|
|
1713
|
+
key: _topValue + "last",
|
|
1487
1714
|
value: _topValue,
|
|
1488
1715
|
x1Line: columnWidth * (i + 1),
|
|
1489
1716
|
y1Line: 0,
|
|
@@ -1494,7 +1721,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
1494
1721
|
}
|
|
1495
1722
|
}
|
|
1496
1723
|
|
|
1497
|
-
return [topValues, bottomValues];
|
|
1724
|
+
return [topValues, bottomValues, offDayRects, tickLines];
|
|
1498
1725
|
};
|
|
1499
1726
|
|
|
1500
1727
|
var getCalendarValuesForPartOfDay = function getCalendarValuesForPartOfDay() {
|
|
@@ -1518,7 +1745,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
1518
1745
|
}, bottomValue));
|
|
1519
1746
|
|
|
1520
1747
|
if (i === 0 || date.getDate() !== dates[i - 1].getDate()) {
|
|
1521
|
-
var topValue = getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate() + " " +
|
|
1748
|
+
var topValue = getLocalDayOfWeek(date, locale, "short") + ", " + date.getDate() + " " + shortMonth(date);
|
|
1522
1749
|
topValues.push(React.createElement(TopPartOfCalendar, {
|
|
1523
1750
|
key: topValue + date.getFullYear(),
|
|
1524
1751
|
value: topValue,
|
|
@@ -1555,7 +1782,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
1555
1782
|
|
|
1556
1783
|
if (i !== 0 && date.getDate() !== dates[i - 1].getDate()) {
|
|
1557
1784
|
var displayDate = dates[i - 1];
|
|
1558
|
-
var topValue = getLocalDayOfWeek(displayDate, locale, "long") + ", " + displayDate.getDate() + " " +
|
|
1785
|
+
var topValue = getLocalDayOfWeek(displayDate, locale, "long") + ", " + displayDate.getDate() + " " + shortMonth(displayDate);
|
|
1559
1786
|
var topPosition = (date.getHours() - 24) / 2;
|
|
1560
1787
|
topValues.push(React.createElement(TopPartOfCalendar, {
|
|
1561
1788
|
key: topValue + displayDate.getFullYear(),
|
|
@@ -1574,6 +1801,8 @@ var Calendar = function Calendar(_ref) {
|
|
|
1574
1801
|
|
|
1575
1802
|
var topValues = [];
|
|
1576
1803
|
var bottomValues = [];
|
|
1804
|
+
var extraValues = [];
|
|
1805
|
+
var tickLines = [];
|
|
1577
1806
|
|
|
1578
1807
|
switch (dateSetup.viewMode) {
|
|
1579
1808
|
case ViewMode.Year:
|
|
@@ -1584,46 +1813,57 @@ var Calendar = function Calendar(_ref) {
|
|
|
1584
1813
|
break;
|
|
1585
1814
|
|
|
1586
1815
|
case ViewMode.Quarter:
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1816
|
+
{
|
|
1817
|
+
var r = getCalendarValuesForQuarter();
|
|
1818
|
+
topValues = r[0];
|
|
1819
|
+
bottomValues = r[1];
|
|
1820
|
+
extraValues = r[2] || [];
|
|
1821
|
+
break;
|
|
1822
|
+
}
|
|
1592
1823
|
|
|
1593
1824
|
case ViewMode.Month:
|
|
1594
|
-
|
|
1825
|
+
{
|
|
1826
|
+
var _r = getCalendarValuesForMonth();
|
|
1595
1827
|
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1828
|
+
topValues = _r[0];
|
|
1829
|
+
bottomValues = _r[1];
|
|
1830
|
+
extraValues = _r[2] || [];
|
|
1831
|
+
break;
|
|
1832
|
+
}
|
|
1599
1833
|
|
|
1600
1834
|
case ViewMode.Week:
|
|
1601
|
-
|
|
1835
|
+
{
|
|
1836
|
+
var _r2 = getCalendarValuesForWeek();
|
|
1602
1837
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1838
|
+
topValues = _r2[0];
|
|
1839
|
+
bottomValues = _r2[1];
|
|
1840
|
+
extraValues = _r2[2] || [];
|
|
1841
|
+
break;
|
|
1842
|
+
}
|
|
1606
1843
|
|
|
1607
1844
|
case ViewMode.Day:
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1845
|
+
{
|
|
1846
|
+
var result = getCalendarValuesForDay();
|
|
1847
|
+
topValues = result[0];
|
|
1848
|
+
bottomValues = result[1];
|
|
1849
|
+
extraValues = result[2];
|
|
1850
|
+
tickLines = result[3];
|
|
1851
|
+
break;
|
|
1852
|
+
}
|
|
1613
1853
|
|
|
1614
1854
|
case ViewMode.QuarterDay:
|
|
1615
1855
|
case ViewMode.HalfDay:
|
|
1616
|
-
var
|
|
1856
|
+
var _getCalendarValuesFor2 = getCalendarValuesForPartOfDay();
|
|
1617
1857
|
|
|
1618
|
-
topValues =
|
|
1619
|
-
bottomValues =
|
|
1858
|
+
topValues = _getCalendarValuesFor2[0];
|
|
1859
|
+
bottomValues = _getCalendarValuesFor2[1];
|
|
1620
1860
|
break;
|
|
1621
1861
|
|
|
1622
1862
|
case ViewMode.Hour:
|
|
1623
|
-
var
|
|
1863
|
+
var _getCalendarValuesFor3 = getCalendarValuesForHour();
|
|
1624
1864
|
|
|
1625
|
-
topValues =
|
|
1626
|
-
bottomValues =
|
|
1865
|
+
topValues = _getCalendarValuesFor3[0];
|
|
1866
|
+
bottomValues = _getCalendarValuesFor3[1];
|
|
1627
1867
|
}
|
|
1628
1868
|
|
|
1629
1869
|
return React.createElement("g", {
|
|
@@ -1637,7 +1877,7 @@ var Calendar = function Calendar(_ref) {
|
|
|
1637
1877
|
width: columnWidth * dateSetup.dates.length,
|
|
1638
1878
|
height: headerHeight,
|
|
1639
1879
|
className: styles$6.calendarHeader
|
|
1640
|
-
}),
|
|
1880
|
+
}), extraValues, tickLines, bottomValues, topValues);
|
|
1641
1881
|
};
|
|
1642
1882
|
|
|
1643
1883
|
// A type of promise-like that resolves synchronously and supports only one observer
|
|
@@ -1691,19 +1931,31 @@ var drawPathAndTriangle = function drawPathAndTriangle(taskFrom, taskTo, rowHeig
|
|
|
1691
1931
|
var verticalOffset = indexCompare * (rowHeight / 2);
|
|
1692
1932
|
|
|
1693
1933
|
var minX = function minX(t) {
|
|
1694
|
-
if (t.
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
return
|
|
1698
|
-
} else if (t.actualx1) {
|
|
1699
|
-
return t.actualx1;
|
|
1700
|
-
} else {
|
|
1701
|
-
return 0;
|
|
1934
|
+
if (t.plannedSegments && t.plannedSegments.length > 0) {
|
|
1935
|
+
var p = t.plannedSegments[0].x1;
|
|
1936
|
+
if (t.actualSegments && t.actualSegments.length > 0) return Math.min(p, t.actualSegments[0].x1);
|
|
1937
|
+
return p;
|
|
1702
1938
|
}
|
|
1939
|
+
|
|
1940
|
+
if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[0].x1;
|
|
1941
|
+
var candidates = [];
|
|
1942
|
+
if (t.x1 !== undefined && t.x1 >= 0) candidates.push(t.x1);
|
|
1943
|
+
if (t.actualx1 !== undefined && t.actualx1 >= 0) candidates.push(t.actualx1);
|
|
1944
|
+
return candidates.length > 0 ? Math.min.apply(Math, candidates) : 0;
|
|
1703
1945
|
};
|
|
1704
1946
|
|
|
1705
1947
|
var maxX = function maxX(t) {
|
|
1706
|
-
|
|
1948
|
+
if (t.plannedSegments && t.plannedSegments.length > 0) {
|
|
1949
|
+
var p = t.plannedSegments[t.plannedSegments.length - 1].x2;
|
|
1950
|
+
if (t.actualSegments && t.actualSegments.length > 0) return Math.max(p, t.actualSegments[t.actualSegments.length - 1].x2);
|
|
1951
|
+
return p;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
if (t.actualSegments && t.actualSegments.length > 0) return t.actualSegments[t.actualSegments.length - 1].x2;
|
|
1955
|
+
var candidates = [];
|
|
1956
|
+
if (t.x2 !== undefined && t.x2 >= 0) candidates.push(t.x2);
|
|
1957
|
+
if (t.actualx2 !== undefined && t.actualx2 >= 0) candidates.push(t.actualx2);
|
|
1958
|
+
return candidates.length > 0 ? Math.max.apply(Math, candidates) : 0;
|
|
1707
1959
|
};
|
|
1708
1960
|
|
|
1709
1961
|
var fromPoint, toPoint;
|
|
@@ -1830,10 +2082,10 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
|
|
|
1830
2082
|
actualx1 = task.actualStart ? taskXCoordinateRTL(task.actualStart, dates, columnWidth) : -1;
|
|
1831
2083
|
actualx2 = task.actualEnd ? taskXCoordinateRTL(task.actualEnd, dates, columnWidth) : -1;
|
|
1832
2084
|
} else {
|
|
1833
|
-
x1 = task.start ? taskXCoordinate(task.start, dates, columnWidth) : -1;
|
|
1834
|
-
x2 = task.end ? taskXCoordinate(task.end, dates, columnWidth) : -1;
|
|
1835
|
-
actualx1 = task.actualStart ? taskXCoordinate(task.actualStart, dates, columnWidth) : -1;
|
|
1836
|
-
actualx2 = task.actualEnd ? taskXCoordinate(task.actualEnd, dates, columnWidth) : -1;
|
|
2085
|
+
x1 = task.start ? taskXCoordinate(startOfDate(task.start, "day"), dates, columnWidth) : -1;
|
|
2086
|
+
x2 = task.end ? taskXCoordinate(addToDate(startOfDate(task.end, "day"), 1, "day"), dates, columnWidth) : -1;
|
|
2087
|
+
actualx1 = task.actualStart ? taskXCoordinate(startOfDate(task.actualStart, "day"), dates, columnWidth) : -1;
|
|
2088
|
+
actualx2 = task.actualEnd ? taskXCoordinate(addToDate(startOfDate(task.actualEnd, "day"), 1, "day"), dates, columnWidth) : -1;
|
|
1837
2089
|
}
|
|
1838
2090
|
|
|
1839
2091
|
progressStartWidth = actualx1 && x1 ? Math.abs(actualx1 - x1) : -1;
|
|
@@ -1846,6 +2098,39 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
|
|
|
1846
2098
|
|
|
1847
2099
|
var y = taskYCoordinate(index, rowHeight, taskHeight);
|
|
1848
2100
|
var hideChildren = task.hideChildren || false;
|
|
2101
|
+
var plannedSegments;
|
|
2102
|
+
var actualSegments;
|
|
2103
|
+
|
|
2104
|
+
if (task.calender && task.start && task.end && task.start.getTime() > 0) {
|
|
2105
|
+
var planEnd = addToDate(startOfDate(task.end, "day"), 1, "day");
|
|
2106
|
+
var intervals = getWorkingIntervals(task.start, planEnd, task.calender);
|
|
2107
|
+
var segs = intervals.map(function (iv) {
|
|
2108
|
+
return {
|
|
2109
|
+
x1: taskXCoordinate(iv.start, dates, columnWidth),
|
|
2110
|
+
x2: taskXCoordinate(iv.end, dates, columnWidth)
|
|
2111
|
+
};
|
|
2112
|
+
}).filter(function (s) {
|
|
2113
|
+
return s.x2 > s.x1;
|
|
2114
|
+
});
|
|
2115
|
+
if (segs.length > 0) plannedSegments = segs;
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
if (task.calender && task.actualStart && task.actualEnd && task.actualStart.getTime() > 0) {
|
|
2119
|
+
var actEnd = addToDate(startOfDate(task.actualEnd, "day"), 1, "day");
|
|
2120
|
+
|
|
2121
|
+
var _intervals = getWorkingIntervals(task.actualStart, actEnd, task.calender);
|
|
2122
|
+
|
|
2123
|
+
var _segs = _intervals.map(function (iv) {
|
|
2124
|
+
return {
|
|
2125
|
+
x1: taskXCoordinate(iv.start, dates, columnWidth),
|
|
2126
|
+
x2: taskXCoordinate(iv.end, dates, columnWidth)
|
|
2127
|
+
};
|
|
2128
|
+
}).filter(function (s) {
|
|
2129
|
+
return s.x2 > s.x1;
|
|
2130
|
+
});
|
|
2131
|
+
|
|
2132
|
+
if (_segs.length > 0) actualSegments = _segs;
|
|
2133
|
+
}
|
|
1849
2134
|
|
|
1850
2135
|
var styles = _extends({
|
|
1851
2136
|
backgroundColor: barBackgroundColor,
|
|
@@ -1871,7 +2156,9 @@ var convertToBar = function convertToBar(task, index, dates, columnWidth, rowHei
|
|
|
1871
2156
|
hideChildren: hideChildren,
|
|
1872
2157
|
height: taskHeight,
|
|
1873
2158
|
barChildren: [],
|
|
1874
|
-
styles: styles
|
|
2159
|
+
styles: styles,
|
|
2160
|
+
plannedSegments: plannedSegments,
|
|
2161
|
+
actualSegments: actualSegments
|
|
1875
2162
|
});
|
|
1876
2163
|
};
|
|
1877
2164
|
|
|
@@ -2237,6 +2524,7 @@ var BarDisplay = function BarDisplay(_ref) {
|
|
|
2237
2524
|
progressWidth = _ref.progressWidth,
|
|
2238
2525
|
barCornerRadius = _ref.barCornerRadius,
|
|
2239
2526
|
styles = _ref.styles,
|
|
2527
|
+
segments = _ref.segments,
|
|
2240
2528
|
onMouseDown = _ref.onMouseDown;
|
|
2241
2529
|
|
|
2242
2530
|
var getProcessColor = function getProcessColor() {
|
|
@@ -2247,45 +2535,121 @@ var BarDisplay = function BarDisplay(_ref) {
|
|
|
2247
2535
|
return isSelected ? styles.backgroundSelectedColor : styles.backgroundColor;
|
|
2248
2536
|
};
|
|
2249
2537
|
|
|
2250
|
-
if (type
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2538
|
+
if (type === "planned") {
|
|
2539
|
+
if (segments && segments.length > 0) {
|
|
2540
|
+
var totalWidth = width;
|
|
2541
|
+
return React.createElement("g", {
|
|
2542
|
+
onMouseDown: onMouseDown
|
|
2543
|
+
}, segments.map(function (seg, idx) {
|
|
2544
|
+
return React.createElement("rect", {
|
|
2545
|
+
key: "seg-" + idx,
|
|
2546
|
+
x: seg.x1,
|
|
2547
|
+
width: seg.x2 - seg.x1,
|
|
2548
|
+
y: y,
|
|
2549
|
+
height: height,
|
|
2550
|
+
ry: barCornerRadius,
|
|
2551
|
+
rx: barCornerRadius,
|
|
2552
|
+
fill: getBarColor(),
|
|
2553
|
+
strokeWidth: 2,
|
|
2554
|
+
stroke: styles.criticalPathColor
|
|
2555
|
+
});
|
|
2556
|
+
}), progressWidth > 0 && function () {
|
|
2557
|
+
var rects = [];
|
|
2558
|
+
var remaining = progressWidth;
|
|
2559
|
+
|
|
2560
|
+
for (var _iterator = _createForOfIteratorHelperLoose(segments), _step; !(_step = _iterator()).done;) {
|
|
2561
|
+
var seg = _step.value;
|
|
2562
|
+
if (remaining <= 0) break;
|
|
2563
|
+
var segW = seg.x2 - seg.x1;
|
|
2564
|
+
var ratio = totalWidth > 0 ? segW / totalWidth : 0;
|
|
2565
|
+
var pw = Math.min(remaining, progressWidth * ratio);
|
|
2566
|
+
|
|
2567
|
+
if (pw > 0) {
|
|
2568
|
+
rects.push(React.createElement("rect", {
|
|
2569
|
+
key: "prog-" + seg.x1,
|
|
2570
|
+
x: seg.x1,
|
|
2571
|
+
width: pw,
|
|
2572
|
+
y: y,
|
|
2573
|
+
height: height,
|
|
2574
|
+
ry: barCornerRadius,
|
|
2575
|
+
rx: barCornerRadius,
|
|
2576
|
+
fill: getProcessColor()
|
|
2577
|
+
}));
|
|
2578
|
+
remaining -= pw;
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
return rects;
|
|
2583
|
+
}());
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
return React.createElement("g", {
|
|
2587
|
+
onMouseDown: onMouseDown
|
|
2588
|
+
}, React.createElement("rect", {
|
|
2589
|
+
x: x,
|
|
2590
|
+
width: width,
|
|
2591
|
+
y: y,
|
|
2592
|
+
height: height,
|
|
2593
|
+
ry: barCornerRadius,
|
|
2594
|
+
rx: barCornerRadius,
|
|
2595
|
+
fill: getBarColor(),
|
|
2596
|
+
strokeWidth: 2,
|
|
2597
|
+
stroke: styles.criticalPathColor
|
|
2598
|
+
}), React.createElement("rect", {
|
|
2599
|
+
x: progressX,
|
|
2600
|
+
width: progressWidth,
|
|
2601
|
+
y: y,
|
|
2602
|
+
height: height,
|
|
2603
|
+
ry: barCornerRadius,
|
|
2604
|
+
rx: barCornerRadius,
|
|
2605
|
+
fill: getProcessColor()
|
|
2606
|
+
}));
|
|
2607
|
+
} else {
|
|
2608
|
+
if (segments && segments.length > 0) {
|
|
2609
|
+
return React.createElement("g", {
|
|
2610
|
+
onMouseDown: onMouseDown
|
|
2611
|
+
}, segments.map(function (seg, idx) {
|
|
2612
|
+
return React.createElement("rect", {
|
|
2613
|
+
key: "aseg-" + idx,
|
|
2614
|
+
x: seg.x1,
|
|
2615
|
+
width: seg.x2 - seg.x1,
|
|
2616
|
+
y: y,
|
|
2617
|
+
height: height,
|
|
2618
|
+
ry: barCornerRadius,
|
|
2619
|
+
rx: barCornerRadius,
|
|
2620
|
+
fill: styles.taskProgressColor
|
|
2621
|
+
});
|
|
2622
|
+
}), React.createElement("rect", {
|
|
2623
|
+
x: progressX,
|
|
2624
|
+
width: progressWidth,
|
|
2625
|
+
y: y,
|
|
2626
|
+
height: height,
|
|
2627
|
+
ry: barCornerRadius,
|
|
2628
|
+
rx: barCornerRadius,
|
|
2629
|
+
fill: getProcessColor()
|
|
2630
|
+
}));
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
return React.createElement("g", {
|
|
2634
|
+
onMouseDown: onMouseDown
|
|
2635
|
+
}, React.createElement("rect", {
|
|
2636
|
+
x: x,
|
|
2637
|
+
width: width,
|
|
2638
|
+
y: y,
|
|
2639
|
+
height: height,
|
|
2640
|
+
ry: barCornerRadius,
|
|
2641
|
+
rx: barCornerRadius,
|
|
2642
|
+
fill: styles.taskProgressColor
|
|
2643
|
+
}), React.createElement("rect", {
|
|
2644
|
+
x: progressX,
|
|
2645
|
+
width: progressWidth,
|
|
2646
|
+
y: y,
|
|
2647
|
+
height: height,
|
|
2648
|
+
ry: barCornerRadius,
|
|
2649
|
+
rx: barCornerRadius,
|
|
2650
|
+
fill: getProcessColor()
|
|
2651
|
+
}));
|
|
2652
|
+
}
|
|
2289
2653
|
};
|
|
2290
2654
|
|
|
2291
2655
|
var styles$7 = {"barWrapper":"_KxSXS","barHandle":"_3w_5u","barBackground":"_31ERP"};
|
|
@@ -2325,12 +2689,24 @@ var Bar = function Bar(_ref) {
|
|
|
2325
2689
|
isSelected = _ref.isSelected;
|
|
2326
2690
|
var progressPoint = getProgressPoint(+!rtl * task.progressWidth + task.progressX, task.y, task.height);
|
|
2327
2691
|
var handleHeight = task.height / 2 - 1;
|
|
2692
|
+
var plannedSegs = task.plannedSegments;
|
|
2693
|
+
var plannedLeftHandleX = plannedSegs !== null && plannedSegs !== void 0 && plannedSegs.length ? plannedSegs[0].x1 : task.x1;
|
|
2694
|
+
var plannedRightHandleX = plannedSegs !== null && plannedSegs !== void 0 && plannedSegs.length ? plannedSegs[plannedSegs.length - 1].x2 : task.x2;
|
|
2695
|
+
var actualSegs = task.actualSegments;
|
|
2696
|
+
var actualLeftHandleX = actualSegs !== null && actualSegs !== void 0 && actualSegs.length ? actualSegs[0].x1 : task.actualx1;
|
|
2697
|
+
var actualRightHandleX = actualSegs !== null && actualSegs !== void 0 && actualSegs.length ? actualSegs[actualSegs.length - 1].x2 : task.actualx2;
|
|
2328
2698
|
|
|
2329
2699
|
if (type == "planned") {
|
|
2330
2700
|
if ((task === null || task === void 0 ? void 0 : task.x1) >= 0 && (task === null || task === void 0 ? void 0 : task.x2) >= 0 && task.x2 - task.x1 >= 0) return React.createElement("g", {
|
|
2331
2701
|
className: styles$7.barWrapper,
|
|
2332
2702
|
tabIndex: 0
|
|
2333
|
-
}, React.createElement(
|
|
2703
|
+
}, React.createElement("rect", {
|
|
2704
|
+
x: task.x1,
|
|
2705
|
+
y: task.y,
|
|
2706
|
+
width: task.x2 - task.x1,
|
|
2707
|
+
height: task.height / 2,
|
|
2708
|
+
fill: "transparent"
|
|
2709
|
+
}), React.createElement(BarDisplay, {
|
|
2334
2710
|
x: task.x1,
|
|
2335
2711
|
y: task.y,
|
|
2336
2712
|
type: type,
|
|
@@ -2343,13 +2719,14 @@ var Bar = function Bar(_ref) {
|
|
|
2343
2719
|
barCornerRadius: task.barCornerRadius,
|
|
2344
2720
|
styles: task.styles,
|
|
2345
2721
|
isSelected: isSelected,
|
|
2722
|
+
segments: task.plannedSegments,
|
|
2346
2723
|
onMouseDown: function onMouseDown(e) {
|
|
2347
2724
|
isDateChangeable && onEventStart("move", task, e, "planned");
|
|
2348
2725
|
}
|
|
2349
2726
|
}), React.createElement("g", {
|
|
2350
2727
|
className: "handleGroup"
|
|
2351
2728
|
}, isDateChangeable && React.createElement("g", null, React.createElement(BarDateHandle, {
|
|
2352
|
-
x:
|
|
2729
|
+
x: plannedLeftHandleX + 1,
|
|
2353
2730
|
y: task.y + 1,
|
|
2354
2731
|
width: task.handleWidth,
|
|
2355
2732
|
height: handleHeight,
|
|
@@ -2358,7 +2735,7 @@ var Bar = function Bar(_ref) {
|
|
|
2358
2735
|
onEventStart("start", task, e, "planned");
|
|
2359
2736
|
}
|
|
2360
2737
|
}), React.createElement(BarDateHandle, {
|
|
2361
|
-
x:
|
|
2738
|
+
x: plannedRightHandleX - task.handleWidth - 1,
|
|
2362
2739
|
y: task.y + 1,
|
|
2363
2740
|
width: task.handleWidth,
|
|
2364
2741
|
height: handleHeight,
|
|
@@ -2379,7 +2756,13 @@ var Bar = function Bar(_ref) {
|
|
|
2379
2756
|
return React.createElement("g", {
|
|
2380
2757
|
className: styles$7.barWrapper,
|
|
2381
2758
|
tabIndex: 0
|
|
2382
|
-
}, React.createElement(
|
|
2759
|
+
}, React.createElement("rect", {
|
|
2760
|
+
x: task.actualx1,
|
|
2761
|
+
y: task.y + task.height / 2,
|
|
2762
|
+
width: task.actualx2 - task.actualx1,
|
|
2763
|
+
height: task.height / 2,
|
|
2764
|
+
fill: "transparent"
|
|
2765
|
+
}), React.createElement(BarDisplay, {
|
|
2383
2766
|
x: task.actualx1,
|
|
2384
2767
|
y: task.y + task.height / 2,
|
|
2385
2768
|
type: type,
|
|
@@ -2392,13 +2775,14 @@ var Bar = function Bar(_ref) {
|
|
|
2392
2775
|
barCornerRadius: task.barCornerRadius,
|
|
2393
2776
|
styles: task.styles,
|
|
2394
2777
|
isSelected: isSelected,
|
|
2778
|
+
segments: task.actualSegments,
|
|
2395
2779
|
onMouseDown: function onMouseDown(e) {
|
|
2396
2780
|
isDateChangeable && onEventStart("move", task, e, "actual");
|
|
2397
2781
|
}
|
|
2398
2782
|
}), React.createElement("g", {
|
|
2399
2783
|
className: "handleGroup"
|
|
2400
2784
|
}, isDateChangeable && React.createElement("g", null, React.createElement(BarDateHandle, {
|
|
2401
|
-
x:
|
|
2785
|
+
x: actualLeftHandleX + 1,
|
|
2402
2786
|
y: task.y + task.height / 2 + 1,
|
|
2403
2787
|
width: task.handleWidth,
|
|
2404
2788
|
height: handleHeight,
|
|
@@ -2407,7 +2791,7 @@ var Bar = function Bar(_ref) {
|
|
|
2407
2791
|
onEventStart("start", task, e, "actual");
|
|
2408
2792
|
}
|
|
2409
2793
|
}), React.createElement(BarDateHandle, {
|
|
2410
|
-
x:
|
|
2794
|
+
x: actualRightHandleX - task.handleWidth - 1,
|
|
2411
2795
|
y: task.y + task.height / 2 + 1,
|
|
2412
2796
|
width: task.handleWidth,
|
|
2413
2797
|
height: handleHeight,
|
|
@@ -2674,6 +3058,8 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2674
3058
|
onDoubleClick = _ref.onDoubleClick,
|
|
2675
3059
|
onClick = _ref.onClick,
|
|
2676
3060
|
onDelete = _ref.onDelete,
|
|
3061
|
+
onCalendarError = _ref.onCalendarError,
|
|
3062
|
+
projectCalendar = _ref.projectCalendar,
|
|
2677
3063
|
visibleStartY = _ref.visibleStartY,
|
|
2678
3064
|
visibleEndY = _ref.visibleEndY;
|
|
2679
3065
|
var point = svg === null || svg === void 0 ? void 0 : (_svg$current = svg.current) === null || _svg$current === void 0 ? void 0 : _svg$current.createSVGPoint();
|
|
@@ -2710,9 +3096,35 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2710
3096
|
changedTask = _handleTaskBySVGMouse.changedTask;
|
|
2711
3097
|
|
|
2712
3098
|
if (isChanged) {
|
|
3099
|
+
var finalTask = changedTask;
|
|
3100
|
+
|
|
3101
|
+
if (changedTask.calender && (ganttEvent.action === "end" || ganttEvent.action === "start" || ganttEvent.action === "move")) {
|
|
3102
|
+
finalTask = _extends({}, changedTask);
|
|
3103
|
+
var cal = finalTask.calender;
|
|
3104
|
+
|
|
3105
|
+
if (ganttEvent.action === "end") {
|
|
3106
|
+
var snapped = snapToWorkingTime(finalTask.end, cal, "forward");
|
|
3107
|
+
finalTask.end = snapped;
|
|
3108
|
+
finalTask.x2 = taskXCoordinate(snapped, dates, columnWidth);
|
|
3109
|
+
} else if (ganttEvent.action === "start") {
|
|
3110
|
+
var _snapped = snapToWorkingTime(finalTask.start, cal, "forward");
|
|
3111
|
+
|
|
3112
|
+
finalTask.start = _snapped;
|
|
3113
|
+
finalTask.x1 = taskXCoordinate(_snapped, dates, columnWidth);
|
|
3114
|
+
} else {
|
|
3115
|
+
var _snapped2 = snapToWorkingTime(finalTask.start, cal, "forward");
|
|
3116
|
+
|
|
3117
|
+
var delta = _snapped2.getTime() - finalTask.start.getTime();
|
|
3118
|
+
finalTask.start = _snapped2;
|
|
3119
|
+
finalTask.end = new Date(finalTask.end.getTime() + delta);
|
|
3120
|
+
finalTask.x1 = taskXCoordinate(finalTask.start, dates, columnWidth);
|
|
3121
|
+
finalTask.x2 = taskXCoordinate(finalTask.end, dates, columnWidth);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
|
|
2713
3125
|
setGanttEvent({
|
|
2714
3126
|
action: ganttEvent.action,
|
|
2715
|
-
changedTask:
|
|
3127
|
+
changedTask: finalTask
|
|
2716
3128
|
});
|
|
2717
3129
|
}
|
|
2718
3130
|
|
|
@@ -2745,6 +3157,54 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2745
3157
|
newChangedTask = _handleTaskBySVGMouse2.changedTask;
|
|
2746
3158
|
|
|
2747
3159
|
var isNotLikeOriginal = originalSelectedTask.start !== newChangedTask.start || originalSelectedTask.end !== newChangedTask.end || originalSelectedTask.actualStart !== newChangedTask.actualStart || originalSelectedTask.actualEnd !== newChangedTask.actualEnd || originalSelectedTask.progress !== newChangedTask.progress;
|
|
3160
|
+
|
|
3161
|
+
if (newChangedTask.calender && (action === "move" || action === "end" || action === "start")) {
|
|
3162
|
+
var cal = newChangedTask.calender;
|
|
3163
|
+
|
|
3164
|
+
if (action === "end") {
|
|
3165
|
+
var snappedEnd = snapToWorkingTime(newChangedTask.end, cal, "forward");
|
|
3166
|
+
newChangedTask.end = snappedEnd;
|
|
3167
|
+
newChangedTask.x2 = taskXCoordinate(snappedEnd, dates, columnWidth);
|
|
3168
|
+
} else if (action === "start") {
|
|
3169
|
+
var snappedStart = snapToWorkingTime(newChangedTask.start, cal, "forward");
|
|
3170
|
+
|
|
3171
|
+
if (snappedStart >= newChangedTask.end) {
|
|
3172
|
+
setFailedTask(originalSelectedTask);
|
|
3173
|
+
onCalendarError === null || onCalendarError === void 0 ? void 0 : onCalendarError(newChangedTask, "No working time in selected range");
|
|
3174
|
+
setGanttEvent({
|
|
3175
|
+
action: ""
|
|
3176
|
+
});
|
|
3177
|
+
setIsMoving(false);
|
|
3178
|
+
svg.current.removeEventListener("mousemove", handleMouseMove);
|
|
3179
|
+
svg.current.removeEventListener("mouseup", handleMouseUp);
|
|
3180
|
+
return Promise.resolve();
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
newChangedTask.start = snappedStart;
|
|
3184
|
+
newChangedTask.x1 = taskXCoordinate(snappedStart, dates, columnWidth);
|
|
3185
|
+
} else {
|
|
3186
|
+
var _snappedStart = snapToWorkingTime(newChangedTask.start, cal, "forward");
|
|
3187
|
+
|
|
3188
|
+
var delta = _snappedStart.getTime() - newChangedTask.start.getTime();
|
|
3189
|
+
newChangedTask.start = _snappedStart;
|
|
3190
|
+
newChangedTask.end = new Date(newChangedTask.end.getTime() + delta);
|
|
3191
|
+
newChangedTask.x1 = taskXCoordinate(_snappedStart, dates, columnWidth);
|
|
3192
|
+
newChangedTask.x2 = taskXCoordinate(newChangedTask.end, dates, columnWidth);
|
|
3193
|
+
}
|
|
3194
|
+
|
|
3195
|
+
var snapEnd = addToDate(startOfDate(newChangedTask.end, "day"), 1, "day");
|
|
3196
|
+
var newIntervals = getWorkingIntervals(newChangedTask.start, snapEnd, cal);
|
|
3197
|
+
var segs = newIntervals.map(function (iv) {
|
|
3198
|
+
return {
|
|
3199
|
+
x1: taskXCoordinate(iv.start, dates, columnWidth),
|
|
3200
|
+
x2: taskXCoordinate(iv.end, dates, columnWidth)
|
|
3201
|
+
};
|
|
3202
|
+
}).filter(function (s) {
|
|
3203
|
+
return s.x2 > s.x1;
|
|
3204
|
+
});
|
|
3205
|
+
newChangedTask.plannedSegments = segs.length > 0 ? segs : undefined;
|
|
3206
|
+
}
|
|
3207
|
+
|
|
2748
3208
|
svg.current.removeEventListener("mousemove", handleMouseMove);
|
|
2749
3209
|
svg.current.removeEventListener("mouseup", handleMouseUp);
|
|
2750
3210
|
setGanttEvent({
|
|
@@ -2798,7 +3258,7 @@ var TaskGanttContent = function TaskGanttContent(_ref) {
|
|
|
2798
3258
|
svg.current.addEventListener("mouseup", handleMouseUp);
|
|
2799
3259
|
setIsMoving(true);
|
|
2800
3260
|
}
|
|
2801
|
-
}, [ganttEvent, xStep, initEventX1Delta, onProgressChange, timeStep, onDateChange, svg, isMoving, point, rtl, setFailedTask, setGanttEvent]);
|
|
3261
|
+
}, [ganttEvent, xStep, initEventX1Delta, onProgressChange, timeStep, onDateChange, onCalendarError, projectCalendar, svg, isMoving, point, rtl, setFailedTask, setGanttEvent, dates, columnWidth]);
|
|
2802
3262
|
|
|
2803
3263
|
var handleBarEventStart = function handleBarEventStart(action, task, event, type) {
|
|
2804
3264
|
try {
|
|
@@ -3093,6 +3553,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
|
|
|
3093
3553
|
};
|
|
3094
3554
|
|
|
3095
3555
|
var Gantt = function Gantt(_ref) {
|
|
3556
|
+
var _tasks$find$calender, _tasks$find;
|
|
3557
|
+
|
|
3096
3558
|
var tasks = _ref.tasks,
|
|
3097
3559
|
_ref$leafTasks = _ref.leafTasks,
|
|
3098
3560
|
leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
|
|
@@ -3159,7 +3621,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3159
3621
|
_ref$todayColor = _ref.todayColor,
|
|
3160
3622
|
todayColor = _ref$todayColor === void 0 ? "rgba(252, 248, 227, 0.5)" : _ref$todayColor,
|
|
3161
3623
|
_ref$weekendColor = _ref.weekendColor,
|
|
3162
|
-
weekendColor = _ref$weekendColor === void 0 ? "#
|
|
3624
|
+
weekendColor = _ref$weekendColor === void 0 ? "#e6e4e4" : _ref$weekendColor,
|
|
3163
3625
|
viewDate = _ref.viewDate,
|
|
3164
3626
|
_ref$TooltipContent = _ref.TooltipContent,
|
|
3165
3627
|
TooltipContent = _ref$TooltipContent === void 0 ? StandardTooltipContent : _ref$TooltipContent,
|
|
@@ -3179,7 +3641,12 @@ var Gantt = function Gantt(_ref) {
|
|
|
3179
3641
|
_ref$delayToRender = _ref.delayToRender,
|
|
3180
3642
|
delayToRender = _ref$delayToRender === void 0 ? 500 : _ref$delayToRender,
|
|
3181
3643
|
_ref$shouldNotShowLoa = _ref.shouldNotShowLoadingOverlay,
|
|
3182
|
-
shouldNotShowLoadingOverlay = _ref$shouldNotShowLoa === void 0 ? true : _ref$shouldNotShowLoa
|
|
3644
|
+
shouldNotShowLoadingOverlay = _ref$shouldNotShowLoa === void 0 ? true : _ref$shouldNotShowLoa,
|
|
3645
|
+
projectCalendar = _ref.projectCalendar,
|
|
3646
|
+
onCalendarError = _ref.onCalendarError;
|
|
3647
|
+
var effectiveCalendar = (_tasks$find$calender = (_tasks$find = tasks.find(function (t) {
|
|
3648
|
+
return t.calender;
|
|
3649
|
+
})) === null || _tasks$find === void 0 ? void 0 : _tasks$find.calender) != null ? _tasks$find$calender : projectCalendar;
|
|
3183
3650
|
var wrapperRef = useRef(null);
|
|
3184
3651
|
var taskListRef = useRef(null);
|
|
3185
3652
|
var isDraggingTable = useRef(false);
|
|
@@ -3294,7 +3761,11 @@ var Gantt = function Gantt(_ref) {
|
|
|
3294
3761
|
failedTask = _useState11[0],
|
|
3295
3762
|
setFailedTask = _useState11[1];
|
|
3296
3763
|
|
|
3297
|
-
var
|
|
3764
|
+
var effectiveColumnWidth = useMemo(function () {
|
|
3765
|
+
if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
|
|
3766
|
+
return Math.max(columnWidth, Math.ceil(svgContainerWidth / dateSetup.dates.length));
|
|
3767
|
+
}, [columnWidth, svgContainerWidth, dateSetup.dates.length]);
|
|
3768
|
+
var svgWidth = effectiveColumnWidth < 55 ? (dateSetup.dates.length + 0.5) * effectiveColumnWidth : dateSetup.dates.length * effectiveColumnWidth;
|
|
3298
3769
|
var ganttFullHeight = useMemo(function () {
|
|
3299
3770
|
return barTasks.length * rowHeight;
|
|
3300
3771
|
}, [barTasks.length, rowHeight]);
|
|
@@ -3344,11 +3815,13 @@ var Gantt = function Gantt(_ref) {
|
|
|
3344
3815
|
}
|
|
3345
3816
|
|
|
3346
3817
|
debounceRef.current = setTimeout(function () {
|
|
3818
|
+
var _effectiveCalendar$qu;
|
|
3819
|
+
|
|
3347
3820
|
var filteredTasks;
|
|
3348
3821
|
filteredTasks = removeHiddenTasks(tasks);
|
|
3349
3822
|
filteredTasks = filteredTasks.sort(sortTasks);
|
|
3350
3823
|
|
|
3351
|
-
var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount),
|
|
3824
|
+
var _ganttDateRange2 = ganttDateRange(filteredTasks, viewMode, preStepsCount, (_effectiveCalendar$qu = effectiveCalendar === null || effectiveCalendar === void 0 ? void 0 : effectiveCalendar.quarter_start) != null ? _effectiveCalendar$qu : 0),
|
|
3352
3825
|
startDateRange = _ganttDateRange2[0],
|
|
3353
3826
|
endDateRange = _ganttDateRange2[1];
|
|
3354
3827
|
|
|
@@ -3362,7 +3835,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3362
3835
|
newDates = newDates.reverse();
|
|
3363
3836
|
|
|
3364
3837
|
if (scrollX === -1) {
|
|
3365
|
-
setScrollX(newDates.length *
|
|
3838
|
+
setScrollX(newDates.length * effectiveColumnWidth);
|
|
3366
3839
|
}
|
|
3367
3840
|
}
|
|
3368
3841
|
|
|
@@ -3384,10 +3857,10 @@ var Gantt = function Gantt(_ref) {
|
|
|
3384
3857
|
colorPath(primaryPath, "#ff0000", tasks, "primary");
|
|
3385
3858
|
}
|
|
3386
3859
|
|
|
3387
|
-
setBarTasks(convertToBarTasks(filteredTasks, newDates,
|
|
3860
|
+
setBarTasks(convertToBarTasks(filteredTasks, newDates, effectiveColumnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor));
|
|
3388
3861
|
setIsProcessing(false);
|
|
3389
3862
|
}, delayToRender);
|
|
3390
|
-
}, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius,
|
|
3863
|
+
}, [tasks, viewMode, preStepsCount, rowHeight, barCornerRadius, taskHeight, handleWidth, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor, rtl, shouldNotShowLoadingOverlay, effectiveColumnWidth, effectiveCalendar]);
|
|
3391
3864
|
useEffect(function () {
|
|
3392
3865
|
return function () {
|
|
3393
3866
|
clearTimeout(debounceRef.current);
|
|
@@ -3405,9 +3878,9 @@ var Gantt = function Gantt(_ref) {
|
|
|
3405
3878
|
}
|
|
3406
3879
|
|
|
3407
3880
|
setCurrentViewDate(viewDate);
|
|
3408
|
-
setScrollX(
|
|
3881
|
+
setScrollX(effectiveColumnWidth * index);
|
|
3409
3882
|
}
|
|
3410
|
-
}, [viewDate,
|
|
3883
|
+
}, [viewDate, effectiveColumnWidth, dateSetup.dates, dateSetup.viewMode, viewMode, currentViewDate, setCurrentViewDate]);
|
|
3411
3884
|
useEffect(function () {
|
|
3412
3885
|
var changedTask = ganttEvent.changedTask,
|
|
3413
3886
|
action = ganttEvent.action;
|
|
@@ -3453,7 +3926,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3453
3926
|
}, [taskListRef, listCellWidth]);
|
|
3454
3927
|
useEffect(function () {
|
|
3455
3928
|
if (wrapperRef.current) {
|
|
3456
|
-
setSvgContainerWidth(wrapperRef.current.offsetWidth - taskListWidth);
|
|
3929
|
+
setSvgContainerWidth(wrapperRef.current.offsetWidth - taskListWidth - 20);
|
|
3457
3930
|
}
|
|
3458
3931
|
}, [wrapperRef, taskListWidth]);
|
|
3459
3932
|
useEffect(function () {
|
|
@@ -3599,12 +4072,12 @@ var Gantt = function Gantt(_ref) {
|
|
|
3599
4072
|
|
|
3600
4073
|
case "Left":
|
|
3601
4074
|
case "ArrowLeft":
|
|
3602
|
-
newScrollX -=
|
|
4075
|
+
newScrollX -= effectiveColumnWidth;
|
|
3603
4076
|
break;
|
|
3604
4077
|
|
|
3605
4078
|
case "Right":
|
|
3606
4079
|
case "ArrowRight":
|
|
3607
|
-
newScrollX +=
|
|
4080
|
+
newScrollX += effectiveColumnWidth;
|
|
3608
4081
|
break;
|
|
3609
4082
|
}
|
|
3610
4083
|
|
|
@@ -3659,7 +4132,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3659
4132
|
};
|
|
3660
4133
|
|
|
3661
4134
|
var gridProps = {
|
|
3662
|
-
columnWidth:
|
|
4135
|
+
columnWidth: effectiveColumnWidth,
|
|
3663
4136
|
svgWidth: svgWidth,
|
|
3664
4137
|
tasks: tasks,
|
|
3665
4138
|
scheduleType: scheduleType,
|
|
@@ -3669,17 +4142,20 @@ var Gantt = function Gantt(_ref) {
|
|
|
3669
4142
|
weekendColor: weekendColor,
|
|
3670
4143
|
rtl: rtl,
|
|
3671
4144
|
visibleStartY: visibleStartY,
|
|
3672
|
-
visibleEndY: visibleEndY
|
|
4145
|
+
visibleEndY: visibleEndY,
|
|
4146
|
+
projectCalendar: effectiveCalendar,
|
|
4147
|
+
viewMode: viewMode
|
|
3673
4148
|
};
|
|
3674
4149
|
var calendarProps = {
|
|
3675
4150
|
dateSetup: dateSetup,
|
|
3676
4151
|
locale: locale,
|
|
3677
4152
|
viewMode: viewMode,
|
|
3678
4153
|
headerHeight: headerHeight,
|
|
3679
|
-
columnWidth:
|
|
4154
|
+
columnWidth: effectiveColumnWidth,
|
|
3680
4155
|
fontFamily: fontFamily,
|
|
3681
4156
|
fontSize: fontSize,
|
|
3682
|
-
rtl: rtl
|
|
4157
|
+
rtl: rtl,
|
|
4158
|
+
projectCalendar: effectiveCalendar
|
|
3683
4159
|
};
|
|
3684
4160
|
var barProps = {
|
|
3685
4161
|
tasks: barTasks,
|
|
@@ -3688,7 +4164,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3688
4164
|
selectedTask: selectedTask,
|
|
3689
4165
|
rowHeight: rowHeight,
|
|
3690
4166
|
taskHeight: taskHeight,
|
|
3691
|
-
columnWidth:
|
|
4167
|
+
columnWidth: effectiveColumnWidth,
|
|
3692
4168
|
arrowColor: arrowColor,
|
|
3693
4169
|
timeStep: timeStep,
|
|
3694
4170
|
fontFamily: fontFamily,
|
|
@@ -3704,6 +4180,8 @@ var Gantt = function Gantt(_ref) {
|
|
|
3704
4180
|
onDoubleClick: onDoubleClick,
|
|
3705
4181
|
onClick: onClick,
|
|
3706
4182
|
onDelete: onDelete,
|
|
4183
|
+
onCalendarError: onCalendarError,
|
|
4184
|
+
projectCalendar: effectiveCalendar,
|
|
3707
4185
|
visibleStartY: visibleStartY,
|
|
3708
4186
|
visibleEndY: visibleEndY
|
|
3709
4187
|
};
|