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