@worktile/gantt 12.2.3 → 13.0.0
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/components/bar/bar.component.scss +201 -0
- package/components/calendar/calendar.component.scss +79 -0
- package/components/drag-backdrop/drag-backdrop.component.scss +50 -0
- package/components/icon/icon.component.scss +13 -0
- package/components/links/links.component.scss +29 -0
- package/components/range/range.component.scss +35 -0
- package/components/table/gantt-table.component.scss +153 -0
- package/{esm2015/class/date-point.js → esm2020/class/date-point.mjs} +0 -0
- package/{esm2015/class/event.js → esm2020/class/event.mjs} +0 -0
- package/{esm2015/class/group.js → esm2020/class/group.mjs} +0 -0
- package/{esm2015/class/index.js → esm2020/class/index.mjs} +0 -0
- package/{esm2015/class/item.js → esm2020/class/item.mjs} +0 -0
- package/{esm2015/class/link.js → esm2020/class/link.mjs} +0 -0
- package/{esm2015/class/view-type.js → esm2020/class/view-type.mjs} +0 -0
- package/esm2020/components/bar/bar-drag.mjs +308 -0
- package/{esm2015/components/bar/bar.component.js → esm2020/components/bar/bar.component.mjs} +5 -9
- package/{esm2015/components/calendar/calendar.component.js → esm2020/components/calendar/calendar.component.mjs} +5 -8
- package/{esm2015/components/drag-backdrop/drag-backdrop.component.js → esm2020/components/drag-backdrop/drag-backdrop.component.mjs} +6 -10
- package/{esm2015/components/icon/icon.component.js → esm2020/components/icon/icon.component.mjs} +3 -3
- package/{esm2015/components/icon/icons.js → esm2020/components/icon/icons.mjs} +0 -0
- package/esm2020/components/links/lines/curve.mjs +95 -0
- package/{esm2015/components/links/lines/factory.js → esm2020/components/links/lines/factory.mjs} +0 -0
- package/{esm2015/components/links/lines/line.js → esm2020/components/links/lines/line.mjs} +0 -0
- package/{esm2015/components/links/lines/straight.js → esm2020/components/links/lines/straight.mjs} +0 -0
- package/esm2020/components/links/links.component.mjs +178 -0
- package/{esm2015/components/main/gantt-main.component.js → esm2020/components/main/gantt-main.component.mjs} +5 -8
- package/{esm2015/components/range/range.component.js → esm2020/components/range/range.component.mjs} +5 -8
- package/esm2020/components/table/gantt-table.component.mjs +161 -0
- package/{esm2015/gantt-abstract.js → esm2020/gantt-abstract.mjs} +0 -0
- package/{esm2015/gantt-dom.service.js → esm2020/gantt-dom.service.mjs} +3 -3
- package/{esm2015/gantt-drag-container.js → esm2020/gantt-drag-container.mjs} +5 -6
- package/{esm2015/gantt-item-upper.js → esm2020/gantt-item-upper.mjs} +4 -4
- package/esm2020/gantt-print.service.mjs +94 -0
- package/esm2020/gantt-upper.mjs +339 -0
- package/{esm2015/gantt.component.js → esm2020/gantt.component.mjs} +7 -13
- package/{esm2015/gantt.config.js → esm2020/gantt.config.mjs} +0 -0
- package/{esm2015/gantt.module.js → esm2020/gantt.module.mjs} +4 -4
- package/{esm2015/gantt.pipe.js → esm2020/gantt.pipe.mjs} +9 -9
- package/{esm2015/gantt.styles.js → esm2020/gantt.styles.mjs} +0 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
- package/{esm2015/root.component.js → esm2020/root.component.mjs} +6 -11
- package/{esm2015/table/gantt-column.component.js → esm2020/table/gantt-column.component.mjs} +3 -3
- package/{esm2015/table/gantt-table.component.js → esm2020/table/gantt-table.component.mjs} +3 -3
- package/{esm2015/utils/date.js → esm2020/utils/date.mjs} +0 -0
- package/{esm2015/utils/helpers.js → esm2020/utils/helpers.mjs} +0 -0
- package/{esm2015/utils/passive-listeners.js → esm2020/utils/passive-listeners.mjs} +0 -0
- package/{esm2015/utils/set-style-with-vendor-prefix.js → esm2020/utils/set-style-with-vendor-prefix.mjs} +0 -0
- package/{esm2015/views/day.js → esm2020/views/day.mjs} +0 -0
- package/{esm2015/views/factory.js → esm2020/views/factory.mjs} +0 -0
- package/{esm2015/views/month.js → esm2020/views/month.mjs} +0 -0
- package/{esm2015/views/quarter.js → esm2020/views/quarter.mjs} +0 -0
- package/{esm2015/views/view.js → esm2020/views/view.mjs} +5 -5
- package/{esm2015/views/week.js → esm2020/views/week.mjs} +0 -0
- package/{esm2015/views/year.js → esm2020/views/year.mjs} +0 -0
- package/{esm2015/worktile-gantt.js → esm2020/worktile-gantt.mjs} +0 -0
- package/fesm2015/worktile-gantt.mjs +3078 -0
- package/fesm2015/worktile-gantt.mjs.map +1 -0
- package/{fesm2015/worktile-gantt.js → fesm2020/worktile-gantt.mjs} +159 -191
- package/fesm2020/worktile-gantt.mjs.map +1 -0
- package/gantt-item-upper.d.ts +1 -1
- package/gantt-upper.d.ts +1 -1
- package/gantt.component.scss +83 -0
- package/package.json +35 -9
- package/styles/index.scss +9 -0
- package/styles/variables.scss +46 -0
- package/bundles/worktile-gantt.umd.js +0 -3723
- package/bundles/worktile-gantt.umd.js.map +0 -1
- package/esm2015/components/bar/bar-drag.js +0 -306
- package/esm2015/components/links/lines/curve.js +0 -96
- package/esm2015/components/links/links.component.js +0 -173
- package/esm2015/components/table/gantt-table.component.js +0 -167
- package/esm2015/gantt-print.service.js +0 -97
- package/esm2015/gantt-upper.js +0 -340
- package/fesm2015/worktile-gantt.js.map +0 -1
- package/main.bundle.scss +0 -688
|
@@ -0,0 +1,3078 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Pipe, ViewChild, PLATFORM_ID, Injectable, ElementRef, Optional, SkipSelf, ViewChildren, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
|
|
3
|
+
import * as i2 from '@angular/common';
|
|
4
|
+
import { isPlatformServer, CommonModule } from '@angular/common';
|
|
5
|
+
import { take, takeUntil, skip, map, pairwise, auditTime, startWith, debounceTime, switchMap, finalize } from 'rxjs/operators';
|
|
6
|
+
import { BehaviorSubject, Subject, from, merge, fromEvent, Observable, EMPTY } from 'rxjs';
|
|
7
|
+
import { fromUnixTime, getWeek, getDaysInMonth, differenceInCalendarDays, setDate, addSeconds, addMinutes, addHours, addDays, addWeeks, addMonths, addQuarters, addYears, startOfDay, startOfWeek, startOfMonth, startOfQuarter, startOfYear, endOfDay, endOfWeek, endOfMonth, endOfQuarter, endOfYear, getUnixTime, format, isWeekend, isToday, differenceInDays, differenceInCalendarQuarters, eachMonthOfInterval, eachYearOfInterval, eachWeekOfInterval, eachDayOfInterval, differenceInCalendarYears } from 'date-fns';
|
|
8
|
+
export { addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarQuarters, differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, endOfDay, endOfMonth, endOfQuarter, endOfWeek, endOfYear, format, fromUnixTime, getDaysInMonth, getUnixTime, getWeek, isToday, isWeekend, setDate, startOfDay, startOfMonth, startOfQuarter, startOfWeek, startOfYear } from 'date-fns';
|
|
9
|
+
import { SelectionModel } from '@angular/cdk/collections';
|
|
10
|
+
import { coerceBooleanProperty, coerceCssPixelValue } from '@angular/cdk/coercion';
|
|
11
|
+
import * as i1 from '@angular/cdk/drag-drop';
|
|
12
|
+
import { DragDropModule } from '@angular/cdk/drag-drop';
|
|
13
|
+
import { __awaiter, __decorate, __param } from 'tslib';
|
|
14
|
+
|
|
15
|
+
class GanttDatePoint {
|
|
16
|
+
constructor(start, text, x, y, additions) {
|
|
17
|
+
this.start = start;
|
|
18
|
+
this.text = text;
|
|
19
|
+
this.x = x;
|
|
20
|
+
this.y = y;
|
|
21
|
+
this.additions = additions;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class GanttDragEvent {
|
|
26
|
+
}
|
|
27
|
+
class GanttTableEvent {
|
|
28
|
+
}
|
|
29
|
+
class GanttLinkDragEvent {
|
|
30
|
+
}
|
|
31
|
+
class GanttLoadOnScrollEvent {
|
|
32
|
+
}
|
|
33
|
+
class GanttLineClickEvent {
|
|
34
|
+
}
|
|
35
|
+
class GanttBarClickEvent {
|
|
36
|
+
}
|
|
37
|
+
class GanttSelectedEvent {
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class GanttDate {
|
|
41
|
+
constructor(date) {
|
|
42
|
+
if (date) {
|
|
43
|
+
if (date instanceof Date) {
|
|
44
|
+
this.value = date;
|
|
45
|
+
}
|
|
46
|
+
else if (typeof date === 'string' || typeof date === 'number') {
|
|
47
|
+
if (date.toString().length < 13) {
|
|
48
|
+
this.value = fromUnixTime(+date);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.value = new Date(date);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error(`The input date type is not supported expect Date | string
|
|
56
|
+
| number | { date: number; with_time: 0 | 1}, actual ${JSON.stringify(date)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.value = new Date();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
getYear() {
|
|
64
|
+
return this.value.getFullYear();
|
|
65
|
+
}
|
|
66
|
+
getMonth() {
|
|
67
|
+
return this.value.getMonth();
|
|
68
|
+
}
|
|
69
|
+
getDay() {
|
|
70
|
+
return this.value.getDay();
|
|
71
|
+
}
|
|
72
|
+
getTime() {
|
|
73
|
+
return this.value.getTime();
|
|
74
|
+
}
|
|
75
|
+
getDate() {
|
|
76
|
+
return this.value.getDate();
|
|
77
|
+
}
|
|
78
|
+
getHours() {
|
|
79
|
+
return this.value.getHours();
|
|
80
|
+
}
|
|
81
|
+
getMinutes() {
|
|
82
|
+
return this.value.getMinutes();
|
|
83
|
+
}
|
|
84
|
+
getSeconds() {
|
|
85
|
+
return this.value.getSeconds();
|
|
86
|
+
}
|
|
87
|
+
getMilliseconds() {
|
|
88
|
+
return this.value.getMilliseconds();
|
|
89
|
+
}
|
|
90
|
+
getWeek(options = { weekStartsOn: 1 }) {
|
|
91
|
+
return getWeek(this.value, options);
|
|
92
|
+
}
|
|
93
|
+
getDaysInMonth() {
|
|
94
|
+
return getDaysInMonth(this.value);
|
|
95
|
+
}
|
|
96
|
+
getDaysInQuarter() {
|
|
97
|
+
return differenceInCalendarDays(this.endOfQuarter().addSeconds(1).value, this.startOfQuarter().value);
|
|
98
|
+
}
|
|
99
|
+
getDaysInYear() {
|
|
100
|
+
return differenceInCalendarDays(this.endOfYear().addSeconds(1).value, this.startOfYear().value);
|
|
101
|
+
}
|
|
102
|
+
setDate(dayOfMonth) {
|
|
103
|
+
return new GanttDate(setDate(this.value, dayOfMonth));
|
|
104
|
+
}
|
|
105
|
+
clone() {
|
|
106
|
+
return new GanttDate(new Date(this.value));
|
|
107
|
+
}
|
|
108
|
+
add(amount, unit) {
|
|
109
|
+
switch (unit) {
|
|
110
|
+
case 'second':
|
|
111
|
+
return new GanttDate(this.value).addSeconds(amount);
|
|
112
|
+
case 'minute':
|
|
113
|
+
return new GanttDate(this.value).addMinutes(amount);
|
|
114
|
+
case 'hour':
|
|
115
|
+
return new GanttDate(this.value).addHours(amount);
|
|
116
|
+
case 'day':
|
|
117
|
+
return new GanttDate(this.value).addDays(amount);
|
|
118
|
+
case 'week':
|
|
119
|
+
return new GanttDate(this.value).addWeeks(amount);
|
|
120
|
+
case 'month':
|
|
121
|
+
return new GanttDate(this.value).addMonths(amount);
|
|
122
|
+
case 'quarter':
|
|
123
|
+
return new GanttDate(this.value).addQuarters(amount);
|
|
124
|
+
case 'year':
|
|
125
|
+
return new GanttDate(this.value).addYears(amount);
|
|
126
|
+
default:
|
|
127
|
+
return new GanttDate(this.value).addSeconds(amount);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
addSeconds(amount) {
|
|
131
|
+
return new GanttDate(addSeconds(this.value, amount));
|
|
132
|
+
}
|
|
133
|
+
addMinutes(amount) {
|
|
134
|
+
return new GanttDate(addMinutes(this.value, amount));
|
|
135
|
+
}
|
|
136
|
+
addHours(amount) {
|
|
137
|
+
return new GanttDate(addHours(this.value, amount));
|
|
138
|
+
}
|
|
139
|
+
addDays(amount) {
|
|
140
|
+
return new GanttDate(addDays(this.value, amount));
|
|
141
|
+
}
|
|
142
|
+
addWeeks(amount) {
|
|
143
|
+
return new GanttDate(addWeeks(this.value, amount));
|
|
144
|
+
}
|
|
145
|
+
addMonths(amount) {
|
|
146
|
+
return new GanttDate(addMonths(this.value, amount));
|
|
147
|
+
}
|
|
148
|
+
addQuarters(amount) {
|
|
149
|
+
return new GanttDate(addQuarters(this.value, amount));
|
|
150
|
+
}
|
|
151
|
+
addYears(amount) {
|
|
152
|
+
return new GanttDate(addYears(this.value, amount));
|
|
153
|
+
}
|
|
154
|
+
startOfDay() {
|
|
155
|
+
return new GanttDate(startOfDay(this.value));
|
|
156
|
+
}
|
|
157
|
+
startOfWeek(options) {
|
|
158
|
+
return new GanttDate(startOfWeek(this.value, options));
|
|
159
|
+
}
|
|
160
|
+
startOfMonth() {
|
|
161
|
+
return new GanttDate(startOfMonth(this.value));
|
|
162
|
+
}
|
|
163
|
+
startOfQuarter() {
|
|
164
|
+
return new GanttDate(startOfQuarter(this.value));
|
|
165
|
+
}
|
|
166
|
+
startOfYear() {
|
|
167
|
+
return new GanttDate(startOfYear(this.value));
|
|
168
|
+
}
|
|
169
|
+
endOfDay() {
|
|
170
|
+
return new GanttDate(endOfDay(this.value));
|
|
171
|
+
}
|
|
172
|
+
endOfWeek(options) {
|
|
173
|
+
return new GanttDate(endOfWeek(this.value, options));
|
|
174
|
+
}
|
|
175
|
+
endOfMonth() {
|
|
176
|
+
return new GanttDate(endOfMonth(this.value));
|
|
177
|
+
}
|
|
178
|
+
endOfQuarter() {
|
|
179
|
+
return new GanttDate(endOfQuarter(this.value));
|
|
180
|
+
}
|
|
181
|
+
endOfYear() {
|
|
182
|
+
return new GanttDate(endOfYear(this.value));
|
|
183
|
+
}
|
|
184
|
+
getUnixTime() {
|
|
185
|
+
return getUnixTime(this.value);
|
|
186
|
+
}
|
|
187
|
+
format(mat, options) {
|
|
188
|
+
return format(this.value, mat, options);
|
|
189
|
+
}
|
|
190
|
+
isWeekend() {
|
|
191
|
+
return isWeekend(this.value);
|
|
192
|
+
}
|
|
193
|
+
isToday() {
|
|
194
|
+
return isToday(this.value);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
var GanttViewType;
|
|
199
|
+
(function (GanttViewType) {
|
|
200
|
+
GanttViewType["day"] = "day";
|
|
201
|
+
GanttViewType["quarter"] = "quarter";
|
|
202
|
+
GanttViewType["month"] = "month";
|
|
203
|
+
GanttViewType["year"] = "year";
|
|
204
|
+
GanttViewType["week"] = "week";
|
|
205
|
+
})(GanttViewType || (GanttViewType = {}));
|
|
206
|
+
|
|
207
|
+
var GanttLinkType;
|
|
208
|
+
(function (GanttLinkType) {
|
|
209
|
+
GanttLinkType[GanttLinkType["fs"] = 1] = "fs";
|
|
210
|
+
GanttLinkType[GanttLinkType["ff"] = 2] = "ff";
|
|
211
|
+
GanttLinkType[GanttLinkType["ss"] = 3] = "ss";
|
|
212
|
+
GanttLinkType[GanttLinkType["sf"] = 4] = "sf";
|
|
213
|
+
})(GanttLinkType || (GanttLinkType = {}));
|
|
214
|
+
var GanttLinkLineType;
|
|
215
|
+
(function (GanttLinkLineType) {
|
|
216
|
+
GanttLinkLineType["curve"] = "curve";
|
|
217
|
+
GanttLinkLineType["straight"] = "straight";
|
|
218
|
+
})(GanttLinkLineType || (GanttLinkLineType = {}));
|
|
219
|
+
var LinkColors;
|
|
220
|
+
(function (LinkColors) {
|
|
221
|
+
LinkColors["default"] = "#cacaca";
|
|
222
|
+
LinkColors["blocked"] = "#FF7575";
|
|
223
|
+
LinkColors["active"] = "#348FE4";
|
|
224
|
+
})(LinkColors || (LinkColors = {}));
|
|
225
|
+
|
|
226
|
+
var GanttItemType;
|
|
227
|
+
(function (GanttItemType) {
|
|
228
|
+
GanttItemType["bar"] = "bar";
|
|
229
|
+
GanttItemType["range"] = "range";
|
|
230
|
+
GanttItemType["custom"] = "custom";
|
|
231
|
+
})(GanttItemType || (GanttItemType = {}));
|
|
232
|
+
class GanttItemInternal {
|
|
233
|
+
constructor(item, options) {
|
|
234
|
+
this.refs$ = new BehaviorSubject(null);
|
|
235
|
+
this.origin = item;
|
|
236
|
+
this.id = this.origin.id;
|
|
237
|
+
this.links = (this.origin.links || []).map((link) => {
|
|
238
|
+
if (typeof link === 'string') {
|
|
239
|
+
return {
|
|
240
|
+
type: GanttLinkType.fs,
|
|
241
|
+
link
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
return link;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
this.color = this.origin.color;
|
|
249
|
+
this.barStyle = this.origin.barStyle;
|
|
250
|
+
this.linkable = this.origin.linkable === undefined ? true : this.origin.linkable;
|
|
251
|
+
this.draggable = this.origin.draggable === undefined ? true : this.origin.draggable;
|
|
252
|
+
this.expandable = this.origin.expandable || (this.origin.children || []).length > 0;
|
|
253
|
+
this.expanded = this.origin.expanded === undefined ? false : this.origin.expanded;
|
|
254
|
+
this.start = item.start ? new GanttDate(item.start) : null;
|
|
255
|
+
this.end = item.end ? new GanttDate(item.end) : null;
|
|
256
|
+
this.viewType = options && options.viewType ? options.viewType : GanttViewType.month;
|
|
257
|
+
this.children = (item.children || []).map((subItem) => {
|
|
258
|
+
return new GanttItemInternal(subItem, { viewType: this.viewType });
|
|
259
|
+
});
|
|
260
|
+
this.type = this.origin.type || GanttItemType.bar;
|
|
261
|
+
this.progress = this.origin.progress;
|
|
262
|
+
// fill one month when start or end is null
|
|
263
|
+
this.fillItemStartOrEnd(item);
|
|
264
|
+
}
|
|
265
|
+
get refs() {
|
|
266
|
+
return this.refs$.getValue();
|
|
267
|
+
}
|
|
268
|
+
fillItemStartOrEnd(item) {
|
|
269
|
+
let addInterval;
|
|
270
|
+
switch (this.viewType) {
|
|
271
|
+
case GanttViewType.day:
|
|
272
|
+
case GanttViewType.week:
|
|
273
|
+
addInterval = 0;
|
|
274
|
+
break;
|
|
275
|
+
default:
|
|
276
|
+
addInterval = 30;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
if (item.start && !item.end) {
|
|
280
|
+
this.end = new GanttDate(item.start).addDays(addInterval).endOfDay();
|
|
281
|
+
}
|
|
282
|
+
if (!item.start && item.end) {
|
|
283
|
+
this.start = new GanttDate(item.end).addDays(-addInterval).startOfDay();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
updateRefs(refs) {
|
|
287
|
+
this.refs$.next(refs);
|
|
288
|
+
}
|
|
289
|
+
updateDate(start, end) {
|
|
290
|
+
this.start = start.startOfDay();
|
|
291
|
+
this.end = end.endOfDay();
|
|
292
|
+
this.origin.start = this.start.getUnixTime();
|
|
293
|
+
this.origin.end = this.end.getUnixTime();
|
|
294
|
+
}
|
|
295
|
+
addChildren(items) {
|
|
296
|
+
this.origin.children = items;
|
|
297
|
+
this.children = (items || []).map((subItem) => {
|
|
298
|
+
return new GanttItemInternal(subItem, { viewType: this.viewType });
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
setExpand(expanded) {
|
|
302
|
+
this.expanded = expanded;
|
|
303
|
+
this.origin.expanded = expanded;
|
|
304
|
+
}
|
|
305
|
+
addLink(link) {
|
|
306
|
+
console.log(link);
|
|
307
|
+
this.links = [...this.links, link];
|
|
308
|
+
this.origin.links = this.links;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
class GanttGroupInternal {
|
|
313
|
+
constructor(group) {
|
|
314
|
+
this.refs = {};
|
|
315
|
+
this.id = group.id;
|
|
316
|
+
this.origin = group;
|
|
317
|
+
this.title = group.title;
|
|
318
|
+
this.expanded = group.expanded === undefined ? true : group.expanded;
|
|
319
|
+
this.items = [];
|
|
320
|
+
this.mergedItems = [[]];
|
|
321
|
+
this.class = group.class || '';
|
|
322
|
+
}
|
|
323
|
+
setExpand(expanded) {
|
|
324
|
+
this.expanded = expanded;
|
|
325
|
+
this.origin.expanded = expanded;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const defaultConfig = {
|
|
330
|
+
dateFormat: {
|
|
331
|
+
week: '第w周',
|
|
332
|
+
month: 'M月',
|
|
333
|
+
quarter: 'QQQ',
|
|
334
|
+
year: 'yyyy年',
|
|
335
|
+
yearMonth: 'yyyy年MM月',
|
|
336
|
+
yearQuarter: 'yyyy年QQQ'
|
|
337
|
+
},
|
|
338
|
+
linkOptions: {
|
|
339
|
+
dependencyTypes: [GanttLinkType.fs],
|
|
340
|
+
showArrow: false,
|
|
341
|
+
lineType: GanttLinkLineType.curve
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
const GANTT_GLOBAL_CONFIG = new InjectionToken('GANTT_GLOBAL_CONFIG');
|
|
345
|
+
|
|
346
|
+
const primaryDatePointTop = 18;
|
|
347
|
+
const secondaryDatePointTop = 36;
|
|
348
|
+
const viewOptions$5 = {
|
|
349
|
+
min: new GanttDate().addYears(-1).startOfYear(),
|
|
350
|
+
max: new GanttDate().addYears(1).endOfYear(),
|
|
351
|
+
dateFormat: defaultConfig.dateFormat
|
|
352
|
+
};
|
|
353
|
+
class GanttView {
|
|
354
|
+
constructor(start, end, options) {
|
|
355
|
+
this.showTimeline = true;
|
|
356
|
+
this.options = Object.assign({}, viewOptions$5, options);
|
|
357
|
+
const startDate = start.isCustom
|
|
358
|
+
? this.startOf(start.date)
|
|
359
|
+
: this.startOf(start.date.value < this.options.start.value ? start.date : this.options.start);
|
|
360
|
+
const endDate = end.isCustom
|
|
361
|
+
? this.endOf(end.date)
|
|
362
|
+
: this.endOf(end.date.value > this.options.end.value ? end.date : this.options.end);
|
|
363
|
+
this.start$ = new BehaviorSubject(startDate);
|
|
364
|
+
this.end$ = new BehaviorSubject(endDate);
|
|
365
|
+
this.initialize();
|
|
366
|
+
}
|
|
367
|
+
get start() {
|
|
368
|
+
return this.start$.getValue();
|
|
369
|
+
}
|
|
370
|
+
get end() {
|
|
371
|
+
return this.end$.getValue();
|
|
372
|
+
}
|
|
373
|
+
getDateIntervalWidth(start, end) {
|
|
374
|
+
let result = 0;
|
|
375
|
+
const days = differenceInDays(end.value, start.value);
|
|
376
|
+
for (let i = 0; i < Math.abs(days); i++) {
|
|
377
|
+
result += this.getDayOccupancyWidth(start.addDays(i));
|
|
378
|
+
}
|
|
379
|
+
result = days >= 0 ? result : -result;
|
|
380
|
+
return Number(result.toFixed(3));
|
|
381
|
+
}
|
|
382
|
+
initialize() {
|
|
383
|
+
this.primaryDatePoints = this.getPrimaryDatePoints();
|
|
384
|
+
this.secondaryDatePoints = this.getSecondaryDatePoints();
|
|
385
|
+
this.width = this.getWidth();
|
|
386
|
+
this.cellWidth = this.getCellWidth();
|
|
387
|
+
this.primaryWidth = this.getPrimaryWidth();
|
|
388
|
+
}
|
|
389
|
+
addStartDate() {
|
|
390
|
+
const start = this.startOf(this.start.add(this.options.addAmount * -1, this.options.addUnit));
|
|
391
|
+
if (start.value >= this.options.min.value) {
|
|
392
|
+
const origin = this.start;
|
|
393
|
+
this.start$.next(start);
|
|
394
|
+
this.initialize();
|
|
395
|
+
return { start: this.start, end: origin };
|
|
396
|
+
}
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
addEndDate() {
|
|
400
|
+
const end = this.endOf(this.end.add(this.options.addAmount, this.options.addUnit));
|
|
401
|
+
if (end.value <= this.options.max.value) {
|
|
402
|
+
const origin = this.end;
|
|
403
|
+
this.end$.next(end);
|
|
404
|
+
this.initialize();
|
|
405
|
+
return { start: origin, end: this.end };
|
|
406
|
+
}
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
updateDate(start, end) {
|
|
410
|
+
start = this.startOf(start);
|
|
411
|
+
end = this.endOf(end);
|
|
412
|
+
if (start.value < this.start.value) {
|
|
413
|
+
this.start$.next(start);
|
|
414
|
+
}
|
|
415
|
+
if (end.value > this.end.value) {
|
|
416
|
+
this.end$.next(end);
|
|
417
|
+
}
|
|
418
|
+
this.initialize();
|
|
419
|
+
}
|
|
420
|
+
// 获取View的宽度
|
|
421
|
+
getWidth() {
|
|
422
|
+
return this.getCellWidth() * this.secondaryDatePoints.length;
|
|
423
|
+
}
|
|
424
|
+
// 获取单个网格的宽度
|
|
425
|
+
getCellWidth() {
|
|
426
|
+
return this.options.cellWidth;
|
|
427
|
+
}
|
|
428
|
+
// 获取当前时间的X坐标
|
|
429
|
+
getTodayXPoint() {
|
|
430
|
+
const toady = new GanttDate().startOfDay();
|
|
431
|
+
if (toady.value > this.start.value && toady.value < this.end.value) {
|
|
432
|
+
const x = this.getXPointByDate(toady) + this.getDayOccupancyWidth(toady) / 2;
|
|
433
|
+
return x;
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// 获取指定时间的X坐标
|
|
440
|
+
getXPointByDate(date) {
|
|
441
|
+
return this.getDateIntervalWidth(this.start, date);
|
|
442
|
+
}
|
|
443
|
+
// 根据X坐标获取对应时间
|
|
444
|
+
getDateByXPoint(x) {
|
|
445
|
+
const indexOfSecondaryDate = Math.floor(x / this.getCellWidth());
|
|
446
|
+
const matchDate = this.secondaryDatePoints[indexOfSecondaryDate];
|
|
447
|
+
const dayWidth = this.getDayOccupancyWidth(matchDate === null || matchDate === void 0 ? void 0 : matchDate.start);
|
|
448
|
+
if (dayWidth === this.getCellWidth()) {
|
|
449
|
+
return matchDate === null || matchDate === void 0 ? void 0 : matchDate.start;
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
const day = Math.floor((x % this.getCellWidth()) / dayWidth) + 1;
|
|
453
|
+
if (this.getCellWidth() / dayWidth === 7) {
|
|
454
|
+
return matchDate === null || matchDate === void 0 ? void 0 : matchDate.start.addDays(day);
|
|
455
|
+
}
|
|
456
|
+
return matchDate === null || matchDate === void 0 ? void 0 : matchDate.start.setDate(day);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// 获取指定时间范围的宽度
|
|
460
|
+
getDateRangeWidth(start, end) {
|
|
461
|
+
// addSeconds(1) 是因为计算相差天会以一个整天来计算 end时间一般是59分59秒不是一个整天,所以需要加1
|
|
462
|
+
return this.getDateIntervalWidth(start, end.addSeconds(1));
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
const viewOptions$4 = {
|
|
467
|
+
start: new GanttDate().startOfQuarter().addQuarters(-1),
|
|
468
|
+
end: new GanttDate().endOfQuarter().addQuarters(2),
|
|
469
|
+
cellWidth: 280,
|
|
470
|
+
addAmount: 1,
|
|
471
|
+
addUnit: 'quarter'
|
|
472
|
+
};
|
|
473
|
+
class GanttViewMonth extends GanttView {
|
|
474
|
+
constructor(start, end, options) {
|
|
475
|
+
super(start, end, Object.assign({}, viewOptions$4, options));
|
|
476
|
+
}
|
|
477
|
+
startOf(date) {
|
|
478
|
+
return date.startOfQuarter();
|
|
479
|
+
}
|
|
480
|
+
endOf(date) {
|
|
481
|
+
return date.endOfQuarter();
|
|
482
|
+
}
|
|
483
|
+
getPrimaryWidth() {
|
|
484
|
+
return this.getCellWidth() * 3;
|
|
485
|
+
}
|
|
486
|
+
getDayOccupancyWidth(date) {
|
|
487
|
+
return this.cellWidth / date.getDaysInMonth();
|
|
488
|
+
}
|
|
489
|
+
getPrimaryDatePoints() {
|
|
490
|
+
const quarters = differenceInCalendarQuarters(this.end.addSeconds(1).value, this.start.value);
|
|
491
|
+
const points = [];
|
|
492
|
+
for (let i = 0; i < quarters; i++) {
|
|
493
|
+
const start = this.start.addQuarters(i);
|
|
494
|
+
const point = new GanttDatePoint(start, start.format(this.options.dateFormat.yearQuarter), (this.getCellWidth() * 3) / 2 + i * (this.getCellWidth() * 3), primaryDatePointTop);
|
|
495
|
+
points.push(point);
|
|
496
|
+
}
|
|
497
|
+
return points;
|
|
498
|
+
}
|
|
499
|
+
getSecondaryDatePoints() {
|
|
500
|
+
const months = eachMonthOfInterval({ start: this.start.value, end: this.end.value });
|
|
501
|
+
const points = [];
|
|
502
|
+
for (let i = 0; i < months.length; i++) {
|
|
503
|
+
const start = new GanttDate(months[i]);
|
|
504
|
+
const point = new GanttDatePoint(start, start.format(this.options.dateFormat.month), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
|
|
505
|
+
points.push(point);
|
|
506
|
+
}
|
|
507
|
+
return points;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
const viewOptions$3 = {
|
|
512
|
+
start: new GanttDate().addYears(-1).startOfYear(),
|
|
513
|
+
end: new GanttDate().addYears(1).endOfYear(),
|
|
514
|
+
min: new GanttDate().addYears(-2).startOfYear(),
|
|
515
|
+
max: new GanttDate().addYears(2).endOfYear(),
|
|
516
|
+
cellWidth: 500,
|
|
517
|
+
addAmount: 1,
|
|
518
|
+
addUnit: 'year'
|
|
519
|
+
};
|
|
520
|
+
class GanttViewQuarter extends GanttView {
|
|
521
|
+
constructor(start, end, options) {
|
|
522
|
+
super(start, end, Object.assign({}, viewOptions$3, options));
|
|
523
|
+
}
|
|
524
|
+
startOf(date) {
|
|
525
|
+
return date.startOfYear();
|
|
526
|
+
}
|
|
527
|
+
endOf(date) {
|
|
528
|
+
return date.endOfYear();
|
|
529
|
+
}
|
|
530
|
+
getPrimaryWidth() {
|
|
531
|
+
return this.getCellWidth() * 4;
|
|
532
|
+
}
|
|
533
|
+
getDayOccupancyWidth(date) {
|
|
534
|
+
return this.cellWidth / date.getDaysInQuarter();
|
|
535
|
+
}
|
|
536
|
+
getPrimaryDatePoints() {
|
|
537
|
+
const years = eachYearOfInterval({ start: this.start.value, end: this.end.value });
|
|
538
|
+
const points = [];
|
|
539
|
+
for (let i = 0; i < years.length; i++) {
|
|
540
|
+
const start = new GanttDate(years[i]);
|
|
541
|
+
const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.year)}`, (this.getCellWidth() * 4) / 2 + i * (this.getCellWidth() * 4), primaryDatePointTop);
|
|
542
|
+
points.push(point);
|
|
543
|
+
}
|
|
544
|
+
return points;
|
|
545
|
+
}
|
|
546
|
+
getSecondaryDatePoints() {
|
|
547
|
+
const quarters = differenceInCalendarQuarters(this.end.value, this.start.value);
|
|
548
|
+
const points = [];
|
|
549
|
+
for (let i = 0; i <= quarters; i++) {
|
|
550
|
+
const start = this.start.addQuarters(i);
|
|
551
|
+
const point = new GanttDatePoint(start, start.format(this.options.dateFormat.quarter), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
|
|
552
|
+
points.push(point);
|
|
553
|
+
}
|
|
554
|
+
return points;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
const viewOptions$2 = {
|
|
559
|
+
cellWidth: 35,
|
|
560
|
+
start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
|
|
561
|
+
end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
|
|
562
|
+
addAmount: 1,
|
|
563
|
+
addUnit: 'month'
|
|
564
|
+
};
|
|
565
|
+
class GanttViewDay extends GanttView {
|
|
566
|
+
constructor(start, end, options) {
|
|
567
|
+
super(start, end, Object.assign({}, viewOptions$2, options));
|
|
568
|
+
this.showWeekBackdrop = true;
|
|
569
|
+
this.showTimeline = false;
|
|
570
|
+
}
|
|
571
|
+
startOf(date) {
|
|
572
|
+
return date.startOfWeek({ weekStartsOn: 1 });
|
|
573
|
+
}
|
|
574
|
+
endOf(date) {
|
|
575
|
+
return date.endOfWeek({ weekStartsOn: 1 });
|
|
576
|
+
}
|
|
577
|
+
getPrimaryWidth() {
|
|
578
|
+
return this.getCellWidth() * 7;
|
|
579
|
+
}
|
|
580
|
+
getDayOccupancyWidth() {
|
|
581
|
+
return this.cellWidth;
|
|
582
|
+
}
|
|
583
|
+
getPrimaryDatePoints() {
|
|
584
|
+
const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.addSeconds(1).value }, { weekStartsOn: 1 });
|
|
585
|
+
const points = [];
|
|
586
|
+
for (let i = 0; i < weeks.length; i++) {
|
|
587
|
+
const weekStart = new GanttDate(weeks[i]);
|
|
588
|
+
const increaseWeek = weekStart.getDaysInMonth() - weekStart.getDate() >= 3 ? 0 : 1;
|
|
589
|
+
const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format(this.options.dateFormat.yearMonth), (this.getCellWidth() * 7) / 2 + i * (this.getCellWidth() * 7), primaryDatePointTop);
|
|
590
|
+
points.push(point);
|
|
591
|
+
}
|
|
592
|
+
return points;
|
|
593
|
+
}
|
|
594
|
+
getSecondaryDatePoints() {
|
|
595
|
+
const days = eachDayOfInterval({ start: this.start.value, end: this.end.value });
|
|
596
|
+
const points = [];
|
|
597
|
+
for (let i = 0; i < days.length; i++) {
|
|
598
|
+
const start = new GanttDate(days[i]);
|
|
599
|
+
const point = new GanttDatePoint(start, start.getDate().toString(), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop, {
|
|
600
|
+
isWeekend: start.isWeekend(),
|
|
601
|
+
isToday: start.isToday()
|
|
602
|
+
});
|
|
603
|
+
points.push(point);
|
|
604
|
+
}
|
|
605
|
+
return points;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const viewOptions$1 = {
|
|
610
|
+
cellWidth: 280,
|
|
611
|
+
start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
|
|
612
|
+
end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
|
|
613
|
+
addAmount: 1,
|
|
614
|
+
addUnit: 'month'
|
|
615
|
+
};
|
|
616
|
+
class GanttViewWeek extends GanttView {
|
|
617
|
+
constructor(start, end, options) {
|
|
618
|
+
super(start, end, Object.assign({}, viewOptions$1, options));
|
|
619
|
+
}
|
|
620
|
+
startOf(date) {
|
|
621
|
+
return date.startOfWeek({ weekStartsOn: 1 });
|
|
622
|
+
}
|
|
623
|
+
endOf(date) {
|
|
624
|
+
return date.endOfWeek({ weekStartsOn: 1 });
|
|
625
|
+
}
|
|
626
|
+
getPrimaryWidth() {
|
|
627
|
+
return this.getCellWidth();
|
|
628
|
+
}
|
|
629
|
+
getDayOccupancyWidth() {
|
|
630
|
+
return this.cellWidth / 7;
|
|
631
|
+
}
|
|
632
|
+
getPrimaryDatePoints() {
|
|
633
|
+
const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.addSeconds(1).value }, { weekStartsOn: 1 });
|
|
634
|
+
const points = [];
|
|
635
|
+
for (let i = 0; i < weeks.length; i++) {
|
|
636
|
+
const weekStart = new GanttDate(weeks[i]);
|
|
637
|
+
const increaseWeek = weekStart.getDaysInMonth() - weekStart.getDate() >= 3 ? 0 : 1;
|
|
638
|
+
const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format(this.options.dateFormat.year), this.getCellWidth() / 2 + i * this.getCellWidth(), primaryDatePointTop);
|
|
639
|
+
points.push(point);
|
|
640
|
+
}
|
|
641
|
+
return points;
|
|
642
|
+
}
|
|
643
|
+
getSecondaryDatePoints() {
|
|
644
|
+
const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.value });
|
|
645
|
+
const points = [];
|
|
646
|
+
for (let i = 0; i < weeks.length; i++) {
|
|
647
|
+
const start = new GanttDate(weeks[i]);
|
|
648
|
+
const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.week)}`, i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
|
|
649
|
+
points.push(point);
|
|
650
|
+
}
|
|
651
|
+
return points;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const viewOptions = {
|
|
656
|
+
cellWidth: 480,
|
|
657
|
+
start: new GanttDate().addYears(-2).startOfYear(),
|
|
658
|
+
end: new GanttDate().addYears(2).endOfYear(),
|
|
659
|
+
addAmount: 1,
|
|
660
|
+
addUnit: 'year'
|
|
661
|
+
};
|
|
662
|
+
class GanttViewYear extends GanttView {
|
|
663
|
+
constructor(start, end, options) {
|
|
664
|
+
super(start, end, Object.assign({}, viewOptions, options));
|
|
665
|
+
}
|
|
666
|
+
startOf(date) {
|
|
667
|
+
return date.startOfYear();
|
|
668
|
+
}
|
|
669
|
+
endOf(date) {
|
|
670
|
+
return date.endOfYear();
|
|
671
|
+
}
|
|
672
|
+
getPrimaryWidth() {
|
|
673
|
+
return this.getCellWidth();
|
|
674
|
+
}
|
|
675
|
+
getDayOccupancyWidth(date) {
|
|
676
|
+
return this.cellWidth / date.getDaysInYear();
|
|
677
|
+
}
|
|
678
|
+
getPrimaryDatePoints() {
|
|
679
|
+
const years = eachYearOfInterval({ start: this.start.value, end: this.end.value });
|
|
680
|
+
const points = [];
|
|
681
|
+
for (let i = 0; i < years.length; i++) {
|
|
682
|
+
const start = new GanttDate(years[i]);
|
|
683
|
+
const point = new GanttDatePoint(start, ``, this.getCellWidth() / 2 + i * this.getCellWidth(), primaryDatePointTop);
|
|
684
|
+
points.push(point);
|
|
685
|
+
}
|
|
686
|
+
return points;
|
|
687
|
+
}
|
|
688
|
+
getSecondaryDatePoints() {
|
|
689
|
+
const years = differenceInCalendarYears(this.end.value, this.start.value);
|
|
690
|
+
const points = [];
|
|
691
|
+
const pointTop = 27;
|
|
692
|
+
for (let i = 0; i <= years; i++) {
|
|
693
|
+
const start = this.start.addYears(i);
|
|
694
|
+
const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.year)}`, i * this.getCellWidth() + this.getCellWidth() / 2, pointTop);
|
|
695
|
+
points.push(point);
|
|
696
|
+
}
|
|
697
|
+
return points;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
function createViewFactory(type, start, end, options) {
|
|
702
|
+
switch (type) {
|
|
703
|
+
case GanttViewType.month:
|
|
704
|
+
return new GanttViewMonth(start, end, options);
|
|
705
|
+
case GanttViewType.week:
|
|
706
|
+
return new GanttViewWeek(start, end, options);
|
|
707
|
+
case GanttViewType.quarter:
|
|
708
|
+
return new GanttViewQuarter(start, end, options);
|
|
709
|
+
case GanttViewType.day:
|
|
710
|
+
return new GanttViewDay(start, end, options);
|
|
711
|
+
case GanttViewType.year:
|
|
712
|
+
return new GanttViewYear(start, end, options);
|
|
713
|
+
default:
|
|
714
|
+
throw new Error('gantt view type invalid');
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const defaultStyles = {
|
|
719
|
+
lineHeight: 44,
|
|
720
|
+
barHeight: 22
|
|
721
|
+
};
|
|
722
|
+
const headerHeight = 44;
|
|
723
|
+
const sideWidth = 400;
|
|
724
|
+
const sideMiddleWidth = 500;
|
|
725
|
+
const sideMaxWidth = 600;
|
|
726
|
+
const sideMinWidth = 400;
|
|
727
|
+
const barBackground = '#348fe4';
|
|
728
|
+
const rangeHeight = 17;
|
|
729
|
+
const todayHeight = 24;
|
|
730
|
+
const todayWidth = 35;
|
|
731
|
+
const todayBorderRadius = 4;
|
|
732
|
+
|
|
733
|
+
function isNumber(value) {
|
|
734
|
+
return typeof value === 'number';
|
|
735
|
+
}
|
|
736
|
+
function isString(value) {
|
|
737
|
+
return typeof value === 'string';
|
|
738
|
+
}
|
|
739
|
+
function isUndefined(value) {
|
|
740
|
+
return value === undefined;
|
|
741
|
+
}
|
|
742
|
+
function hexToRgb(color, opacity = 1) {
|
|
743
|
+
if (/^#/g.test(color)) {
|
|
744
|
+
return `rgba(${parseInt(color.slice(1, 3), 16)},${parseInt(color.slice(3, 5), 16)},${parseInt(color.slice(5, 7), 16)},${opacity})`;
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
return color;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
function uniqBy(array, key) {
|
|
751
|
+
const valuesMap = {};
|
|
752
|
+
const result = [];
|
|
753
|
+
(array || []).forEach((value) => {
|
|
754
|
+
const _key = value[key];
|
|
755
|
+
if (!valuesMap[_key]) {
|
|
756
|
+
valuesMap[_key] = value;
|
|
757
|
+
result.push(value);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
return result;
|
|
761
|
+
}
|
|
762
|
+
function flatten(array) {
|
|
763
|
+
return array.reduce((pre, cur) => {
|
|
764
|
+
return pre.concat(Array.isArray(cur) ? flatten(cur) : cur);
|
|
765
|
+
}, []);
|
|
766
|
+
}
|
|
767
|
+
function recursiveItems(items) {
|
|
768
|
+
const result = [];
|
|
769
|
+
(items || []).forEach((item) => {
|
|
770
|
+
result.push(item);
|
|
771
|
+
if (item.expanded && item.children) {
|
|
772
|
+
result.push(...recursiveItems(item.children));
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
return result;
|
|
776
|
+
}
|
|
777
|
+
function getFlatItems(items) {
|
|
778
|
+
const result = [];
|
|
779
|
+
(items || []).forEach((item) => {
|
|
780
|
+
result.push(item);
|
|
781
|
+
if (item.children) {
|
|
782
|
+
result.push(...getFlatItems(item.children));
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
return result;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
class GanttUpper {
|
|
789
|
+
constructor(elementRef, cdr, ngZone, config) {
|
|
790
|
+
this.elementRef = elementRef;
|
|
791
|
+
this.cdr = cdr;
|
|
792
|
+
this.ngZone = ngZone;
|
|
793
|
+
this.config = config;
|
|
794
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
795
|
+
this.originItems = [];
|
|
796
|
+
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
797
|
+
this.originGroups = [];
|
|
798
|
+
this.viewType = GanttViewType.month;
|
|
799
|
+
this.showTodayLine = true;
|
|
800
|
+
this.viewOptions = {};
|
|
801
|
+
this.loadOnScroll = new EventEmitter();
|
|
802
|
+
this.dragStarted = new EventEmitter();
|
|
803
|
+
this.dragMoved = new EventEmitter();
|
|
804
|
+
this.dragEnded = new EventEmitter();
|
|
805
|
+
this.barClick = new EventEmitter();
|
|
806
|
+
this.linkDragEnded = new EventEmitter();
|
|
807
|
+
this.items = [];
|
|
808
|
+
this.groups = [];
|
|
809
|
+
this.viewChange = new EventEmitter();
|
|
810
|
+
this.expandChange = new EventEmitter();
|
|
811
|
+
this.firstChange = true;
|
|
812
|
+
this.unsubscribe$ = new Subject();
|
|
813
|
+
this._selectable = false;
|
|
814
|
+
this._multiple = false;
|
|
815
|
+
this.ganttClass = true;
|
|
816
|
+
}
|
|
817
|
+
set linkOptions(options) {
|
|
818
|
+
this._linkOptions = options;
|
|
819
|
+
}
|
|
820
|
+
get linkOptions() {
|
|
821
|
+
return Object.assign({}, defaultConfig.linkOptions, this.config.linkOptions, this._linkOptions);
|
|
822
|
+
}
|
|
823
|
+
set selectable(value) {
|
|
824
|
+
var _a;
|
|
825
|
+
this._selectable = coerceBooleanProperty(value);
|
|
826
|
+
if (this._selectable) {
|
|
827
|
+
this.selectionModel = this.initSelectionModel();
|
|
828
|
+
}
|
|
829
|
+
else {
|
|
830
|
+
(_a = this.selectionModel) === null || _a === void 0 ? void 0 : _a.clear();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
get selectable() {
|
|
834
|
+
return this._selectable;
|
|
835
|
+
}
|
|
836
|
+
set multiple(value) {
|
|
837
|
+
this._multiple = coerceBooleanProperty(value);
|
|
838
|
+
if (this.selectable) {
|
|
839
|
+
this.selectionModel = this.initSelectionModel();
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
get multiple() {
|
|
843
|
+
return this._multiple;
|
|
844
|
+
}
|
|
845
|
+
get element() {
|
|
846
|
+
return this.elementRef.nativeElement;
|
|
847
|
+
}
|
|
848
|
+
createView() {
|
|
849
|
+
const viewDate = this.getViewDate();
|
|
850
|
+
this.view = createViewFactory(this.viewType, viewDate.start, viewDate.end, this.viewOptions);
|
|
851
|
+
}
|
|
852
|
+
setupGroups() {
|
|
853
|
+
const collapsedIds = this.groups.filter((group) => group.expanded === false).map((group) => group.id);
|
|
854
|
+
this.groupsMap = {};
|
|
855
|
+
this.groups = [];
|
|
856
|
+
this.originGroups.forEach((origin) => {
|
|
857
|
+
const group = new GanttGroupInternal(origin);
|
|
858
|
+
group.expanded = !collapsedIds.includes(group.id);
|
|
859
|
+
this.groupsMap[group.id] = group;
|
|
860
|
+
this.groups.push(group);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
setupItems() {
|
|
864
|
+
this.originItems = uniqBy(this.originItems, 'id');
|
|
865
|
+
this.items = [];
|
|
866
|
+
if (this.groups.length > 0) {
|
|
867
|
+
this.originItems.forEach((origin) => {
|
|
868
|
+
const group = this.groupsMap[origin.group_id];
|
|
869
|
+
if (group) {
|
|
870
|
+
const item = new GanttItemInternal(origin, { viewType: this.viewType });
|
|
871
|
+
group.items.push(item);
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
else {
|
|
876
|
+
this.originItems.forEach((origin) => {
|
|
877
|
+
const item = new GanttItemInternal(origin, { viewType: this.viewType });
|
|
878
|
+
this.items.push(item);
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
setupExpandedState() {
|
|
883
|
+
this.originItems = uniqBy(this.originItems, 'id');
|
|
884
|
+
let items = [];
|
|
885
|
+
const flatOriginItems = getFlatItems(this.originItems);
|
|
886
|
+
if (this.items.length > 0) {
|
|
887
|
+
items = recursiveItems(this.items);
|
|
888
|
+
}
|
|
889
|
+
else {
|
|
890
|
+
items = flatten(this.groups.map((group) => recursiveItems(group.items)));
|
|
891
|
+
}
|
|
892
|
+
items.forEach((item) => {
|
|
893
|
+
if (item.origin.expanded) {
|
|
894
|
+
const newItem = flatOriginItems.find((originItem) => originItem.id === item.id);
|
|
895
|
+
if (newItem) {
|
|
896
|
+
if (newItem.expanded === undefined) {
|
|
897
|
+
newItem.expanded = true;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
getViewDate() {
|
|
904
|
+
let start = this.start;
|
|
905
|
+
let end = this.end;
|
|
906
|
+
if (!this.start || !this.end) {
|
|
907
|
+
this.originItems.forEach((item) => {
|
|
908
|
+
if (item.start && !this.start) {
|
|
909
|
+
start = start ? Math.min(start, item.start) : item.start;
|
|
910
|
+
}
|
|
911
|
+
if (item.end && !this.end) {
|
|
912
|
+
end = end ? Math.max(end, item.end) : item.end;
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
return {
|
|
917
|
+
start: {
|
|
918
|
+
date: new GanttDate(start),
|
|
919
|
+
isCustom: this.start ? true : false
|
|
920
|
+
},
|
|
921
|
+
end: {
|
|
922
|
+
date: new GanttDate(end),
|
|
923
|
+
isCustom: this.end ? true : false
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
computeRefs() {
|
|
928
|
+
this.groups.forEach((group) => {
|
|
929
|
+
const groupItems = recursiveItems(group.items);
|
|
930
|
+
this.computeItemsRefs(...groupItems);
|
|
931
|
+
});
|
|
932
|
+
const items = recursiveItems(this.items);
|
|
933
|
+
this.computeItemsRefs(...items);
|
|
934
|
+
}
|
|
935
|
+
expandGroups(expanded) {
|
|
936
|
+
this.groups.forEach((group) => {
|
|
937
|
+
group.setExpand(expanded);
|
|
938
|
+
});
|
|
939
|
+
this.expandChange.next();
|
|
940
|
+
this.cdr.detectChanges();
|
|
941
|
+
}
|
|
942
|
+
initSelectionModel() {
|
|
943
|
+
return new SelectionModel(this.multiple, []);
|
|
944
|
+
}
|
|
945
|
+
ngOnInit() {
|
|
946
|
+
this.styles = Object.assign({}, defaultStyles, this.styles);
|
|
947
|
+
this.viewOptions.dateFormat = Object.assign({}, defaultConfig.dateFormat, this.config.dateFormat, this.viewOptions.dateFormat);
|
|
948
|
+
this.createView();
|
|
949
|
+
this.setupGroups();
|
|
950
|
+
this.setupItems();
|
|
951
|
+
this.computeRefs();
|
|
952
|
+
this.initSelectionModel();
|
|
953
|
+
this.firstChange = false;
|
|
954
|
+
// Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
|
|
955
|
+
// the `onStable` will never emit any value.
|
|
956
|
+
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
|
|
957
|
+
// Normally this isn't in the zone, but it can cause performance regressions for apps
|
|
958
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
959
|
+
this.ngZone.runOutsideAngular(() => {
|
|
960
|
+
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
961
|
+
this.element.style.opacity = '1';
|
|
962
|
+
this.dragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
|
|
963
|
+
this.dragStarted.emit(event);
|
|
964
|
+
});
|
|
965
|
+
this.dragContainer.dragMoved.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
|
|
966
|
+
this.dragMoved.emit(event);
|
|
967
|
+
});
|
|
968
|
+
this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe((event) => {
|
|
969
|
+
this.dragEnded.emit(event);
|
|
970
|
+
this.computeRefs();
|
|
971
|
+
this.detectChanges();
|
|
972
|
+
});
|
|
973
|
+
});
|
|
974
|
+
});
|
|
975
|
+
this.view.start$.pipe(skip(1), takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
976
|
+
this.computeRefs();
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
ngOnChanges(changes) {
|
|
980
|
+
if (!this.firstChange) {
|
|
981
|
+
if (changes.viewType && changes.viewType.currentValue) {
|
|
982
|
+
this.createView();
|
|
983
|
+
this.setupGroups();
|
|
984
|
+
this.setupItems();
|
|
985
|
+
this.computeRefs();
|
|
986
|
+
this.viewChange.emit(this.view);
|
|
987
|
+
}
|
|
988
|
+
if (changes.originItems || changes.originGroups) {
|
|
989
|
+
this.setupExpandedState();
|
|
990
|
+
this.setupGroups();
|
|
991
|
+
this.setupItems();
|
|
992
|
+
this.computeRefs();
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
ngOnDestroy() {
|
|
997
|
+
this.unsubscribe$.next();
|
|
998
|
+
this.unsubscribe$.complete();
|
|
999
|
+
}
|
|
1000
|
+
computeItemsRefs(...items) {
|
|
1001
|
+
items.forEach((item) => {
|
|
1002
|
+
item.updateRefs({
|
|
1003
|
+
width: item.start && item.end ? this.view.getDateRangeWidth(item.start.startOfDay(), item.end.endOfDay()) : 0,
|
|
1004
|
+
x: item.start ? this.view.getXPointByDate(item.start) : 0,
|
|
1005
|
+
y: (this.styles.lineHeight - this.styles.barHeight) / 2 - 1
|
|
1006
|
+
});
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
trackBy(index, item) {
|
|
1010
|
+
return item.id || index;
|
|
1011
|
+
}
|
|
1012
|
+
detectChanges() {
|
|
1013
|
+
this.cdr.detectChanges();
|
|
1014
|
+
}
|
|
1015
|
+
expandGroup(group) {
|
|
1016
|
+
group.setExpand(!group.expanded);
|
|
1017
|
+
this.expandChange.emit();
|
|
1018
|
+
this.cdr.detectChanges();
|
|
1019
|
+
}
|
|
1020
|
+
// public functions
|
|
1021
|
+
expandAll() {
|
|
1022
|
+
this.expandGroups(true);
|
|
1023
|
+
}
|
|
1024
|
+
collapseAll() {
|
|
1025
|
+
this.expandGroups(false);
|
|
1026
|
+
}
|
|
1027
|
+
getGanttItem(id) {
|
|
1028
|
+
return this.getGanttItems([id])[0] || null;
|
|
1029
|
+
}
|
|
1030
|
+
getGanttItems(ids) {
|
|
1031
|
+
let items = [];
|
|
1032
|
+
if (this.items.length > 0) {
|
|
1033
|
+
items = recursiveItems(this.items);
|
|
1034
|
+
}
|
|
1035
|
+
else {
|
|
1036
|
+
items = flatten(this.groups.map((group) => recursiveItems(group.items)));
|
|
1037
|
+
}
|
|
1038
|
+
return items.filter((item) => ids.includes(item.id));
|
|
1039
|
+
}
|
|
1040
|
+
isSelected(id) {
|
|
1041
|
+
if (!this.selectable) {
|
|
1042
|
+
return false;
|
|
1043
|
+
}
|
|
1044
|
+
if (!this.selectionModel.hasValue()) {
|
|
1045
|
+
return false;
|
|
1046
|
+
}
|
|
1047
|
+
return this.selectionModel.isSelected(id);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
GanttUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttUpper, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1051
|
+
GanttUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: GanttUpper, inputs: { originItems: ["items", "originItems"], originGroups: ["groups", "originGroups"], viewType: "viewType", start: "start", end: "end", showTodayLine: "showTodayLine", draggable: "draggable", styles: "styles", viewOptions: "viewOptions", linkOptions: "linkOptions", disabledLoadOnScroll: "disabledLoadOnScroll", selectable: "selectable", multiple: "multiple" }, outputs: { loadOnScroll: "loadOnScroll", dragStarted: "dragStarted", dragMoved: "dragMoved", dragEnded: "dragEnded", barClick: "barClick" }, host: { properties: { "class.gantt": "this.ganttClass" } }, queries: [{ propertyName: "barTemplate", first: true, predicate: ["bar"], descendants: true, static: true }, { propertyName: "rangeTemplate", first: true, predicate: ["range"], descendants: true, static: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, static: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true, static: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ["groupHeader"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0 });
|
|
1052
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttUpper, decorators: [{
|
|
1053
|
+
type: Directive
|
|
1054
|
+
}], ctorParameters: function () {
|
|
1055
|
+
return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
|
1056
|
+
type: Inject,
|
|
1057
|
+
args: [GANTT_GLOBAL_CONFIG]
|
|
1058
|
+
}] }];
|
|
1059
|
+
}, propDecorators: { originItems: [{
|
|
1060
|
+
type: Input,
|
|
1061
|
+
args: ['items']
|
|
1062
|
+
}], originGroups: [{
|
|
1063
|
+
type: Input,
|
|
1064
|
+
args: ['groups']
|
|
1065
|
+
}], viewType: [{
|
|
1066
|
+
type: Input
|
|
1067
|
+
}], start: [{
|
|
1068
|
+
type: Input
|
|
1069
|
+
}], end: [{
|
|
1070
|
+
type: Input
|
|
1071
|
+
}], showTodayLine: [{
|
|
1072
|
+
type: Input
|
|
1073
|
+
}], draggable: [{
|
|
1074
|
+
type: Input
|
|
1075
|
+
}], styles: [{
|
|
1076
|
+
type: Input
|
|
1077
|
+
}], viewOptions: [{
|
|
1078
|
+
type: Input
|
|
1079
|
+
}], linkOptions: [{
|
|
1080
|
+
type: Input
|
|
1081
|
+
}], disabledLoadOnScroll: [{
|
|
1082
|
+
type: Input
|
|
1083
|
+
}], selectable: [{
|
|
1084
|
+
type: Input
|
|
1085
|
+
}], multiple: [{
|
|
1086
|
+
type: Input
|
|
1087
|
+
}], loadOnScroll: [{
|
|
1088
|
+
type: Output
|
|
1089
|
+
}], dragStarted: [{
|
|
1090
|
+
type: Output
|
|
1091
|
+
}], dragMoved: [{
|
|
1092
|
+
type: Output
|
|
1093
|
+
}], dragEnded: [{
|
|
1094
|
+
type: Output
|
|
1095
|
+
}], barClick: [{
|
|
1096
|
+
type: Output
|
|
1097
|
+
}], barTemplate: [{
|
|
1098
|
+
type: ContentChild,
|
|
1099
|
+
args: ['bar', { static: true }]
|
|
1100
|
+
}], rangeTemplate: [{
|
|
1101
|
+
type: ContentChild,
|
|
1102
|
+
args: ['range', { static: true }]
|
|
1103
|
+
}], itemTemplate: [{
|
|
1104
|
+
type: ContentChild,
|
|
1105
|
+
args: ['item', { static: true }]
|
|
1106
|
+
}], groupTemplate: [{
|
|
1107
|
+
type: ContentChild,
|
|
1108
|
+
args: ['group', { static: true }]
|
|
1109
|
+
}], groupHeaderTemplate: [{
|
|
1110
|
+
type: ContentChild,
|
|
1111
|
+
args: ['groupHeader', { static: true }]
|
|
1112
|
+
}], ganttClass: [{
|
|
1113
|
+
type: HostBinding,
|
|
1114
|
+
args: ['class.gantt']
|
|
1115
|
+
}] } });
|
|
1116
|
+
const GANTT_UPPER_TOKEN = new InjectionToken('GANTT_UPPER_TOKEN');
|
|
1117
|
+
|
|
1118
|
+
class NgxGanttTableColumnComponent {
|
|
1119
|
+
constructor(ganttUpper) {
|
|
1120
|
+
this.ganttUpper = ganttUpper;
|
|
1121
|
+
}
|
|
1122
|
+
set width(width) {
|
|
1123
|
+
this.columnWidth = coerceCssPixelValue(width);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
|
|
1127
|
+
NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
|
|
1128
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttTableColumnComponent, decorators: [{
|
|
1129
|
+
type: Component,
|
|
1130
|
+
args: [{
|
|
1131
|
+
selector: 'ngx-gantt-column',
|
|
1132
|
+
template: ''
|
|
1133
|
+
}]
|
|
1134
|
+
}], ctorParameters: function () {
|
|
1135
|
+
return [{ type: GanttUpper, decorators: [{
|
|
1136
|
+
type: Inject,
|
|
1137
|
+
args: [GANTT_UPPER_TOKEN]
|
|
1138
|
+
}] }];
|
|
1139
|
+
}, propDecorators: { width: [{
|
|
1140
|
+
type: Input
|
|
1141
|
+
}], name: [{
|
|
1142
|
+
type: Input
|
|
1143
|
+
}], templateRef: [{
|
|
1144
|
+
type: ContentChild,
|
|
1145
|
+
args: ['cell', { static: true }]
|
|
1146
|
+
}], headerTemplateRef: [{
|
|
1147
|
+
type: ContentChild,
|
|
1148
|
+
args: ['header', { static: true }]
|
|
1149
|
+
}] } });
|
|
1150
|
+
|
|
1151
|
+
class NgxGanttTableComponent {
|
|
1152
|
+
constructor() {
|
|
1153
|
+
this.columnChanges = new EventEmitter();
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
NgxGanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1157
|
+
NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: NgxGanttTableComponent, selector: "ngx-gantt-table", outputs: { columnChanges: "columnChanges" }, queries: [{ propertyName: "rowBeforeTemplate", first: true, predicate: ["rowBeforeSlot"], descendants: true, static: true }, { propertyName: "rowAfterTemplate", first: true, predicate: ["rowAfterSlot"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
|
|
1158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttTableComponent, decorators: [{
|
|
1159
|
+
type: Component,
|
|
1160
|
+
args: [{
|
|
1161
|
+
selector: 'ngx-gantt-table',
|
|
1162
|
+
template: ''
|
|
1163
|
+
}]
|
|
1164
|
+
}], propDecorators: { columnChanges: [{
|
|
1165
|
+
type: Output
|
|
1166
|
+
}], rowBeforeTemplate: [{
|
|
1167
|
+
type: ContentChild,
|
|
1168
|
+
args: ['rowBeforeSlot', { static: true }]
|
|
1169
|
+
}], rowAfterTemplate: [{
|
|
1170
|
+
type: ContentChild,
|
|
1171
|
+
args: ['rowAfterSlot', { static: true }]
|
|
1172
|
+
}] } });
|
|
1173
|
+
|
|
1174
|
+
const GANTT_ABSTRACT_TOKEN = new InjectionToken('gantt-abstract-token');
|
|
1175
|
+
|
|
1176
|
+
const supports = (typeof window !== 'undefined' && !!window.CSS && CSS.supports) || (() => false);
|
|
1177
|
+
/**
|
|
1178
|
+
* Note: we don't need to add vendor prefixes within `.scss` files since they're added automatically.
|
|
1179
|
+
* This function is necessary when the `element.style` is updated directly through the JavaScript.
|
|
1180
|
+
* This is not required to be used with CSS properties that don't require vendor prefixes (e.g. `opacity`).
|
|
1181
|
+
*/
|
|
1182
|
+
function setStyleWithVendorPrefix({ element, style, value }) {
|
|
1183
|
+
element.style[style] = value;
|
|
1184
|
+
if (supports(`-webkit-${style}: ${value}`)) {
|
|
1185
|
+
// Note: some browsers still require setting `-webkit` vendor prefix. E.g. Mozilla 49 has implemented
|
|
1186
|
+
// the 3D support for `transform`, but it requires setting `-webkit-` prefix.
|
|
1187
|
+
element.style[`-webkit-${style}`] = value;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
const angleRight = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="amnavigation/angle-right" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.498l-.005.005L2.3 5.831 3.13 5l4.848 4.848L12.826 5l.83.831-5.673 5.672-.005-.005z" transform="rotate(-90 7.978 8.252)"></path></g></svg>`;
|
|
1192
|
+
const angleDown = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="aknavigation/angle-down" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.997l-.005.006L2.3 6.33l.83-.831 4.848 4.848L12.826 5.5l.83.83-5.673 5.673-.005-.006z" ></path></g></svg>`;
|
|
1193
|
+
const plusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="kxaction/plus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm5.45 6.2V4.75h1.2V7.4h2.65v1.2H8.65v2.65h-1.2V8.6H4.8V7.4h2.65z"></path></g></svg>`;
|
|
1194
|
+
const minusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="jnaction/minus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm2.8 6.2h6.5v1.2H4.8V7.4z"></path></g></svg>`;
|
|
1195
|
+
const loadingIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve">
|
|
1196
|
+
<path fill="#aaa" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)">
|
|
1197
|
+
<animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform>
|
|
1198
|
+
</path>
|
|
1199
|
+
</svg>`;
|
|
1200
|
+
const emptyIcon = `<svg
|
|
1201
|
+
width="148px"
|
|
1202
|
+
height="134px"
|
|
1203
|
+
viewBox="0 0 148 134"
|
|
1204
|
+
version="1.1"
|
|
1205
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1206
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
1207
|
+
>
|
|
1208
|
+
<defs>
|
|
1209
|
+
<filter x="0.0%" y="0.0%" width="100.0%" height="100.0%" filterUnits="objectBoundingBox" id="filter-1">
|
|
1210
|
+
<feGaussianBlur stdDeviation="0" in="SourceGraphic"></feGaussianBlur>
|
|
1211
|
+
</filter>
|
|
1212
|
+
</defs>
|
|
1213
|
+
<g id="148x134" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
1214
|
+
<g id="编组-6" transform="translate(1.000000, 1.000000)">
|
|
1215
|
+
<ellipse
|
|
1216
|
+
id="椭圆形"
|
|
1217
|
+
fill="#EDEEF2"
|
|
1218
|
+
opacity="0.3"
|
|
1219
|
+
filter="url(#filter-1)"
|
|
1220
|
+
cx="73.0800017"
|
|
1221
|
+
cy="115.920003"
|
|
1222
|
+
rx="73.0800017"
|
|
1223
|
+
ry="16.8000004"
|
|
1224
|
+
></ellipse>
|
|
1225
|
+
<g id="编组-5" transform="translate(15.120000, 0.000000)">
|
|
1226
|
+
<polygon
|
|
1227
|
+
id="矩形"
|
|
1228
|
+
fill="#E2E4E9"
|
|
1229
|
+
points="19.2789848 49.5600011 99.1200023 48.7200011 117.600003 75.9297673 117.600003 92.313049 0 92.313049 0 75.0356267"
|
|
1230
|
+
></polygon>
|
|
1231
|
+
<path
|
|
1232
|
+
d="M23.5200005,0 L94.0800002,0 C97.7913538,2.06413823e-16 100.8,3.00864655 100.8,6.72000015 L100.8,99.1200023 L100.8,99.1200023 L16.8000004,99.1200023 L16.8000004,6.72000015 C16.8000004,3.00864655 19.8086469,1.56994302e-15 23.5200005,0 Z"
|
|
1233
|
+
id="矩形"
|
|
1234
|
+
fill="#F9FAFB"
|
|
1235
|
+
></path>
|
|
1236
|
+
<path
|
|
1237
|
+
d="M30.9200007,12.4400003 L86.6800019,12.4400003 C88.5356787,12.4400003 90.040002,13.9443236 90.040002,15.8000004 L90.040002,42.000001 C90.040002,43.8556778 88.5356787,45.360001 86.6800019,45.360001 L30.9200007,45.360001 C29.0643239,45.360001 27.5600006,43.8556778 27.5600006,42.000001 L27.5600006,15.8000004 C27.5600006,13.9443236 29.0643239,12.4400003 30.9200007,12.4400003 Z"
|
|
1238
|
+
id="矩形"
|
|
1239
|
+
fill="#E8EAEE"
|
|
1240
|
+
></path>
|
|
1241
|
+
<text
|
|
1242
|
+
id="</null>"
|
|
1243
|
+
font-family="PingFangSC-Medium, PingFang SC"
|
|
1244
|
+
font-size="15.1200003"
|
|
1245
|
+
font-weight="400"
|
|
1246
|
+
fill="#BCBECD"
|
|
1247
|
+
>
|
|
1248
|
+
<tspan x="33.6000008" y="32.8000004"></null></tspan>
|
|
1249
|
+
</text>
|
|
1250
|
+
<rect id="矩形" fill="#E8EAEE" x="27.5600006" y="52.0800012" width="61.4800014" height="5.04000011" rx="2.52000006"></rect>
|
|
1251
|
+
<rect
|
|
1252
|
+
id="矩形备份"
|
|
1253
|
+
fill="#E8EAEE"
|
|
1254
|
+
x="27.5600006"
|
|
1255
|
+
y="63.8400014"
|
|
1256
|
+
width="61.4800014"
|
|
1257
|
+
height="5.04000011"
|
|
1258
|
+
rx="2.52000006"
|
|
1259
|
+
></rect>
|
|
1260
|
+
<path
|
|
1261
|
+
d="M0,75.6000017 L29.280235,75.6000017 C32.0637502,75.6000017 34.3202352,77.8564866 34.3202352,80.6400018 L34.3202352,86.2591426 C34.3202352,89.0426578 36.5767201,91.2991427 39.3602353,91.2991427 L78.4136737,91.2991427 C81.1971889,91.2991427 83.4536738,89.0426578 83.4536738,86.2591426 L83.4536738,80.6400018 C83.4536738,77.8564866 85.7101587,75.6000017 88.4936739,75.6000017 L117.600003,75.6000017 L117.600003,75.6000017 L117.600003,110.880003 C117.600003,115.519195 113.839194,119.280003 109.200002,119.280003 L8.40000019,119.280003 C3.76080819,119.280003 -6.53729019e-15,115.519195 0,110.880003 L0,75.6000017 L0,75.6000017 Z"
|
|
1262
|
+
id="矩形"
|
|
1263
|
+
fill="#EDEFF2"
|
|
1264
|
+
></path>
|
|
1265
|
+
</g>
|
|
1266
|
+
</g>
|
|
1267
|
+
</g>
|
|
1268
|
+
</svg>`;
|
|
1269
|
+
const icons = {
|
|
1270
|
+
'angle-right': angleRight,
|
|
1271
|
+
'angle-down': angleDown,
|
|
1272
|
+
'plus-square': plusSquare,
|
|
1273
|
+
'minus-square': minusSquare,
|
|
1274
|
+
loading: loadingIcon,
|
|
1275
|
+
empty: emptyIcon
|
|
1276
|
+
};
|
|
1277
|
+
|
|
1278
|
+
class GanttIconComponent {
|
|
1279
|
+
constructor(elementRef) {
|
|
1280
|
+
this.elementRef = elementRef;
|
|
1281
|
+
this.isIcon = true;
|
|
1282
|
+
}
|
|
1283
|
+
set iconName(name) {
|
|
1284
|
+
this.setSvg(name);
|
|
1285
|
+
}
|
|
1286
|
+
setSvg(name) {
|
|
1287
|
+
const iconSvg = icons[name];
|
|
1288
|
+
if (iconSvg) {
|
|
1289
|
+
this.elementRef.nativeElement.innerHTML = iconSvg;
|
|
1290
|
+
}
|
|
1291
|
+
else {
|
|
1292
|
+
this.elementRef.nativeElement.innerHTML = '';
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
GanttIconComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttIconComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1297
|
+
GanttIconComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: GanttIconComponent, selector: "gantt-icon", inputs: { iconName: "iconName" }, host: { properties: { "class.gantt-icon": "this.isIcon" } }, ngImport: i0, template: '', isInline: true });
|
|
1298
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttIconComponent, decorators: [{
|
|
1299
|
+
type: Component,
|
|
1300
|
+
args: [{
|
|
1301
|
+
selector: 'gantt-icon',
|
|
1302
|
+
template: ''
|
|
1303
|
+
}]
|
|
1304
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { isIcon: [{
|
|
1305
|
+
type: HostBinding,
|
|
1306
|
+
args: ['class.gantt-icon']
|
|
1307
|
+
}], iconName: [{
|
|
1308
|
+
type: Input
|
|
1309
|
+
}] } });
|
|
1310
|
+
|
|
1311
|
+
class IsGanttRangeItemPipe {
|
|
1312
|
+
transform(value) {
|
|
1313
|
+
return value === GanttItemType.range;
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
IsGanttRangeItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttRangeItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1317
|
+
IsGanttRangeItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttRangeItemPipe, name: "isGanttRangeItem" });
|
|
1318
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttRangeItemPipe, decorators: [{
|
|
1319
|
+
type: Pipe,
|
|
1320
|
+
args: [{
|
|
1321
|
+
name: 'isGanttRangeItem'
|
|
1322
|
+
}]
|
|
1323
|
+
}] });
|
|
1324
|
+
class IsGanttBarItemPipe {
|
|
1325
|
+
transform(value) {
|
|
1326
|
+
return value === GanttItemType.bar;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
IsGanttBarItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttBarItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1330
|
+
IsGanttBarItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttBarItemPipe, name: "isGanttBarItem" });
|
|
1331
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttBarItemPipe, decorators: [{
|
|
1332
|
+
type: Pipe,
|
|
1333
|
+
args: [{
|
|
1334
|
+
name: 'isGanttBarItem'
|
|
1335
|
+
}]
|
|
1336
|
+
}] });
|
|
1337
|
+
class IsGanttCustomItemPipe {
|
|
1338
|
+
transform(value) {
|
|
1339
|
+
return value === GanttItemType.custom;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
IsGanttCustomItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttCustomItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
1343
|
+
IsGanttCustomItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttCustomItemPipe, name: "isGanttCustomItem" });
|
|
1344
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: IsGanttCustomItemPipe, decorators: [{
|
|
1345
|
+
type: Pipe,
|
|
1346
|
+
args: [{
|
|
1347
|
+
name: 'isGanttCustomItem'
|
|
1348
|
+
}]
|
|
1349
|
+
}] });
|
|
1350
|
+
|
|
1351
|
+
const defaultColumnWidth = 100;
|
|
1352
|
+
const minColumnWidth = 80;
|
|
1353
|
+
class GanttTableComponent {
|
|
1354
|
+
constructor(gantt, ganttUpper, elementRef) {
|
|
1355
|
+
this.gantt = gantt;
|
|
1356
|
+
this.ganttUpper = ganttUpper;
|
|
1357
|
+
this.elementRef = elementRef;
|
|
1358
|
+
this.itemClick = new EventEmitter();
|
|
1359
|
+
this.ganttTableClass = true;
|
|
1360
|
+
this.ganttTableEmptyClass = false;
|
|
1361
|
+
}
|
|
1362
|
+
set columns(columns) {
|
|
1363
|
+
columns.forEach((column) => {
|
|
1364
|
+
if (!column.columnWidth) {
|
|
1365
|
+
column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
this.columnList = columns;
|
|
1369
|
+
}
|
|
1370
|
+
ngOnChanges(changes) {
|
|
1371
|
+
var _a, _b;
|
|
1372
|
+
if (!((_a = changes.groups.currentValue) === null || _a === void 0 ? void 0 : _a.length) && !((_b = changes.items.currentValue) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
1373
|
+
this.ganttTableEmptyClass = true;
|
|
1374
|
+
}
|
|
1375
|
+
else {
|
|
1376
|
+
this.ganttTableEmptyClass = false;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
dragFixed(config) {
|
|
1380
|
+
if (config.movedWidth < config.minWidth) {
|
|
1381
|
+
setStyleWithVendorPrefix({
|
|
1382
|
+
element: config.target,
|
|
1383
|
+
style: 'transform',
|
|
1384
|
+
value: `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
expandGroup(group) {
|
|
1389
|
+
this.gantt.expandGroup(group);
|
|
1390
|
+
}
|
|
1391
|
+
expandChildren(event, item) {
|
|
1392
|
+
event.stopPropagation();
|
|
1393
|
+
this.gantt.expandChildren(item);
|
|
1394
|
+
}
|
|
1395
|
+
dragStarted(event) {
|
|
1396
|
+
const target = event.source.element.nativeElement;
|
|
1397
|
+
this.dragStartLeft = target.getBoundingClientRect().left;
|
|
1398
|
+
}
|
|
1399
|
+
dragMoved(event, column) {
|
|
1400
|
+
const target = event.source.element.nativeElement;
|
|
1401
|
+
const left = target.getBoundingClientRect().left;
|
|
1402
|
+
let originWidth;
|
|
1403
|
+
let movedWidth;
|
|
1404
|
+
let minWidth;
|
|
1405
|
+
if (column) {
|
|
1406
|
+
originWidth = parseInt(column.columnWidth, 10);
|
|
1407
|
+
movedWidth = originWidth + (left - this.dragStartLeft);
|
|
1408
|
+
minWidth = minColumnWidth;
|
|
1409
|
+
}
|
|
1410
|
+
else {
|
|
1411
|
+
originWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
|
|
1412
|
+
movedWidth = originWidth + (left - this.dragStartLeft);
|
|
1413
|
+
minWidth = minColumnWidth * this.columnList.length;
|
|
1414
|
+
}
|
|
1415
|
+
this.dragFixed({
|
|
1416
|
+
target,
|
|
1417
|
+
originWidth,
|
|
1418
|
+
movedWidth,
|
|
1419
|
+
minWidth
|
|
1420
|
+
});
|
|
1421
|
+
this.showAuxiliaryLine(event);
|
|
1422
|
+
}
|
|
1423
|
+
columnDragEnded(event, column) {
|
|
1424
|
+
const target = event.source.element.nativeElement;
|
|
1425
|
+
const left = target.getBoundingClientRect().left;
|
|
1426
|
+
const width = parseInt(column.columnWidth, 10) + (left - this.dragStartLeft);
|
|
1427
|
+
const columnWidth = Math.max(width || 0, minColumnWidth);
|
|
1428
|
+
column.columnWidth = coerceCssPixelValue(columnWidth);
|
|
1429
|
+
if (this.gantt.table) {
|
|
1430
|
+
this.gantt.table.columnChanges.emit({ columns: this.columnList });
|
|
1431
|
+
}
|
|
1432
|
+
this.hideAuxiliaryLine();
|
|
1433
|
+
event.source.reset();
|
|
1434
|
+
}
|
|
1435
|
+
tableDragEnded(event) {
|
|
1436
|
+
const target = event.source.element.nativeElement;
|
|
1437
|
+
const left = target.getBoundingClientRect().left;
|
|
1438
|
+
const tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
|
|
1439
|
+
const dragWidth = left - this.dragStartLeft;
|
|
1440
|
+
this.columnList.forEach((column) => {
|
|
1441
|
+
const lastColumnWidth = parseInt(column.columnWidth, 10);
|
|
1442
|
+
const distributeWidth = parseInt(String(dragWidth * (lastColumnWidth / tableWidth)), 10);
|
|
1443
|
+
const columnWidth = Math.max(lastColumnWidth + distributeWidth || 0, minColumnWidth);
|
|
1444
|
+
column.columnWidth = coerceCssPixelValue(columnWidth);
|
|
1445
|
+
});
|
|
1446
|
+
if (this.gantt.table) {
|
|
1447
|
+
this.gantt.table.columnChanges.emit({ columns: this.columnList });
|
|
1448
|
+
}
|
|
1449
|
+
this.hideAuxiliaryLine();
|
|
1450
|
+
event.source.reset();
|
|
1451
|
+
}
|
|
1452
|
+
showAuxiliaryLine(event) {
|
|
1453
|
+
const tableRect = this.elementRef.nativeElement.getBoundingClientRect();
|
|
1454
|
+
this.draglineElementRef.nativeElement.style.left = `${event.event.clientX - tableRect.left}px`;
|
|
1455
|
+
this.draglineElementRef.nativeElement.style.display = 'block';
|
|
1456
|
+
}
|
|
1457
|
+
hideAuxiliaryLine() {
|
|
1458
|
+
this.draglineElementRef.nativeElement.style.display = 'none';
|
|
1459
|
+
}
|
|
1460
|
+
trackBy(index, item) {
|
|
1461
|
+
return item.id || index;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
GanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttTableComponent, deps: [{ token: GANTT_ABSTRACT_TOKEN }, { token: GANTT_UPPER_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1465
|
+
GanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: GanttTableComponent, selector: "gantt-table", inputs: { groups: "groups", items: "items", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate", rowBeforeTemplate: "rowBeforeTemplate", rowAfterTemplate: "rowAfterTemplate" }, outputs: { itemClick: "itemClick" }, host: { properties: { "class.gantt-table": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass" } }, viewQueries: [{ propertyName: "draglineElementRef", first: true, predicate: ["dragLine"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-table-header gantt-table-row\">\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let i = index\" [style.width]=\"column.columnWidth\">\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"></ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event, column)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"columnDragEnded($event, column)\"\n ></div>\n </div>\n</div>\n<div class=\"gantt-table-body\">\n <ng-container *ngIf=\"!groups.length && !items.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"groups && groups.length > 0; else itemsTemplate\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"group.class\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"group.expanded\" (click)=\"expandGroup(group)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"group.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: group.origin, group: group.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ group.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <ng-container *ngIf=\"group.expanded\">\n <ng-template\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ group: group, items: group.items, level: 0 }\"\n ></ng-template>\n </ng-container>\n </ng-container>\n </ng-container>\n</div>\n\n<div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"tableDragEnded($event)\"\n></div>\n\n<div #dragLine class=\"gantt-table-drag-auxiliary-line\"></div>\n\n<ng-template #itemsTemplate>\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items, level: 0 }\"></ng-template>\n</ng-template>\n\n<ng-template #ganttItems let-group=\"group\" let-items=\"items\" let-level=\"level\">\n <ng-container *ngFor=\"let item of items; trackBy: trackBy\">\n <div\n (click)=\"itemClick.emit({ event: $event, selectedValue: this.item.origin })\"\n class=\"gantt-table-item gantt-table-row\"\n [class.gantt-table-item-first-level-group]=\"level === 0 && (item.type | isGanttRangeItem)\"\n [class.gantt-table-item-with-group]=\"group\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let first = first\" [style.width]=\"column.columnWidth\">\n <div *ngIf=\"first\" class=\"gantt-expand-icon\" [style.marginLeft.px]=\"level * 20\">\n <ng-container *ngIf=\"level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n ></gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children, level: level + 1, group: group }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n", components: [{ type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }], directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], pipes: { "isGanttRangeItem": IsGanttRangeItemPipe } });
|
|
1466
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttTableComponent, decorators: [{
|
|
1467
|
+
type: Component,
|
|
1468
|
+
args: [{ selector: 'gantt-table', template: "<div class=\"gantt-table-header gantt-table-row\">\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let i = index\" [style.width]=\"column.columnWidth\">\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"></ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event, column)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"columnDragEnded($event, column)\"\n ></div>\n </div>\n</div>\n<div class=\"gantt-table-body\">\n <ng-container *ngIf=\"!groups.length && !items.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"groups && groups.length > 0; else itemsTemplate\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"group.class\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"group.expanded\" (click)=\"expandGroup(group)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"group.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: group.origin, group: group.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ group.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <ng-container *ngIf=\"group.expanded\">\n <ng-template\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ group: group, items: group.items, level: 0 }\"\n ></ng-template>\n </ng-container>\n </ng-container>\n </ng-container>\n</div>\n\n<div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"tableDragEnded($event)\"\n></div>\n\n<div #dragLine class=\"gantt-table-drag-auxiliary-line\"></div>\n\n<ng-template #itemsTemplate>\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items, level: 0 }\"></ng-template>\n</ng-template>\n\n<ng-template #ganttItems let-group=\"group\" let-items=\"items\" let-level=\"level\">\n <ng-container *ngFor=\"let item of items; trackBy: trackBy\">\n <div\n (click)=\"itemClick.emit({ event: $event, selectedValue: this.item.origin })\"\n class=\"gantt-table-item gantt-table-row\"\n [class.gantt-table-item-first-level-group]=\"level === 0 && (item.type | isGanttRangeItem)\"\n [class.gantt-table-item-with-group]=\"group\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let first = first\" [style.width]=\"column.columnWidth\">\n <div *ngIf=\"first\" class=\"gantt-expand-icon\" [style.marginLeft.px]=\"level * 20\">\n <ng-container *ngIf=\"level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n ></gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children, level: level + 1, group: group }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n" }]
|
|
1469
|
+
}], ctorParameters: function () {
|
|
1470
|
+
return [{ type: undefined, decorators: [{
|
|
1471
|
+
type: Inject,
|
|
1472
|
+
args: [GANTT_ABSTRACT_TOKEN]
|
|
1473
|
+
}] }, { type: GanttUpper, decorators: [{
|
|
1474
|
+
type: Inject,
|
|
1475
|
+
args: [GANTT_UPPER_TOKEN]
|
|
1476
|
+
}] }, { type: i0.ElementRef }];
|
|
1477
|
+
}, propDecorators: { groups: [{
|
|
1478
|
+
type: Input
|
|
1479
|
+
}], items: [{
|
|
1480
|
+
type: Input
|
|
1481
|
+
}], columns: [{
|
|
1482
|
+
type: Input
|
|
1483
|
+
}], groupTemplate: [{
|
|
1484
|
+
type: Input
|
|
1485
|
+
}], emptyTemplate: [{
|
|
1486
|
+
type: Input
|
|
1487
|
+
}], rowBeforeTemplate: [{
|
|
1488
|
+
type: Input
|
|
1489
|
+
}], rowAfterTemplate: [{
|
|
1490
|
+
type: Input
|
|
1491
|
+
}], itemClick: [{
|
|
1492
|
+
type: Output
|
|
1493
|
+
}], draglineElementRef: [{
|
|
1494
|
+
type: ViewChild,
|
|
1495
|
+
args: ['dragLine', { static: true }]
|
|
1496
|
+
}], ganttTableClass: [{
|
|
1497
|
+
type: HostBinding,
|
|
1498
|
+
args: ['class.gantt-table']
|
|
1499
|
+
}], ganttTableEmptyClass: [{
|
|
1500
|
+
type: HostBinding,
|
|
1501
|
+
args: ['class.gantt-table-empty']
|
|
1502
|
+
}] } });
|
|
1503
|
+
|
|
1504
|
+
/** Cached result of whether the user's browser supports passive event listeners. */
|
|
1505
|
+
let supportsPassiveEvents;
|
|
1506
|
+
/**
|
|
1507
|
+
* Checks whether the user's browser supports passive event listeners.
|
|
1508
|
+
* See: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
|
|
1509
|
+
*/
|
|
1510
|
+
function supportsPassiveEventListeners() {
|
|
1511
|
+
if (supportsPassiveEvents == null && typeof window !== 'undefined') {
|
|
1512
|
+
try {
|
|
1513
|
+
window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
|
|
1514
|
+
get: () => (supportsPassiveEvents = true)
|
|
1515
|
+
}));
|
|
1516
|
+
}
|
|
1517
|
+
finally {
|
|
1518
|
+
supportsPassiveEvents = supportsPassiveEvents || false;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
return supportsPassiveEvents;
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Normalizes an `AddEventListener` object to something that can be passed
|
|
1525
|
+
* to `addEventListener` on any browser, no matter whether it supports the
|
|
1526
|
+
* `options` parameter.
|
|
1527
|
+
*/
|
|
1528
|
+
function normalizePassiveListenerOptions(options) {
|
|
1529
|
+
return supportsPassiveEventListeners() ? options : !!options.capture;
|
|
1530
|
+
}
|
|
1531
|
+
/** Options used to bind passive event listeners. */
|
|
1532
|
+
const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
|
|
1533
|
+
|
|
1534
|
+
const scrollThreshold = 50;
|
|
1535
|
+
var ScrollDirection;
|
|
1536
|
+
(function (ScrollDirection) {
|
|
1537
|
+
ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
|
|
1538
|
+
ScrollDirection[ScrollDirection["LEFT"] = 1] = "LEFT";
|
|
1539
|
+
ScrollDirection[ScrollDirection["RIGHT"] = 2] = "RIGHT";
|
|
1540
|
+
})(ScrollDirection || (ScrollDirection = {}));
|
|
1541
|
+
class GanttDomService {
|
|
1542
|
+
constructor(ngZone, platformId) {
|
|
1543
|
+
this.ngZone = ngZone;
|
|
1544
|
+
this.platformId = platformId;
|
|
1545
|
+
this.unsubscribe$ = new Subject();
|
|
1546
|
+
}
|
|
1547
|
+
monitorScrollChange() {
|
|
1548
|
+
this.ngZone.runOutsideAngular(() => merge(fromEvent(this.mainContainer, 'scroll', passiveListenerOptions), fromEvent(this.sideContainer, 'scroll', passiveListenerOptions))
|
|
1549
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1550
|
+
.subscribe((event) => {
|
|
1551
|
+
this.syncScroll(event);
|
|
1552
|
+
}));
|
|
1553
|
+
// fromEvent(this.mainContainer, 'scroll')
|
|
1554
|
+
// .pipe(startWith(), takeUntil(this.unsubscribe$))
|
|
1555
|
+
// .subscribe((event) => {
|
|
1556
|
+
// // if (this.mainContainer.scrollLeft > 0) {
|
|
1557
|
+
// // this.side.classList.add('gantt-side-has-shadow');
|
|
1558
|
+
// // } else {
|
|
1559
|
+
// // this.side.classList.remove('gantt-side-has-shadow');
|
|
1560
|
+
// // }
|
|
1561
|
+
// });
|
|
1562
|
+
}
|
|
1563
|
+
syncScroll(event) {
|
|
1564
|
+
const target = event.currentTarget;
|
|
1565
|
+
this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
|
|
1566
|
+
this.sideContainer.scrollTop = target.scrollTop;
|
|
1567
|
+
this.mainContainer.scrollTop = target.scrollTop;
|
|
1568
|
+
}
|
|
1569
|
+
disableBrowserWheelEvent() {
|
|
1570
|
+
const container = this.mainContainer;
|
|
1571
|
+
this.ngZone.runOutsideAngular(() => fromEvent(container, 'wheel')
|
|
1572
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1573
|
+
.subscribe((event) => {
|
|
1574
|
+
const delta = event.deltaX;
|
|
1575
|
+
if (!delta) {
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1578
|
+
if ((container.scrollLeft + container.offsetWidth === container.scrollWidth && delta > 0) ||
|
|
1579
|
+
(container.scrollLeft === 0 && delta < 0)) {
|
|
1580
|
+
event.preventDefault();
|
|
1581
|
+
}
|
|
1582
|
+
}));
|
|
1583
|
+
}
|
|
1584
|
+
initialize(root) {
|
|
1585
|
+
this.root = root.nativeElement;
|
|
1586
|
+
this.side = this.root.getElementsByClassName('gantt-side')[0];
|
|
1587
|
+
this.container = this.root.getElementsByClassName('gantt-container')[0];
|
|
1588
|
+
this.sideContainer = this.root.getElementsByClassName('gantt-side-container')[0];
|
|
1589
|
+
this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
|
|
1590
|
+
this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-overlay')[0];
|
|
1591
|
+
this.monitorScrollChange();
|
|
1592
|
+
this.disableBrowserWheelEvent();
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* @returns An observable that will emit outside the Angular zone. Note, consumers should re-enter the Angular zone
|
|
1596
|
+
* to run the change detection if needed.
|
|
1597
|
+
*/
|
|
1598
|
+
getViewerScroll(options) {
|
|
1599
|
+
return new Observable((subscriber) => this.ngZone.runOutsideAngular(() => fromEvent(this.mainContainer, 'scroll', options)
|
|
1600
|
+
.pipe(map(() => this.mainContainer.scrollLeft), pairwise(), map(([previous, current]) => {
|
|
1601
|
+
const event = {
|
|
1602
|
+
target: this.mainContainer,
|
|
1603
|
+
direction: ScrollDirection.NONE
|
|
1604
|
+
};
|
|
1605
|
+
if (current - previous < 0) {
|
|
1606
|
+
if (this.mainContainer.scrollLeft < scrollThreshold && this.mainContainer.scrollLeft > 0) {
|
|
1607
|
+
event.direction = ScrollDirection.LEFT;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
if (current - previous > 0) {
|
|
1611
|
+
if (this.mainContainer.scrollWidth - this.mainContainer.clientWidth - this.mainContainer.scrollLeft <
|
|
1612
|
+
scrollThreshold) {
|
|
1613
|
+
event.direction = ScrollDirection.RIGHT;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
return event;
|
|
1617
|
+
}))
|
|
1618
|
+
.subscribe(subscriber)));
|
|
1619
|
+
}
|
|
1620
|
+
getResize() {
|
|
1621
|
+
return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime(150));
|
|
1622
|
+
}
|
|
1623
|
+
scrollMainContainer(left) {
|
|
1624
|
+
if (isNumber(left)) {
|
|
1625
|
+
const scrollLeft = left - this.mainContainer.clientWidth / 2;
|
|
1626
|
+
this.mainContainer.scrollLeft = scrollLeft > scrollThreshold ? scrollLeft : 0;
|
|
1627
|
+
this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
ngOnDestroy() {
|
|
1631
|
+
this.unsubscribe$.next();
|
|
1632
|
+
this.unsubscribe$.complete();
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
GanttDomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDomService, deps: [{ token: i0.NgZone }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1636
|
+
GanttDomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDomService });
|
|
1637
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDomService, decorators: [{
|
|
1638
|
+
type: Injectable
|
|
1639
|
+
}], ctorParameters: function () {
|
|
1640
|
+
return [{ type: i0.NgZone }, { type: undefined, decorators: [{
|
|
1641
|
+
type: Inject,
|
|
1642
|
+
args: [PLATFORM_ID]
|
|
1643
|
+
}] }];
|
|
1644
|
+
} });
|
|
1645
|
+
|
|
1646
|
+
function getDependencyType(path, dependencyTypes) {
|
|
1647
|
+
if (dependencyTypes.includes(GanttLinkType.ss) && path.from.pos === InBarPosition.start && path.to.pos === InBarPosition.start) {
|
|
1648
|
+
return GanttLinkType.ss;
|
|
1649
|
+
}
|
|
1650
|
+
if (dependencyTypes.includes(GanttLinkType.ff) && path.from.pos === InBarPosition.finish && path.to.pos === InBarPosition.finish) {
|
|
1651
|
+
return GanttLinkType.ff;
|
|
1652
|
+
}
|
|
1653
|
+
if (dependencyTypes.includes(GanttLinkType.sf) && path.from.pos === InBarPosition.start && path.to.pos === InBarPosition.finish) {
|
|
1654
|
+
return GanttLinkType.sf;
|
|
1655
|
+
}
|
|
1656
|
+
return GanttLinkType.fs;
|
|
1657
|
+
}
|
|
1658
|
+
var InBarPosition;
|
|
1659
|
+
(function (InBarPosition) {
|
|
1660
|
+
InBarPosition["start"] = "start";
|
|
1661
|
+
InBarPosition["finish"] = "finish";
|
|
1662
|
+
})(InBarPosition || (InBarPosition = {}));
|
|
1663
|
+
class GanttDragContainer {
|
|
1664
|
+
constructor(ganttUpper) {
|
|
1665
|
+
this.ganttUpper = ganttUpper;
|
|
1666
|
+
this.dragStarted = new EventEmitter();
|
|
1667
|
+
this.dragMoved = new EventEmitter();
|
|
1668
|
+
this.dragEnded = new EventEmitter();
|
|
1669
|
+
this.linkDragStarted = new EventEmitter();
|
|
1670
|
+
this.linkDragEntered = new EventEmitter();
|
|
1671
|
+
this.linkDragEnded = new EventEmitter();
|
|
1672
|
+
this.linkDragPath = { from: null, to: null };
|
|
1673
|
+
}
|
|
1674
|
+
emitLinkDragStarted(from) {
|
|
1675
|
+
this.linkDraggingId = from.item.id;
|
|
1676
|
+
this.linkDragPath.from = from;
|
|
1677
|
+
this.linkDragStarted.emit({
|
|
1678
|
+
source: from.item.origin,
|
|
1679
|
+
target: null
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
emitLinkDragEntered(to) {
|
|
1683
|
+
this.linkDragPath.to = to;
|
|
1684
|
+
this.linkDragEntered.emit({
|
|
1685
|
+
source: this.linkDragPath.from.item.origin,
|
|
1686
|
+
target: to.item.origin
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
emitLinkDragLeaved() {
|
|
1690
|
+
this.linkDragPath.to = null;
|
|
1691
|
+
}
|
|
1692
|
+
emitLinkDragEnded(to) {
|
|
1693
|
+
var _a;
|
|
1694
|
+
if (to) {
|
|
1695
|
+
this.linkDragPath.to = to;
|
|
1696
|
+
const dependencyType = getDependencyType(this.linkDragPath, (_a = this.ganttUpper.linkOptions) === null || _a === void 0 ? void 0 : _a.dependencyTypes);
|
|
1697
|
+
this.linkDragPath.from.item.addLink({
|
|
1698
|
+
link: this.linkDragPath.to.item.id,
|
|
1699
|
+
type: dependencyType
|
|
1700
|
+
});
|
|
1701
|
+
this.linkDragEnded.emit({
|
|
1702
|
+
source: this.linkDragPath.from.item.origin,
|
|
1703
|
+
target: this.linkDragPath.to.item.origin,
|
|
1704
|
+
type: dependencyType
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
this.linkDraggingId = null;
|
|
1708
|
+
this.linkDragPath = { from: null, to: null };
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
GanttDragContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragContainer, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1712
|
+
GanttDragContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragContainer });
|
|
1713
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragContainer, decorators: [{
|
|
1714
|
+
type: Injectable
|
|
1715
|
+
}], ctorParameters: function () {
|
|
1716
|
+
return [{ type: GanttUpper, decorators: [{
|
|
1717
|
+
type: Inject,
|
|
1718
|
+
args: [GANTT_UPPER_TOKEN]
|
|
1719
|
+
}] }];
|
|
1720
|
+
} });
|
|
1721
|
+
|
|
1722
|
+
class GanttDragBackdropComponent {
|
|
1723
|
+
}
|
|
1724
|
+
GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1725
|
+
GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { classAttribute: "gantt-drag-backdrop" }, ngImport: i0, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" });
|
|
1726
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
|
|
1727
|
+
type: Component,
|
|
1728
|
+
args: [{ selector: 'gantt-drag-backdrop', host: {
|
|
1729
|
+
class: 'gantt-drag-backdrop'
|
|
1730
|
+
}, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" }]
|
|
1731
|
+
}] });
|
|
1732
|
+
|
|
1733
|
+
class GanttPrintService {
|
|
1734
|
+
constructor() { }
|
|
1735
|
+
setInlineStyles(targetElem) {
|
|
1736
|
+
const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
|
|
1737
|
+
for (const svgElement of svgElements) {
|
|
1738
|
+
this.recursElementChildren(svgElement);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
recursElementChildren(node) {
|
|
1742
|
+
const transformProperties = [
|
|
1743
|
+
'fill',
|
|
1744
|
+
'color',
|
|
1745
|
+
'font-size',
|
|
1746
|
+
'stroke',
|
|
1747
|
+
'font',
|
|
1748
|
+
'text-anchor',
|
|
1749
|
+
'stroke-dasharray',
|
|
1750
|
+
'shape-rendering',
|
|
1751
|
+
'stroke-width'
|
|
1752
|
+
];
|
|
1753
|
+
if (!node.style) {
|
|
1754
|
+
return;
|
|
1755
|
+
}
|
|
1756
|
+
const styles = getComputedStyle(node);
|
|
1757
|
+
for (const transformProperty of transformProperties) {
|
|
1758
|
+
node.style[transformProperty] = styles[transformProperty];
|
|
1759
|
+
}
|
|
1760
|
+
for (const child of Array.from(node.childNodes)) {
|
|
1761
|
+
this.recursElementChildren(child);
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
register(root) {
|
|
1765
|
+
this.root = root.nativeElement;
|
|
1766
|
+
this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
|
|
1767
|
+
}
|
|
1768
|
+
print(name = 'download', ignoreElementClass) {
|
|
1769
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1770
|
+
const root = this.root;
|
|
1771
|
+
const mainContainer = this.mainContainer;
|
|
1772
|
+
// set print width
|
|
1773
|
+
const printWidth = root.offsetWidth;
|
|
1774
|
+
// set print height
|
|
1775
|
+
const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
|
|
1776
|
+
const html2canvas = (yield import(/* webpackChunkName: 'html2canvas' */ 'html2canvas')).default;
|
|
1777
|
+
html2canvas(root, {
|
|
1778
|
+
logging: false,
|
|
1779
|
+
allowTaint: true,
|
|
1780
|
+
useCORS: true,
|
|
1781
|
+
width: printWidth,
|
|
1782
|
+
height: printHeight,
|
|
1783
|
+
ignoreElements: (element) => {
|
|
1784
|
+
if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
|
|
1785
|
+
return true;
|
|
1786
|
+
}
|
|
1787
|
+
if (element.classList.contains('gantt-calendar-today-overlay')) {
|
|
1788
|
+
return true;
|
|
1789
|
+
}
|
|
1790
|
+
},
|
|
1791
|
+
onclone: (cloneDocument) => {
|
|
1792
|
+
const ganttClass = root.className;
|
|
1793
|
+
const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
|
|
1794
|
+
const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
|
|
1795
|
+
const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
|
|
1796
|
+
const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
|
|
1797
|
+
// change targetDom width
|
|
1798
|
+
cloneGanttDom.style.width = `${printWidth}px`;
|
|
1799
|
+
cloneGanttDom.style.height = `${printHeight}px`;
|
|
1800
|
+
cloneGanttDom.style.overflow = `unset`;
|
|
1801
|
+
cloneGanttContainerDom.style.backgroundColor = '#fff';
|
|
1802
|
+
cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
|
|
1803
|
+
cloneCalendarOverlay.setAttribute('style', `background: transparent`);
|
|
1804
|
+
if (cloneLinksOverlay) {
|
|
1805
|
+
cloneLinksOverlay.setAttribute('height', `${printHeight}`);
|
|
1806
|
+
cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
|
|
1807
|
+
}
|
|
1808
|
+
// setInlineStyles for svg
|
|
1809
|
+
this.setInlineStyles(cloneGanttDom);
|
|
1810
|
+
}
|
|
1811
|
+
}).then((canvas) => {
|
|
1812
|
+
const link = document.createElement('a');
|
|
1813
|
+
const dataUrl = canvas.toDataURL('image/png');
|
|
1814
|
+
link.download = `${name}.png`;
|
|
1815
|
+
link.href = dataUrl;
|
|
1816
|
+
link.click();
|
|
1817
|
+
});
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
GanttPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttPrintService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1822
|
+
GanttPrintService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttPrintService });
|
|
1823
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttPrintService, decorators: [{
|
|
1824
|
+
type: Injectable
|
|
1825
|
+
}], ctorParameters: function () { return []; } });
|
|
1826
|
+
|
|
1827
|
+
const mainHeight = 5000;
|
|
1828
|
+
class GanttCalendarComponent {
|
|
1829
|
+
constructor(ganttUpper, ngZone, elementRef) {
|
|
1830
|
+
this.ganttUpper = ganttUpper;
|
|
1831
|
+
this.ngZone = ngZone;
|
|
1832
|
+
this.elementRef = elementRef;
|
|
1833
|
+
this.headerHeight = headerHeight;
|
|
1834
|
+
this.mainHeight = mainHeight;
|
|
1835
|
+
this.todayHeight = todayHeight;
|
|
1836
|
+
this.todayWidth = todayWidth;
|
|
1837
|
+
this.todayBorderRadius = todayBorderRadius;
|
|
1838
|
+
this.viewTypes = GanttViewType;
|
|
1839
|
+
this.className = true;
|
|
1840
|
+
this.unsubscribe$ = new Subject();
|
|
1841
|
+
}
|
|
1842
|
+
get view() {
|
|
1843
|
+
return this.ganttUpper.view;
|
|
1844
|
+
}
|
|
1845
|
+
setTodayPoint() {
|
|
1846
|
+
const x = this.view.getTodayXPoint();
|
|
1847
|
+
const today = new GanttDate().getDate();
|
|
1848
|
+
const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
|
|
1849
|
+
const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
|
|
1850
|
+
const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
|
|
1851
|
+
if (isNumber(x)) {
|
|
1852
|
+
if (rect) {
|
|
1853
|
+
rect.style.left = `${x - todayWidth / 2}px`;
|
|
1854
|
+
rect.style.top = `${headerHeight - todayHeight}px`;
|
|
1855
|
+
rect.innerHTML = today.toString();
|
|
1856
|
+
}
|
|
1857
|
+
if (line) {
|
|
1858
|
+
line.style.left = `${x}px`;
|
|
1859
|
+
line.style.top = `${headerHeight}px`;
|
|
1860
|
+
line.style.bottom = `${-mainHeight}px`;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
else {
|
|
1864
|
+
todayEle.style.display = 'none';
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
ngOnInit() {
|
|
1868
|
+
// Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
|
|
1869
|
+
// the `onStable` will never emit any value.
|
|
1870
|
+
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
|
|
1871
|
+
// Normally this isn't in the zone, but it can cause performance regressions for apps
|
|
1872
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
1873
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1874
|
+
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
1875
|
+
merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
|
|
1876
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1877
|
+
.subscribe(() => {
|
|
1878
|
+
this.setTodayPoint();
|
|
1879
|
+
});
|
|
1880
|
+
});
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
trackBy(index, point) {
|
|
1884
|
+
return point.text || index;
|
|
1885
|
+
}
|
|
1886
|
+
ngOnDestroy() {
|
|
1887
|
+
this.unsubscribe$.next();
|
|
1888
|
+
this.unsubscribe$.complete();
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
GanttCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttCalendarComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1892
|
+
GanttCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: GanttCalendarComponent, selector: "gantt-calendar-overlay", host: { properties: { "class.gantt-calendar-overlay": "this.className" } }, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
|
|
1893
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttCalendarComponent, decorators: [{
|
|
1894
|
+
type: Component,
|
|
1895
|
+
args: [{ selector: 'gantt-calendar-overlay', template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n" }]
|
|
1896
|
+
}], ctorParameters: function () {
|
|
1897
|
+
return [{ type: GanttUpper, decorators: [{
|
|
1898
|
+
type: Inject,
|
|
1899
|
+
args: [GANTT_UPPER_TOKEN]
|
|
1900
|
+
}] }, { type: i0.NgZone }, { type: i0.ElementRef }];
|
|
1901
|
+
}, propDecorators: { className: [{
|
|
1902
|
+
type: HostBinding,
|
|
1903
|
+
args: ['class.gantt-calendar-overlay']
|
|
1904
|
+
}] } });
|
|
1905
|
+
|
|
1906
|
+
class NgxGanttRootComponent {
|
|
1907
|
+
constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
|
|
1908
|
+
this.elementRef = elementRef;
|
|
1909
|
+
this.ngZone = ngZone;
|
|
1910
|
+
this.dom = dom;
|
|
1911
|
+
this.dragContainer = dragContainer;
|
|
1912
|
+
this.ganttUpper = ganttUpper;
|
|
1913
|
+
this.printService = printService;
|
|
1914
|
+
this.unsubscribe$ = new Subject();
|
|
1915
|
+
this.ganttUpper.dragContainer = dragContainer;
|
|
1916
|
+
}
|
|
1917
|
+
get view() {
|
|
1918
|
+
return this.ganttUpper.view;
|
|
1919
|
+
}
|
|
1920
|
+
ngOnInit() {
|
|
1921
|
+
// Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
|
|
1922
|
+
// the `onStable` will never emit any value.
|
|
1923
|
+
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
|
|
1924
|
+
// Normally this isn't in the zone, but it can cause performance regressions for apps
|
|
1925
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
1926
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1927
|
+
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
1928
|
+
this.dom.initialize(this.elementRef);
|
|
1929
|
+
if (this.printService) {
|
|
1930
|
+
this.printService.register(this.elementRef);
|
|
1931
|
+
}
|
|
1932
|
+
this.setupScrollClass();
|
|
1933
|
+
this.setupResize();
|
|
1934
|
+
this.setupViewScroll();
|
|
1935
|
+
// 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
|
|
1936
|
+
this.elementRef.nativeElement.style.opacity = '1';
|
|
1937
|
+
this.ganttUpper.viewChange.pipe(startWith(null), takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
1938
|
+
this.scrollToToday();
|
|
1939
|
+
});
|
|
1940
|
+
});
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
ngOnDestroy() {
|
|
1944
|
+
this.unsubscribe$.next();
|
|
1945
|
+
}
|
|
1946
|
+
setupViewScroll() {
|
|
1947
|
+
if (this.ganttUpper.disabledLoadOnScroll) {
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
this.dom
|
|
1951
|
+
.getViewerScroll(passiveListenerOptions)
|
|
1952
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1953
|
+
.subscribe((event) => {
|
|
1954
|
+
if (event.direction === ScrollDirection.LEFT) {
|
|
1955
|
+
const dates = this.view.addStartDate();
|
|
1956
|
+
if (dates) {
|
|
1957
|
+
event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
|
|
1958
|
+
if (this.ganttUpper.loadOnScroll.observers) {
|
|
1959
|
+
this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
if (event.direction === ScrollDirection.RIGHT) {
|
|
1964
|
+
const dates = this.view.addEndDate();
|
|
1965
|
+
if (dates && this.ganttUpper.loadOnScroll.observers) {
|
|
1966
|
+
this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
setupResize() {
|
|
1972
|
+
this.dom
|
|
1973
|
+
.getResize()
|
|
1974
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1975
|
+
.subscribe(() => {
|
|
1976
|
+
this.setupScrollClass();
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
setupScrollClass() {
|
|
1980
|
+
const mainContainer = this.dom.mainContainer;
|
|
1981
|
+
const height = mainContainer.offsetHeight;
|
|
1982
|
+
const scrollHeight = mainContainer.scrollHeight;
|
|
1983
|
+
if (scrollHeight > height) {
|
|
1984
|
+
this.elementRef.nativeElement.className = 'gantt gantt-scroll';
|
|
1985
|
+
}
|
|
1986
|
+
else {
|
|
1987
|
+
this.elementRef.nativeElement.className = 'gantt';
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
scrollToToday() {
|
|
1991
|
+
const x = this.view.getTodayXPoint();
|
|
1992
|
+
this.dom.scrollMainContainer(x);
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
NgxGanttRootComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttRootComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: GanttDomService }, { token: GanttDragContainer }, { token: GANTT_UPPER_TOKEN }, { token: GanttPrintService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
1996
|
+
NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { classAttribute: "gantt" }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], viewQueries: [{ propertyName: "backdrop", first: true, predicate: GanttDragBackdropComponent, descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\">\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\">\n <gantt-calendar-overlay></gantt-calendar-overlay>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n", components: [{ type: GanttCalendarComponent, selector: "gantt-calendar-overlay" }, { type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }], directives: [{ type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
|
|
1997
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
|
|
1998
|
+
type: Component,
|
|
1999
|
+
args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
|
|
2000
|
+
class: 'gantt'
|
|
2001
|
+
}, template: "<div class=\"gantt-side\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\">\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\">\n <gantt-calendar-overlay></gantt-calendar-overlay>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n" }]
|
|
2002
|
+
}], ctorParameters: function () {
|
|
2003
|
+
return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
|
|
2004
|
+
type: Inject,
|
|
2005
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2006
|
+
}] }, { type: GanttPrintService, decorators: [{
|
|
2007
|
+
type: Optional
|
|
2008
|
+
}] }];
|
|
2009
|
+
}, propDecorators: { sideWidth: [{
|
|
2010
|
+
type: Input
|
|
2011
|
+
}], sideTemplate: [{
|
|
2012
|
+
type: ContentChild,
|
|
2013
|
+
args: ['sideTemplate', { static: true }]
|
|
2014
|
+
}], mainTemplate: [{
|
|
2015
|
+
type: ContentChild,
|
|
2016
|
+
args: ['mainTemplate', { static: true }]
|
|
2017
|
+
}], backdrop: [{
|
|
2018
|
+
type: ViewChild,
|
|
2019
|
+
args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
|
|
2020
|
+
}] } });
|
|
2021
|
+
|
|
2022
|
+
class GanttLinkLine {
|
|
2023
|
+
constructor() { }
|
|
2024
|
+
generatePath(source, target, type) {
|
|
2025
|
+
if (source.before && source.after && target.before && target.after) {
|
|
2026
|
+
let path = '';
|
|
2027
|
+
switch (type) {
|
|
2028
|
+
case GanttLinkType.ss:
|
|
2029
|
+
path = this.generateSSPath(source, target);
|
|
2030
|
+
break;
|
|
2031
|
+
case GanttLinkType.ff:
|
|
2032
|
+
path = this.generateFFPath(source, target);
|
|
2033
|
+
break;
|
|
2034
|
+
case GanttLinkType.sf:
|
|
2035
|
+
path = this.generateFSAndSFPath(source, target, type);
|
|
2036
|
+
break;
|
|
2037
|
+
default:
|
|
2038
|
+
path = this.generateFSAndSFPath(source, target);
|
|
2039
|
+
}
|
|
2040
|
+
return path;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
let GanttLinkLineCurve = class GanttLinkLineCurve extends GanttLinkLine {
|
|
2046
|
+
constructor(ganttUpper) {
|
|
2047
|
+
super();
|
|
2048
|
+
this.ganttUpper = ganttUpper;
|
|
2049
|
+
}
|
|
2050
|
+
generateSSPath(source, target) {
|
|
2051
|
+
const x1 = source.before.x;
|
|
2052
|
+
const y1 = source.before.y;
|
|
2053
|
+
const x4 = target.before.x;
|
|
2054
|
+
const y4 = target.before.y;
|
|
2055
|
+
const isMirror = y4 > y1 ? 0 : 1;
|
|
2056
|
+
const radius = Math.abs(y4 - y1) / 2;
|
|
2057
|
+
if (x4 > x1) {
|
|
2058
|
+
return `M ${x1} ${y1}
|
|
2059
|
+
A ${radius} ${radius} 0 1 ${isMirror} ${x1} ${y4}
|
|
2060
|
+
L ${x4} ${y4}`;
|
|
2061
|
+
}
|
|
2062
|
+
else {
|
|
2063
|
+
return `M ${x1} ${y1}
|
|
2064
|
+
L ${x4} ${y1}
|
|
2065
|
+
A ${radius} ${radius} 0 1 ${isMirror} ${x4} ${y4}`;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
generateFFPath(source, target) {
|
|
2069
|
+
const x1 = source.after.x;
|
|
2070
|
+
const y1 = source.after.y;
|
|
2071
|
+
const x4 = target.after.x;
|
|
2072
|
+
const y4 = target.after.y;
|
|
2073
|
+
const isMirror = y4 > y1 ? 1 : 0;
|
|
2074
|
+
const radius = Math.abs(y4 - y1) / 2;
|
|
2075
|
+
if (x4 > x1) {
|
|
2076
|
+
return `M ${x1} ${y1}
|
|
2077
|
+
L ${x4} ${y1}
|
|
2078
|
+
A ${radius} ${radius} 0 1 ${isMirror} ${x4} ${y4}`;
|
|
2079
|
+
}
|
|
2080
|
+
else {
|
|
2081
|
+
return `M ${x1} ${y1}
|
|
2082
|
+
A ${radius} ${radius} 0 1 ${isMirror} ${x1} ${y4}
|
|
2083
|
+
L ${x4} ${y4}`;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
generateFSAndSFPath(source, target, type) {
|
|
2087
|
+
var _a;
|
|
2088
|
+
let x1 = source.after.x;
|
|
2089
|
+
let y1 = source.after.y;
|
|
2090
|
+
let x4 = target.before.x;
|
|
2091
|
+
let y4 = target.before.y;
|
|
2092
|
+
const bezierWeight = 0.5;
|
|
2093
|
+
if (type === GanttLinkType.sf) {
|
|
2094
|
+
x1 = target.after.x;
|
|
2095
|
+
y1 = target.after.y;
|
|
2096
|
+
x4 = source.before.x;
|
|
2097
|
+
y4 = source.before.y;
|
|
2098
|
+
}
|
|
2099
|
+
let dx = Math.abs(x4 - x1) * bezierWeight;
|
|
2100
|
+
let x2 = x1 + dx;
|
|
2101
|
+
let x3 = x4 - dx;
|
|
2102
|
+
const centerX = (x1 + x4) / 2;
|
|
2103
|
+
const centerY = (y1 + y4) / 2;
|
|
2104
|
+
let controlX = this.ganttUpper.styles.lineHeight / 2;
|
|
2105
|
+
const controlY = this.ganttUpper.styles.lineHeight / 2;
|
|
2106
|
+
if (x1 >= x4) {
|
|
2107
|
+
if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
|
|
2108
|
+
return `M ${x1} ${y1}
|
|
2109
|
+
C ${x1 + controlX} ${y1} ${x1 + controlX} ${y4 > y1 ? y1 + controlX : y1 - controlX} ${x1} ${y4 > y1 ? y1 + controlY : y1 - controlY}
|
|
2110
|
+
L ${x4} ${y4 > y1 ? y4 - controlY : y4 + controlY}
|
|
2111
|
+
C ${x4 - controlY} ${y4 > y1 ? y4 - controlY : y4 + controlY} ${x4 - controlX} ${y4} ${x4} ${y4}
|
|
2112
|
+
`;
|
|
2113
|
+
}
|
|
2114
|
+
else {
|
|
2115
|
+
controlX = this.ganttUpper.styles.lineHeight;
|
|
2116
|
+
return `M ${x1} ${y1}
|
|
2117
|
+
C ${x1 + controlX} ${y1} ${x1 + controlX} ${y4 > y1 ? y1 + controlX : y1 - controlX} ${centerX} ${centerY}
|
|
2118
|
+
C ${x4 - controlX} ${y4 > y1 ? y4 - controlX : y4 + controlX} ${x4 - controlX} ${y4} ${x4} ${y4}
|
|
2119
|
+
`;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
else if (((_a = this.ganttUpper.linkOptions) === null || _a === void 0 ? void 0 : _a.showArrow) && x4 - x1 < 200) {
|
|
2123
|
+
dx = Math.max(Math.abs(y4 - y1) * bezierWeight, 60);
|
|
2124
|
+
x2 = x1 + dx;
|
|
2125
|
+
x3 = x4 - dx;
|
|
2126
|
+
return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
|
|
2127
|
+
}
|
|
2128
|
+
return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
|
|
2129
|
+
}
|
|
2130
|
+
};
|
|
2131
|
+
GanttLinkLineCurve = __decorate([
|
|
2132
|
+
__param(0, Inject(GANTT_UPPER_TOKEN))
|
|
2133
|
+
], GanttLinkLineCurve);
|
|
2134
|
+
|
|
2135
|
+
class GanttLinkLineStraight extends GanttLinkLine {
|
|
2136
|
+
constructor() {
|
|
2137
|
+
super();
|
|
2138
|
+
this.pathControl = 20;
|
|
2139
|
+
}
|
|
2140
|
+
generateSSPath(source, target) {
|
|
2141
|
+
const x1 = source.before.x;
|
|
2142
|
+
const y1 = source.before.y;
|
|
2143
|
+
const x4 = target.before.x;
|
|
2144
|
+
const y4 = target.before.y;
|
|
2145
|
+
const control = this.pathControl;
|
|
2146
|
+
return `M ${x1} ${y1}
|
|
2147
|
+
L ${x4 > x1 ? x1 - control : x4 - control} ${y1}
|
|
2148
|
+
L ${x4 > x1 ? x1 - control : x4 - control} ${y4}
|
|
2149
|
+
L ${x4} ${y4}`;
|
|
2150
|
+
}
|
|
2151
|
+
generateFFPath(source, target) {
|
|
2152
|
+
const x1 = source.after.x;
|
|
2153
|
+
const y1 = source.after.y;
|
|
2154
|
+
const x4 = target.after.x;
|
|
2155
|
+
const y4 = target.after.y;
|
|
2156
|
+
const control = this.pathControl;
|
|
2157
|
+
return `M ${x1} ${y1}
|
|
2158
|
+
L ${x4 > x1 ? x4 + control : x1 + control} ${y1}
|
|
2159
|
+
L ${x4 > x1 ? x4 + control : x1 + control} ${y4}
|
|
2160
|
+
L ${x4} ${y4}`;
|
|
2161
|
+
}
|
|
2162
|
+
generateFSAndSFPath(source, target, type) {
|
|
2163
|
+
let x1 = source.after.x;
|
|
2164
|
+
let y1 = source.after.y;
|
|
2165
|
+
let x4 = target.before.x;
|
|
2166
|
+
let y4 = target.before.y;
|
|
2167
|
+
const control = this.pathControl;
|
|
2168
|
+
if (type === GanttLinkType.sf) {
|
|
2169
|
+
x1 = target.after.x;
|
|
2170
|
+
y1 = target.after.y;
|
|
2171
|
+
x4 = source.before.x;
|
|
2172
|
+
y4 = source.before.y;
|
|
2173
|
+
}
|
|
2174
|
+
if (x4 - x1 >= 40) {
|
|
2175
|
+
return `M ${x1} ${y1}
|
|
2176
|
+
L ${x1 + control} ${y1}
|
|
2177
|
+
L ${x1 + control} ${y4}
|
|
2178
|
+
L ${x4} ${y4}`;
|
|
2179
|
+
}
|
|
2180
|
+
else {
|
|
2181
|
+
return `M ${x1} ${y1}
|
|
2182
|
+
L ${x1 + control} ${y1}
|
|
2183
|
+
L ${x1 + control} ${y4 > y1 ? y1 + control : y1 - control}
|
|
2184
|
+
L ${x4 - control} ${y4 > y1 ? y1 + control : y1 - control}
|
|
2185
|
+
L ${x4 - control} ${y4}
|
|
2186
|
+
L ${x4} ${y4}`;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
function createLineGenerator(type, ganttUpper) {
|
|
2192
|
+
switch (type) {
|
|
2193
|
+
case GanttLinkLineType.curve:
|
|
2194
|
+
return new GanttLinkLineCurve(ganttUpper);
|
|
2195
|
+
case GanttLinkLineType.straight:
|
|
2196
|
+
return new GanttLinkLineStraight();
|
|
2197
|
+
default:
|
|
2198
|
+
throw new Error('gantt link path type invalid');
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
class GanttLinksComponent {
|
|
2203
|
+
constructor(ganttUpper, cdr, elementRef, ganttDragContainer) {
|
|
2204
|
+
this.ganttUpper = ganttUpper;
|
|
2205
|
+
this.cdr = cdr;
|
|
2206
|
+
this.elementRef = elementRef;
|
|
2207
|
+
this.ganttDragContainer = ganttDragContainer;
|
|
2208
|
+
this.groups = [];
|
|
2209
|
+
this.items = [];
|
|
2210
|
+
this.lineClick = new EventEmitter();
|
|
2211
|
+
this.links = [];
|
|
2212
|
+
this.ganttLinkTypes = GanttLinkType;
|
|
2213
|
+
this.showArrow = false;
|
|
2214
|
+
this.linkItems = [];
|
|
2215
|
+
this.firstChange = true;
|
|
2216
|
+
this.unsubscribe$ = new Subject();
|
|
2217
|
+
this.ganttLinksOverlay = true;
|
|
2218
|
+
}
|
|
2219
|
+
ngOnInit() {
|
|
2220
|
+
this.linkLine = createLineGenerator(this.ganttUpper.linkOptions.lineType, this.ganttUpper);
|
|
2221
|
+
this.showArrow = this.ganttUpper.linkOptions.showArrow;
|
|
2222
|
+
this.buildLinks();
|
|
2223
|
+
this.firstChange = false;
|
|
2224
|
+
this.ganttDragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2225
|
+
this.elementRef.nativeElement.style.visibility = 'hidden';
|
|
2226
|
+
});
|
|
2227
|
+
merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded)
|
|
2228
|
+
.pipe(skip(1), debounceTime(0), takeUntil(this.unsubscribe$))
|
|
2229
|
+
.subscribe(() => {
|
|
2230
|
+
this.elementRef.nativeElement.style.visibility = 'visible';
|
|
2231
|
+
this.buildLinks();
|
|
2232
|
+
this.cdr.detectChanges();
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
ngOnChanges() {
|
|
2236
|
+
if (!this.firstChange) {
|
|
2237
|
+
this.buildLinks();
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
computeItemPosition() {
|
|
2241
|
+
const lineHeight = this.ganttUpper.styles.lineHeight;
|
|
2242
|
+
const barHeight = this.ganttUpper.styles.barHeight;
|
|
2243
|
+
this.linkItems = [];
|
|
2244
|
+
if (this.groups.length > 0) {
|
|
2245
|
+
let itemNum = 0;
|
|
2246
|
+
let groupNum = 0;
|
|
2247
|
+
this.groups.forEach((group) => {
|
|
2248
|
+
groupNum++;
|
|
2249
|
+
if (group.expanded) {
|
|
2250
|
+
const items = recursiveItems(group.items);
|
|
2251
|
+
items.forEach((item, itemIndex) => {
|
|
2252
|
+
const y = (groupNum + itemNum + itemIndex) * lineHeight + item.refs.y + barHeight / 2;
|
|
2253
|
+
this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
|
|
2254
|
+
x: item.refs.x,
|
|
2255
|
+
y
|
|
2256
|
+
}, after: {
|
|
2257
|
+
x: item.refs.x + item.refs.width,
|
|
2258
|
+
y
|
|
2259
|
+
} }));
|
|
2260
|
+
});
|
|
2261
|
+
itemNum += items.length;
|
|
2262
|
+
}
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2265
|
+
else {
|
|
2266
|
+
const items = recursiveItems(this.items);
|
|
2267
|
+
items.forEach((item, itemIndex) => {
|
|
2268
|
+
const y = itemIndex * lineHeight + item.refs.y + barHeight / 2;
|
|
2269
|
+
this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
|
|
2270
|
+
x: item.refs.x,
|
|
2271
|
+
y
|
|
2272
|
+
}, after: {
|
|
2273
|
+
x: item.refs.x + item.refs.width,
|
|
2274
|
+
y
|
|
2275
|
+
} }));
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
buildLinks() {
|
|
2280
|
+
this.computeItemPosition();
|
|
2281
|
+
this.links = [];
|
|
2282
|
+
this.linkItems.forEach((source) => {
|
|
2283
|
+
if (source.origin.start || source.origin.end) {
|
|
2284
|
+
source.links.forEach((link) => {
|
|
2285
|
+
const target = this.linkItems.find((item) => item.id === link.link);
|
|
2286
|
+
if (target && (target.origin.start || target.origin.end)) {
|
|
2287
|
+
let defaultColor = LinkColors.default;
|
|
2288
|
+
let activeColor = LinkColors.active;
|
|
2289
|
+
if (link.type === GanttLinkType.fs && source.end.getTime() > target.start.getTime()) {
|
|
2290
|
+
defaultColor = LinkColors.blocked;
|
|
2291
|
+
activeColor = LinkColors.blocked;
|
|
2292
|
+
}
|
|
2293
|
+
if (link.color) {
|
|
2294
|
+
if (typeof link.color === 'string') {
|
|
2295
|
+
defaultColor = link.color;
|
|
2296
|
+
activeColor = link.color;
|
|
2297
|
+
}
|
|
2298
|
+
else {
|
|
2299
|
+
defaultColor = link.color.default;
|
|
2300
|
+
activeColor = link.color.active;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
this.links.push({
|
|
2304
|
+
path: this.linkLine.generatePath(source, target, link.type),
|
|
2305
|
+
source: source.origin,
|
|
2306
|
+
target: target.origin,
|
|
2307
|
+
type: link.type,
|
|
2308
|
+
color: defaultColor,
|
|
2309
|
+
defaultColor,
|
|
2310
|
+
activeColor
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
trackBy(index) {
|
|
2318
|
+
return index;
|
|
2319
|
+
}
|
|
2320
|
+
onLineClick(event, link) {
|
|
2321
|
+
this.lineClick.emit({
|
|
2322
|
+
event,
|
|
2323
|
+
source: link.source,
|
|
2324
|
+
target: link.target
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
mouseEnterPath(link, index) {
|
|
2328
|
+
link.color = link.activeColor || link.defaultColor;
|
|
2329
|
+
if (index < this.links.length - 1) {
|
|
2330
|
+
this.links.splice(index, 1);
|
|
2331
|
+
this.links.push(link);
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
mouseLeavePath(link) {
|
|
2335
|
+
link.color = link.defaultColor;
|
|
2336
|
+
}
|
|
2337
|
+
ngOnDestroy() {
|
|
2338
|
+
this.unsubscribe$.next();
|
|
2339
|
+
this.unsubscribe$.complete();
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
GanttLinksComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttLinksComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: GanttDragContainer }], target: i0.ɵɵFactoryTarget.Component });
|
|
2343
|
+
GanttLinksComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { groups: "groups", items: "items" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path\n [attr.d]=\"link.path\"\n fill=\"transparent\"\n stroke-width=\"2\"\n [attr.stroke]=\"link.color\"\n pointer-events=\"none\"\n [attr.style]=\"link.type === ganttLinkTypes.sf ? 'marker-start: url(#triangle' + i + ')' : 'marker-end: url(#triangle' + i + ')'\"\n ></path>\n\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n [attr.d]=\"link.path\"\n (mouseenter)=\"mouseEnterPath(link, i)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n <defs *ngIf=\"showArrow\">\n <marker\n *ngIf=\"link.type === ganttLinkTypes.sf; else markerEnd\"\n [id]=\"'triangle' + i\"\n markerUnits=\"strokeWidth\"\n markerWidth=\"5\"\n markerHeight=\"4\"\n refX=\"5\"\n refY=\"2\"\n orient=\"180\"\n >\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n\n <ng-template #markerEnd>\n <marker [id]=\"'triangle' + i\" markerUnits=\"strokeWidth\" markerWidth=\"5\" markerHeight=\"4\" refX=\"5\" refY=\"2\" orient=\"auto\">\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n </ng-template>\n </defs>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n", directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
2344
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttLinksComponent, decorators: [{
|
|
2345
|
+
type: Component,
|
|
2346
|
+
args: [{ selector: 'gantt-links-overlay', template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path\n [attr.d]=\"link.path\"\n fill=\"transparent\"\n stroke-width=\"2\"\n [attr.stroke]=\"link.color\"\n pointer-events=\"none\"\n [attr.style]=\"link.type === ganttLinkTypes.sf ? 'marker-start: url(#triangle' + i + ')' : 'marker-end: url(#triangle' + i + ')'\"\n ></path>\n\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n [attr.d]=\"link.path\"\n (mouseenter)=\"mouseEnterPath(link, i)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n <defs *ngIf=\"showArrow\">\n <marker\n *ngIf=\"link.type === ganttLinkTypes.sf; else markerEnd\"\n [id]=\"'triangle' + i\"\n markerUnits=\"strokeWidth\"\n markerWidth=\"5\"\n markerHeight=\"4\"\n refX=\"5\"\n refY=\"2\"\n orient=\"180\"\n >\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n\n <ng-template #markerEnd>\n <marker [id]=\"'triangle' + i\" markerUnits=\"strokeWidth\" markerWidth=\"5\" markerHeight=\"4\" refX=\"5\" refY=\"2\" orient=\"auto\">\n <path [attr.fill]=\"link.color\" [attr.stroke]=\"link.color\" d=\"M 0 0 L 5 2 L 0 4 z\" />\n </marker>\n </ng-template>\n </defs>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n" }]
|
|
2347
|
+
}], ctorParameters: function () {
|
|
2348
|
+
return [{ type: GanttUpper, decorators: [{
|
|
2349
|
+
type: Inject,
|
|
2350
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2351
|
+
}] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: GanttDragContainer }];
|
|
2352
|
+
}, propDecorators: { groups: [{
|
|
2353
|
+
type: Input
|
|
2354
|
+
}], items: [{
|
|
2355
|
+
type: Input
|
|
2356
|
+
}], lineClick: [{
|
|
2357
|
+
type: Output
|
|
2358
|
+
}], ganttLinksOverlay: [{
|
|
2359
|
+
type: HostBinding,
|
|
2360
|
+
args: ['class.gantt-links-overlay']
|
|
2361
|
+
}] } });
|
|
2362
|
+
|
|
2363
|
+
class GanttItemUpper {
|
|
2364
|
+
constructor(elementRef, ganttUpper) {
|
|
2365
|
+
this.elementRef = elementRef;
|
|
2366
|
+
this.ganttUpper = ganttUpper;
|
|
2367
|
+
this.firstChange = true;
|
|
2368
|
+
this.unsubscribe$ = new Subject();
|
|
2369
|
+
}
|
|
2370
|
+
ngOnInit() {
|
|
2371
|
+
this.firstChange = false;
|
|
2372
|
+
this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2373
|
+
this.setPositions();
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
ngOnChanges() {
|
|
2377
|
+
if (!this.firstChange) {
|
|
2378
|
+
this.setPositions();
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
setPositions() {
|
|
2382
|
+
const itemElement = this.elementRef.nativeElement;
|
|
2383
|
+
itemElement.style.left = this.item.refs.x + 'px';
|
|
2384
|
+
itemElement.style.top = this.item.refs.y + 'px';
|
|
2385
|
+
itemElement.style.width = this.item.refs.width + 'px';
|
|
2386
|
+
if (this.item.type === GanttItemType.bar) {
|
|
2387
|
+
itemElement.style.height = this.ganttUpper.styles.barHeight + 'px';
|
|
2388
|
+
}
|
|
2389
|
+
else if (this.item.type === GanttItemType.range) {
|
|
2390
|
+
itemElement.style.height = rangeHeight + 'px';
|
|
2391
|
+
}
|
|
2392
|
+
else {
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
ngOnDestroy() {
|
|
2396
|
+
this.unsubscribe$.next();
|
|
2397
|
+
this.unsubscribe$.complete();
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
GanttItemUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttItemUpper, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2401
|
+
GanttItemUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: GanttItemUpper, inputs: { template: "template", item: "item" }, usesOnChanges: true, ngImport: i0 });
|
|
2402
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttItemUpper, decorators: [{
|
|
2403
|
+
type: Directive
|
|
2404
|
+
}], ctorParameters: function () {
|
|
2405
|
+
return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
|
|
2406
|
+
type: Inject,
|
|
2407
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2408
|
+
}] }];
|
|
2409
|
+
}, propDecorators: { template: [{
|
|
2410
|
+
type: Input
|
|
2411
|
+
}], item: [{
|
|
2412
|
+
type: Input
|
|
2413
|
+
}] } });
|
|
2414
|
+
|
|
2415
|
+
class NgxGanttRangeComponent extends GanttItemUpper {
|
|
2416
|
+
constructor(elementRef, ganttUpper) {
|
|
2417
|
+
super(elementRef, ganttUpper);
|
|
2418
|
+
this.ganttRangeClass = true;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
NgxGanttRangeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttRangeComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
|
|
2422
|
+
NgxGanttRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range", host: { properties: { "class.gantt-range": "this.ganttRangeClass" } }, usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"item.start && item.end\">\n <div class=\"gantt-range-main\">\n <div class=\"gantt-range-main-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n </div>\n <div class=\"gantt-range-triangle left\"></div>\n <div class=\"gantt-range-triangle right\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</ng-container>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
|
|
2423
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttRangeComponent, decorators: [{
|
|
2424
|
+
type: Component,
|
|
2425
|
+
args: [{ selector: 'ngx-gantt-range,gantt-range', template: "<ng-container *ngIf=\"item.start && item.end\">\n <div class=\"gantt-range-main\">\n <div class=\"gantt-range-main-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n </div>\n <div class=\"gantt-range-triangle left\"></div>\n <div class=\"gantt-range-triangle right\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</ng-container>\n" }]
|
|
2426
|
+
}], ctorParameters: function () {
|
|
2427
|
+
return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
|
|
2428
|
+
type: Inject,
|
|
2429
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2430
|
+
}] }];
|
|
2431
|
+
}, propDecorators: { ganttRangeClass: [{
|
|
2432
|
+
type: HostBinding,
|
|
2433
|
+
args: ['class.gantt-range']
|
|
2434
|
+
}] } });
|
|
2435
|
+
|
|
2436
|
+
const dragMinWidth = 10;
|
|
2437
|
+
const activeClass = 'gantt-bar-active';
|
|
2438
|
+
const dropActiveClass = 'gantt-bar-drop-active';
|
|
2439
|
+
const singleDropActiveClass = 'gantt-bar-single-drop-active';
|
|
2440
|
+
function createSvgElement(qualifiedName, className) {
|
|
2441
|
+
const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
|
|
2442
|
+
element.classList.add(className);
|
|
2443
|
+
return element;
|
|
2444
|
+
}
|
|
2445
|
+
class GanttBarDrag {
|
|
2446
|
+
constructor(dragDrop, dom, dragContainer, root) {
|
|
2447
|
+
this.dragDrop = dragDrop;
|
|
2448
|
+
this.dom = dom;
|
|
2449
|
+
this.dragContainer = dragContainer;
|
|
2450
|
+
this.root = root;
|
|
2451
|
+
this.dragRefs = [];
|
|
2452
|
+
this.destroy$ = new Subject();
|
|
2453
|
+
}
|
|
2454
|
+
get dragDisabled() {
|
|
2455
|
+
return !this.item.draggable || !this.ganttUpper.draggable;
|
|
2456
|
+
}
|
|
2457
|
+
get linkDragDisabled() {
|
|
2458
|
+
return !this.item.linkable || !this.ganttUpper.linkable;
|
|
2459
|
+
}
|
|
2460
|
+
createMouseEvents() {
|
|
2461
|
+
var _a, _b, _c;
|
|
2462
|
+
const dropClass = ((_b = (_a = this.ganttUpper.config.linkOptions) === null || _a === void 0 ? void 0 : _a.dependencyTypes) === null || _b === void 0 ? void 0 : _b.length) === 1 &&
|
|
2463
|
+
((_c = this.ganttUpper.config.linkOptions) === null || _c === void 0 ? void 0 : _c.dependencyTypes[0]) === GanttLinkType.fs
|
|
2464
|
+
? singleDropActiveClass
|
|
2465
|
+
: dropActiveClass;
|
|
2466
|
+
fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
|
|
2467
|
+
.pipe(takeUntil(this.destroy$))
|
|
2468
|
+
.subscribe(() => {
|
|
2469
|
+
if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
|
|
2470
|
+
if (this.item.linkable) {
|
|
2471
|
+
this.barElement.classList.add(dropClass);
|
|
2472
|
+
this.dragContainer.emitLinkDragEntered({
|
|
2473
|
+
item: this.item,
|
|
2474
|
+
element: this.barElement
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
else {
|
|
2479
|
+
this.barElement.classList.add(activeClass);
|
|
2480
|
+
}
|
|
2481
|
+
});
|
|
2482
|
+
fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
|
|
2483
|
+
.pipe(takeUntil(this.destroy$))
|
|
2484
|
+
.subscribe(() => {
|
|
2485
|
+
if (!this.dragContainer.linkDraggingId) {
|
|
2486
|
+
this.barElement.classList.remove(activeClass);
|
|
2487
|
+
}
|
|
2488
|
+
else {
|
|
2489
|
+
this.dragContainer.emitLinkDragLeaved();
|
|
2490
|
+
}
|
|
2491
|
+
this.barElement.classList.remove(dropClass);
|
|
2492
|
+
});
|
|
2493
|
+
}
|
|
2494
|
+
createBarDrag() {
|
|
2495
|
+
const dragRef = this.dragDrop.createDrag(this.barElement);
|
|
2496
|
+
dragRef.lockAxis = 'x';
|
|
2497
|
+
dragRef.started.subscribe(() => {
|
|
2498
|
+
this.setDraggingStyles();
|
|
2499
|
+
this.dragContainer.dragStarted.emit({ item: this.item.origin });
|
|
2500
|
+
});
|
|
2501
|
+
dragRef.moved.subscribe((event) => {
|
|
2502
|
+
const currentX = this.item.refs.x + event.distance.x;
|
|
2503
|
+
const currentDate = this.ganttUpper.view.getDateByXPoint(currentX);
|
|
2504
|
+
const currentStartX = this.ganttUpper.view.getXPointByDate(currentDate);
|
|
2505
|
+
const dayWidth = this.ganttUpper.view.getDayOccupancyWidth(currentDate);
|
|
2506
|
+
const diffDays = differenceInCalendarDays(this.item.end.value, this.item.start.value);
|
|
2507
|
+
let start = currentDate;
|
|
2508
|
+
let end = currentDate.addDays(diffDays);
|
|
2509
|
+
if (currentX > currentStartX + dayWidth / 2) {
|
|
2510
|
+
start = start.addDays(1);
|
|
2511
|
+
end = end.addDays(1);
|
|
2512
|
+
}
|
|
2513
|
+
this.openDragBackdrop(this.barElement, start, end);
|
|
2514
|
+
this.item.updateDate(start, end);
|
|
2515
|
+
this.dragContainer.dragMoved.emit({ item: this.item.origin });
|
|
2516
|
+
});
|
|
2517
|
+
dragRef.ended.subscribe((event) => {
|
|
2518
|
+
this.clearDraggingStyles();
|
|
2519
|
+
this.closeDragBackdrop();
|
|
2520
|
+
event.source.reset();
|
|
2521
|
+
this.dragContainer.dragEnded.emit({ item: this.item.origin });
|
|
2522
|
+
});
|
|
2523
|
+
this.barDragRef = dragRef;
|
|
2524
|
+
return dragRef;
|
|
2525
|
+
}
|
|
2526
|
+
createBarHandleDrags() {
|
|
2527
|
+
const dragRefs = [];
|
|
2528
|
+
const handles = this.barElement.querySelectorAll('.drag-handles .handle');
|
|
2529
|
+
handles.forEach((handle, index) => {
|
|
2530
|
+
const isBefore = index === 0;
|
|
2531
|
+
const dragRef = this.dragDrop.createDrag(handle);
|
|
2532
|
+
dragRef.lockAxis = 'x';
|
|
2533
|
+
dragRef.withBoundaryElement(this.dom.root);
|
|
2534
|
+
dragRef.started.subscribe(() => {
|
|
2535
|
+
this.setDraggingStyles();
|
|
2536
|
+
this.dragContainer.dragStarted.emit({ item: this.item.origin });
|
|
2537
|
+
});
|
|
2538
|
+
dragRef.moved.subscribe((event) => {
|
|
2539
|
+
if (isBefore) {
|
|
2540
|
+
const x = this.item.refs.x + event.distance.x;
|
|
2541
|
+
const width = this.item.refs.width + event.distance.x * -1;
|
|
2542
|
+
if (width > dragMinWidth) {
|
|
2543
|
+
this.barElement.style.width = width + 'px';
|
|
2544
|
+
this.barElement.style.left = x + 'px';
|
|
2545
|
+
this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), this.item.end);
|
|
2546
|
+
this.item.updateDate(this.ganttUpper.view.getDateByXPoint(x), this.item.end);
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
else {
|
|
2550
|
+
const width = this.item.refs.width + event.distance.x;
|
|
2551
|
+
if (width > dragMinWidth) {
|
|
2552
|
+
this.barElement.style.width = width + 'px';
|
|
2553
|
+
this.openDragBackdrop(this.barElement, this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
|
|
2554
|
+
}
|
|
2555
|
+
this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
|
|
2556
|
+
}
|
|
2557
|
+
this.dragContainer.dragMoved.emit({ item: this.item.origin });
|
|
2558
|
+
event.source.reset();
|
|
2559
|
+
});
|
|
2560
|
+
dragRef.ended.subscribe((event) => {
|
|
2561
|
+
if (isBefore) {
|
|
2562
|
+
const width = this.item.refs.width + event.distance.x * -1;
|
|
2563
|
+
if (width > dragMinWidth) {
|
|
2564
|
+
this.item.updateDate(this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x), this.item.end);
|
|
2565
|
+
}
|
|
2566
|
+
else {
|
|
2567
|
+
this.item.updateDate(this.item.end.startOfDay(), this.item.end);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
else {
|
|
2571
|
+
const width = this.item.refs.width + event.distance.x;
|
|
2572
|
+
if (width > dragMinWidth) {
|
|
2573
|
+
this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + this.item.refs.width + event.distance.x));
|
|
2574
|
+
}
|
|
2575
|
+
else {
|
|
2576
|
+
this.item.updateDate(this.item.start, this.item.start.endOfDay());
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
this.clearDraggingStyles();
|
|
2580
|
+
this.closeDragBackdrop();
|
|
2581
|
+
this.dragContainer.dragEnded.emit({ item: this.item.origin });
|
|
2582
|
+
});
|
|
2583
|
+
dragRefs.push(dragRef);
|
|
2584
|
+
});
|
|
2585
|
+
return dragRefs;
|
|
2586
|
+
}
|
|
2587
|
+
createLinkHandleDrags() {
|
|
2588
|
+
const dragRefs = [];
|
|
2589
|
+
const handles = this.barElement.querySelectorAll('.link-handles .handle');
|
|
2590
|
+
handles.forEach((handle, index) => {
|
|
2591
|
+
const isBegin = index === 0;
|
|
2592
|
+
const dragRef = this.dragDrop.createDrag(handle);
|
|
2593
|
+
dragRef.withBoundaryElement(this.dom.root);
|
|
2594
|
+
dragRef.beforeStarted.subscribe(() => {
|
|
2595
|
+
handle.style.pointerEvents = 'none';
|
|
2596
|
+
if (this.barDragRef) {
|
|
2597
|
+
this.barDragRef.disabled = true;
|
|
2598
|
+
}
|
|
2599
|
+
this.createLinkDraggingLine();
|
|
2600
|
+
this.dragContainer.emitLinkDragStarted({
|
|
2601
|
+
element: this.barElement,
|
|
2602
|
+
item: this.item,
|
|
2603
|
+
pos: isBegin ? InBarPosition.start : InBarPosition.finish
|
|
2604
|
+
});
|
|
2605
|
+
});
|
|
2606
|
+
dragRef.moved.subscribe(() => {
|
|
2607
|
+
const positions = this.calcLinkLinePositions(handle, isBegin);
|
|
2608
|
+
this.linkDraggingLine.setAttribute('x1', positions.x1.toString());
|
|
2609
|
+
this.linkDraggingLine.setAttribute('y1', positions.y1.toString());
|
|
2610
|
+
this.linkDraggingLine.setAttribute('x2', positions.x2.toString());
|
|
2611
|
+
this.linkDraggingLine.setAttribute('y2', positions.y2.toString());
|
|
2612
|
+
});
|
|
2613
|
+
dragRef.ended.subscribe((event) => {
|
|
2614
|
+
handle.style.pointerEvents = '';
|
|
2615
|
+
if (this.barDragRef) {
|
|
2616
|
+
this.barDragRef.disabled = false;
|
|
2617
|
+
}
|
|
2618
|
+
// 计算line拖动的落点位于目标Bar的值,如果值大于Bar宽度的一半,说明是拖动到Begin位置,否则则为拖动到End位置
|
|
2619
|
+
if (this.dragContainer.linkDragPath.to) {
|
|
2620
|
+
const placePointX = event.source.getRootElement().getBoundingClientRect().x -
|
|
2621
|
+
this.dragContainer.linkDragPath.to.element.getBoundingClientRect().x;
|
|
2622
|
+
this.dragContainer.emitLinkDragEnded(Object.assign(Object.assign({}, this.dragContainer.linkDragPath.to), { pos: placePointX < this.dragContainer.linkDragPath.to.item.refs.width / 2
|
|
2623
|
+
? InBarPosition.start
|
|
2624
|
+
: InBarPosition.finish }));
|
|
2625
|
+
}
|
|
2626
|
+
else {
|
|
2627
|
+
this.dragContainer.emitLinkDragEnded();
|
|
2628
|
+
}
|
|
2629
|
+
event.source.reset();
|
|
2630
|
+
this.barElement.classList.remove(activeClass);
|
|
2631
|
+
this.destroyLinkDraggingLine();
|
|
2632
|
+
});
|
|
2633
|
+
dragRefs.push(dragRef);
|
|
2634
|
+
});
|
|
2635
|
+
return dragRefs;
|
|
2636
|
+
}
|
|
2637
|
+
openDragBackdrop(dragElement, start, end) {
|
|
2638
|
+
const dragBackdropElement = this.root.backdrop.nativeElement;
|
|
2639
|
+
const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask');
|
|
2640
|
+
const rootRect = this.dom.root.getBoundingClientRect();
|
|
2641
|
+
const dragRect = dragElement.getBoundingClientRect();
|
|
2642
|
+
const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
|
|
2643
|
+
const width = dragRect.right - dragRect.left;
|
|
2644
|
+
// Note: updating styles will cause re-layout so we have to place them consistently one by one.
|
|
2645
|
+
dragMaskElement.style.left = left + 'px';
|
|
2646
|
+
dragMaskElement.style.width = width + 'px';
|
|
2647
|
+
dragMaskElement.style.display = 'block';
|
|
2648
|
+
dragBackdropElement.style.display = 'block';
|
|
2649
|
+
// This will invalidate the layout, but we won't need re-layout, because we set styles previously.
|
|
2650
|
+
dragMaskElement.querySelector('.start').innerHTML = start.format('MM-dd');
|
|
2651
|
+
dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
|
|
2652
|
+
}
|
|
2653
|
+
closeDragBackdrop() {
|
|
2654
|
+
const dragBackdropElement = this.root.backdrop.nativeElement;
|
|
2655
|
+
const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask');
|
|
2656
|
+
dragMaskElement.style.display = 'none';
|
|
2657
|
+
dragBackdropElement.style.display = 'none';
|
|
2658
|
+
}
|
|
2659
|
+
setDraggingStyles() {
|
|
2660
|
+
this.barElement.style.pointerEvents = 'none';
|
|
2661
|
+
this.barElement.classList.add('gantt-bar-draggable-drag');
|
|
2662
|
+
}
|
|
2663
|
+
clearDraggingStyles() {
|
|
2664
|
+
this.barElement.style.pointerEvents = '';
|
|
2665
|
+
this.barElement.classList.remove('gantt-bar-draggable-drag');
|
|
2666
|
+
}
|
|
2667
|
+
calcLinkLinePositions(target, isBefore) {
|
|
2668
|
+
const rootRect = this.dom.root.getBoundingClientRect();
|
|
2669
|
+
const targetRect = target.getBoundingClientRect();
|
|
2670
|
+
const layerRect = target.parentElement.parentElement.getBoundingClientRect();
|
|
2671
|
+
return {
|
|
2672
|
+
x1: layerRect.left + (isBefore ? 0 : layerRect.width) - rootRect.left,
|
|
2673
|
+
y1: layerRect.top + layerRect.height / 2 - rootRect.top,
|
|
2674
|
+
x2: targetRect.left - rootRect.left + targetRect.width / 2,
|
|
2675
|
+
y2: targetRect.top - rootRect.top + targetRect.height / 2
|
|
2676
|
+
};
|
|
2677
|
+
}
|
|
2678
|
+
createLinkDraggingLine() {
|
|
2679
|
+
if (!this.linkDraggingLine) {
|
|
2680
|
+
const svgElement = createSvgElement('svg', 'gantt-link-drag-container');
|
|
2681
|
+
const linElement = createSvgElement('line', 'link-dragging-line');
|
|
2682
|
+
linElement.style.pointerEvents = 'none';
|
|
2683
|
+
svgElement.appendChild(linElement);
|
|
2684
|
+
this.dom.root.appendChild(svgElement);
|
|
2685
|
+
this.linkDraggingLine = linElement;
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
destroyLinkDraggingLine() {
|
|
2689
|
+
if (this.linkDraggingLine) {
|
|
2690
|
+
this.linkDraggingLine.parentElement.remove();
|
|
2691
|
+
this.linkDraggingLine = null;
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
createDrags(elementRef, item, ganttUpper) {
|
|
2695
|
+
this.item = item;
|
|
2696
|
+
this.barElement = elementRef.nativeElement;
|
|
2697
|
+
this.ganttUpper = ganttUpper;
|
|
2698
|
+
// if (!item.draggable || (this.dragDisabled && this.linkDragDisabled)) {
|
|
2699
|
+
if (this.dragDisabled && this.linkDragDisabled) {
|
|
2700
|
+
return;
|
|
2701
|
+
}
|
|
2702
|
+
else {
|
|
2703
|
+
this.createMouseEvents();
|
|
2704
|
+
if (!this.dragDisabled) {
|
|
2705
|
+
const dragRef = this.createBarDrag();
|
|
2706
|
+
const dragHandlesRefs = this.createBarHandleDrags();
|
|
2707
|
+
this.dragRefs.push(dragRef, ...dragHandlesRefs);
|
|
2708
|
+
}
|
|
2709
|
+
if (!this.linkDragDisabled) {
|
|
2710
|
+
const linkDragRefs = this.createLinkHandleDrags();
|
|
2711
|
+
this.dragRefs.push(...linkDragRefs);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
ngOnDestroy() {
|
|
2716
|
+
this.closeDragBackdrop();
|
|
2717
|
+
this.dragRefs.forEach((dragRef) => dragRef.dispose());
|
|
2718
|
+
this.destroy$.next();
|
|
2719
|
+
this.destroy$.complete();
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttBarDrag, deps: [{ token: i1.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2723
|
+
GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttBarDrag });
|
|
2724
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttBarDrag, decorators: [{
|
|
2725
|
+
type: Injectable
|
|
2726
|
+
}], ctorParameters: function () {
|
|
2727
|
+
return [{ type: i1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: NgxGanttRootComponent, decorators: [{
|
|
2728
|
+
type: SkipSelf
|
|
2729
|
+
}] }];
|
|
2730
|
+
} });
|
|
2731
|
+
|
|
2732
|
+
function linearGradient(sideOrCorner, color, stop) {
|
|
2733
|
+
return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
|
|
2734
|
+
}
|
|
2735
|
+
class NgxGanttBarComponent extends GanttItemUpper {
|
|
2736
|
+
constructor(dragContainer, drag, elementRef, ganttUpper, ngZone) {
|
|
2737
|
+
super(elementRef, ganttUpper);
|
|
2738
|
+
this.dragContainer = dragContainer;
|
|
2739
|
+
this.drag = drag;
|
|
2740
|
+
this.ganttUpper = ganttUpper;
|
|
2741
|
+
this.ngZone = ngZone;
|
|
2742
|
+
this.barClick = new EventEmitter();
|
|
2743
|
+
this.ganttItemClass = true;
|
|
2744
|
+
this.color = 'red';
|
|
2745
|
+
}
|
|
2746
|
+
ngOnInit() {
|
|
2747
|
+
super.ngOnInit();
|
|
2748
|
+
this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2749
|
+
this.setContentBackground();
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
ngAfterViewInit() {
|
|
2753
|
+
this.drag.createDrags(this.elementRef, this.item, this.ganttUpper);
|
|
2754
|
+
this.setContentBackground();
|
|
2755
|
+
this.handles.changes
|
|
2756
|
+
.pipe(startWith(this.handles), switchMap(() =>
|
|
2757
|
+
// Note: we need to explicitly subscribe outside of the Angular zone since `addEventListener`
|
|
2758
|
+
// is called when the `fromEvent` is subscribed.
|
|
2759
|
+
new Observable((subscriber) => this.ngZone.runOutsideAngular(() => merge(...this.handles.toArray().map((handle) => fromEvent(handle.nativeElement, 'mousedown'))).subscribe(subscriber)))), takeUntil(this.unsubscribe$))
|
|
2760
|
+
.subscribe((event) => {
|
|
2761
|
+
event.stopPropagation();
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
onBarClick(event) {
|
|
2765
|
+
this.barClick.emit({ event, item: this.item.origin });
|
|
2766
|
+
}
|
|
2767
|
+
setContentBackground() {
|
|
2768
|
+
const contentElement = this.contentElementRef.nativeElement;
|
|
2769
|
+
const color = this.item.color || barBackground;
|
|
2770
|
+
const style = this.item.barStyle || {};
|
|
2771
|
+
if (this.item.origin.start && this.item.origin.end) {
|
|
2772
|
+
style.background = color;
|
|
2773
|
+
style.borderRadius = '';
|
|
2774
|
+
}
|
|
2775
|
+
if (this.item.origin.start && !this.item.origin.end) {
|
|
2776
|
+
style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
|
|
2777
|
+
style.borderRadius = '4px 12.5px 12.5px 4px';
|
|
2778
|
+
}
|
|
2779
|
+
if (!this.item.origin.start && this.item.origin.end) {
|
|
2780
|
+
style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
|
|
2781
|
+
style.borderRadius = '12.5px 4px 4px 12.5px';
|
|
2782
|
+
}
|
|
2783
|
+
if (this.item.progress >= 0) {
|
|
2784
|
+
const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
|
|
2785
|
+
style.background = hexToRgb(color, 0.3);
|
|
2786
|
+
style.borderRadius = '';
|
|
2787
|
+
contentProgressElement.style.background = color;
|
|
2788
|
+
}
|
|
2789
|
+
for (const key in style) {
|
|
2790
|
+
if (style.hasOwnProperty(key)) {
|
|
2791
|
+
contentElement.style[key] = style[key];
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
stopPropagation(event) {
|
|
2796
|
+
event.stopPropagation();
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
2800
|
+
NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }, { propertyName: "handles", predicate: ["handle"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
|
|
2801
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
|
|
2802
|
+
type: Component,
|
|
2803
|
+
args: [{ selector: 'ngx-gantt-bar,gantt-bar', providers: [GanttBarDrag], template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n" }]
|
|
2804
|
+
}], ctorParameters: function () {
|
|
2805
|
+
return [{ type: GanttDragContainer }, { type: GanttBarDrag }, { type: i0.ElementRef }, { type: GanttUpper, decorators: [{
|
|
2806
|
+
type: Inject,
|
|
2807
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2808
|
+
}] }, { type: i0.NgZone }];
|
|
2809
|
+
}, propDecorators: { barClick: [{
|
|
2810
|
+
type: Output
|
|
2811
|
+
}], contentElementRef: [{
|
|
2812
|
+
type: ViewChild,
|
|
2813
|
+
args: ['content']
|
|
2814
|
+
}], ganttItemClass: [{
|
|
2815
|
+
type: HostBinding,
|
|
2816
|
+
args: ['class.gantt-bar']
|
|
2817
|
+
}], handles: [{
|
|
2818
|
+
type: ViewChildren,
|
|
2819
|
+
args: ['handle']
|
|
2820
|
+
}] } });
|
|
2821
|
+
|
|
2822
|
+
class GanttMainComponent {
|
|
2823
|
+
constructor(ganttUpper) {
|
|
2824
|
+
this.ganttUpper = ganttUpper;
|
|
2825
|
+
this.barClick = new EventEmitter();
|
|
2826
|
+
this.lineClick = new EventEmitter();
|
|
2827
|
+
this.ganttMainClass = true;
|
|
2828
|
+
}
|
|
2829
|
+
trackBy(index, item) {
|
|
2830
|
+
return item.id || index;
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
GanttMainComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttMainComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
|
|
2834
|
+
GanttMainComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: GanttMainComponent, selector: "gantt-main", inputs: { groups: "groups", items: "items", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<gantt-links-overlay [groups]=\"groups\" [items]=\"items\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<!-- groups -->\n<div class=\"gantt-main-groups\" *ngIf=\"groups && groups.length > 0; else itemsTemplate\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"group.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: group }\"></ng-template>\n </div>\n <div *ngIf=\"group.expanded\" class=\"gantt-items\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: group.items }\"></ng-template>\n </div>\n </ng-container>\n</div>\n<!-- items -->\n<ng-template #itemsTemplate>\n <div class=\"gantt-main-items\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items }\"></ng-template>\n </div>\n</ng-template>\n\n<ng-template #ganttItems let-items=\"items\">\n <ng-container *ngFor=\"let item of items;\">\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-container *ngIf=\"item.type | isGanttCustomItem\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n </ng-container>\n <gantt-range *ngIf=\"item.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"item\"></gantt-range>\n <gantt-bar *ngIf=\"item.type | isGanttBarItem\" [item]=\"item\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n", components: [{ type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: ["groups", "items"], outputs: ["lineClick"] }, { type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range" }, { type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: ["barClick"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "isGanttCustomItem": IsGanttCustomItemPipe, "isGanttRangeItem": IsGanttRangeItemPipe, "isGanttBarItem": IsGanttBarItemPipe } });
|
|
2835
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttMainComponent, decorators: [{
|
|
2836
|
+
type: Component,
|
|
2837
|
+
args: [{ selector: 'gantt-main', template: "<gantt-links-overlay [groups]=\"groups\" [items]=\"items\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<!-- groups -->\n<div class=\"gantt-main-groups\" *ngIf=\"groups && groups.length > 0; else itemsTemplate\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"group.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: group }\"></ng-template>\n </div>\n <div *ngIf=\"group.expanded\" class=\"gantt-items\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: group.items }\"></ng-template>\n </div>\n </ng-container>\n</div>\n<!-- items -->\n<ng-template #itemsTemplate>\n <div class=\"gantt-main-items\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items }\"></ng-template>\n </div>\n</ng-template>\n\n<ng-template #ganttItems let-items=\"items\">\n <ng-container *ngFor=\"let item of items;\">\n <div\n class=\"gantt-item\"\n [style.height.px]=\"ganttUpper.styles.lineHeight\"\n [class.gantt-main-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-container *ngIf=\"item.type | isGanttCustomItem\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n </ng-container>\n <gantt-range *ngIf=\"item.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"item\"></gantt-range>\n <gantt-bar *ngIf=\"item.type | isGanttBarItem\" [item]=\"item\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n" }]
|
|
2838
|
+
}], ctorParameters: function () {
|
|
2839
|
+
return [{ type: GanttUpper, decorators: [{
|
|
2840
|
+
type: Inject,
|
|
2841
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2842
|
+
}] }];
|
|
2843
|
+
}, propDecorators: { groups: [{
|
|
2844
|
+
type: Input
|
|
2845
|
+
}], items: [{
|
|
2846
|
+
type: Input
|
|
2847
|
+
}], groupHeaderTemplate: [{
|
|
2848
|
+
type: Input
|
|
2849
|
+
}], itemTemplate: [{
|
|
2850
|
+
type: Input
|
|
2851
|
+
}], barTemplate: [{
|
|
2852
|
+
type: Input
|
|
2853
|
+
}], rangeTemplate: [{
|
|
2854
|
+
type: Input
|
|
2855
|
+
}], barClick: [{
|
|
2856
|
+
type: Output
|
|
2857
|
+
}], lineClick: [{
|
|
2858
|
+
type: Output
|
|
2859
|
+
}], ganttMainClass: [{
|
|
2860
|
+
type: HostBinding,
|
|
2861
|
+
args: ['class.gantt-main-container']
|
|
2862
|
+
}] } });
|
|
2863
|
+
|
|
2864
|
+
class NgxGanttComponent extends GanttUpper {
|
|
2865
|
+
constructor(elementRef, cdr, ngZone, config) {
|
|
2866
|
+
super(elementRef, cdr, ngZone, config);
|
|
2867
|
+
this.maxLevel = 2;
|
|
2868
|
+
this.linkDragStarted = new EventEmitter();
|
|
2869
|
+
this.linkDragEnded = new EventEmitter();
|
|
2870
|
+
this.lineClick = new EventEmitter();
|
|
2871
|
+
this.selectedChange = new EventEmitter();
|
|
2872
|
+
this.ngUnsubscribe$ = new Subject();
|
|
2873
|
+
this.sideTableWidth = sideWidth;
|
|
2874
|
+
}
|
|
2875
|
+
ngOnInit() {
|
|
2876
|
+
super.ngOnInit();
|
|
2877
|
+
// Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
|
|
2878
|
+
// the `onStable` will never emit any value.
|
|
2879
|
+
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
|
|
2880
|
+
// Normally this isn't in the zone, but it can cause performance regressions for apps
|
|
2881
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
2882
|
+
this.ngZone.runOutsideAngular(() => {
|
|
2883
|
+
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2884
|
+
this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
|
|
2885
|
+
this.linkDragStarted.emit(event);
|
|
2886
|
+
});
|
|
2887
|
+
this.dragContainer.linkDragEnded.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
|
|
2888
|
+
this.linkDragEnded.emit(event);
|
|
2889
|
+
});
|
|
2890
|
+
});
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
ngAfterViewInit() {
|
|
2894
|
+
this.columns.changes.pipe(startWith(true), takeUntil(this.ngUnsubscribe$)).subscribe(() => {
|
|
2895
|
+
this.columns.forEach((column) => {
|
|
2896
|
+
if (!column.columnWidth) {
|
|
2897
|
+
column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
|
|
2898
|
+
}
|
|
2899
|
+
});
|
|
2900
|
+
this.cdr.detectChanges();
|
|
2901
|
+
});
|
|
2902
|
+
}
|
|
2903
|
+
expandChildren(item) {
|
|
2904
|
+
if (!item.expanded) {
|
|
2905
|
+
item.setExpand(true);
|
|
2906
|
+
if (this.async && this.childrenResolve && item.children.length === 0) {
|
|
2907
|
+
item.loading = true;
|
|
2908
|
+
this.childrenResolve(item.origin)
|
|
2909
|
+
.pipe(take(1), finalize(() => {
|
|
2910
|
+
item.loading = false;
|
|
2911
|
+
this.expandChange.emit();
|
|
2912
|
+
this.cdr.detectChanges();
|
|
2913
|
+
}))
|
|
2914
|
+
.subscribe((items) => {
|
|
2915
|
+
item.addChildren(items);
|
|
2916
|
+
this.computeItemsRefs(...item.children);
|
|
2917
|
+
});
|
|
2918
|
+
}
|
|
2919
|
+
else {
|
|
2920
|
+
this.computeItemsRefs(...item.children);
|
|
2921
|
+
this.expandChange.emit();
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
else {
|
|
2925
|
+
item.setExpand(false);
|
|
2926
|
+
this.expandChange.emit();
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
selectItem(selectEvent) {
|
|
2930
|
+
var _a;
|
|
2931
|
+
if (!this.selectable) {
|
|
2932
|
+
return;
|
|
2933
|
+
}
|
|
2934
|
+
const { event, selectedValue } = selectEvent;
|
|
2935
|
+
this.selectionModel.toggle(selectedValue.id);
|
|
2936
|
+
const selectedIds = this.selectionModel.selected;
|
|
2937
|
+
if (this.multiple) {
|
|
2938
|
+
const _selectedValue = this.getGanttItems(selectedIds).map((item) => item.origin);
|
|
2939
|
+
this.selectedChange.emit({ event, selectedValue: _selectedValue });
|
|
2940
|
+
}
|
|
2941
|
+
else {
|
|
2942
|
+
const _selectedValue = (_a = this.getGanttItem(selectedIds[0])) === null || _a === void 0 ? void 0 : _a.origin;
|
|
2943
|
+
this.selectedChange.emit({ event, selectedValue: _selectedValue });
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
|
|
2948
|
+
NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.8", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
|
|
2949
|
+
{
|
|
2950
|
+
provide: GANTT_UPPER_TOKEN,
|
|
2951
|
+
useExisting: NgxGanttComponent
|
|
2952
|
+
},
|
|
2953
|
+
{
|
|
2954
|
+
provide: GANTT_ABSTRACT_TOKEN,
|
|
2955
|
+
useExisting: forwardRef(() => NgxGanttComponent)
|
|
2956
|
+
}
|
|
2957
|
+
], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], usesInheritance: true, ngImport: i0, template: "<ngx-gantt-root>\n <ng-template #sideTemplate>\n <gantt-table\n [groups]=\"groups\"\n [items]=\"items\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table>\n </ng-template>\n <ng-template #mainTemplate>\n <gantt-main\n [groups]=\"groups\"\n [items]=\"items\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </ng-template>\n</ngx-gantt-root>\n", components: [{ type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }, { type: GanttTableComponent, selector: "gantt-table", inputs: ["groups", "items", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate"], outputs: ["itemClick"] }, { type: GanttMainComponent, selector: "gantt-main", inputs: ["groups", "items", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2958
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttComponent, decorators: [{
|
|
2959
|
+
type: Component,
|
|
2960
|
+
args: [{ selector: 'ngx-gantt', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
2961
|
+
{
|
|
2962
|
+
provide: GANTT_UPPER_TOKEN,
|
|
2963
|
+
useExisting: NgxGanttComponent
|
|
2964
|
+
},
|
|
2965
|
+
{
|
|
2966
|
+
provide: GANTT_ABSTRACT_TOKEN,
|
|
2967
|
+
useExisting: forwardRef(() => NgxGanttComponent)
|
|
2968
|
+
}
|
|
2969
|
+
], template: "<ngx-gantt-root>\n <ng-template #sideTemplate>\n <gantt-table\n [groups]=\"groups\"\n [items]=\"items\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table>\n </ng-template>\n <ng-template #mainTemplate>\n <gantt-main\n [groups]=\"groups\"\n [items]=\"items\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </ng-template>\n</ngx-gantt-root>\n" }]
|
|
2970
|
+
}], ctorParameters: function () {
|
|
2971
|
+
return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
|
2972
|
+
type: Inject,
|
|
2973
|
+
args: [GANTT_GLOBAL_CONFIG]
|
|
2974
|
+
}] }];
|
|
2975
|
+
}, propDecorators: { maxLevel: [{
|
|
2976
|
+
type: Input
|
|
2977
|
+
}], async: [{
|
|
2978
|
+
type: Input
|
|
2979
|
+
}], childrenResolve: [{
|
|
2980
|
+
type: Input
|
|
2981
|
+
}], linkable: [{
|
|
2982
|
+
type: Input
|
|
2983
|
+
}], linkDragStarted: [{
|
|
2984
|
+
type: Output
|
|
2985
|
+
}], linkDragEnded: [{
|
|
2986
|
+
type: Output
|
|
2987
|
+
}], lineClick: [{
|
|
2988
|
+
type: Output
|
|
2989
|
+
}], selectedChange: [{
|
|
2990
|
+
type: Output
|
|
2991
|
+
}], table: [{
|
|
2992
|
+
type: ContentChild,
|
|
2993
|
+
args: [NgxGanttTableComponent]
|
|
2994
|
+
}], columns: [{
|
|
2995
|
+
type: ContentChildren,
|
|
2996
|
+
args: [NgxGanttTableColumnComponent, { descendants: true }]
|
|
2997
|
+
}], tableEmptyTemplate: [{
|
|
2998
|
+
type: ContentChild,
|
|
2999
|
+
args: ['tableEmpty', { static: true }]
|
|
3000
|
+
}] } });
|
|
3001
|
+
|
|
3002
|
+
class NgxGanttModule {
|
|
3003
|
+
}
|
|
3004
|
+
NgxGanttModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
3005
|
+
NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttModule, declarations: [NgxGanttComponent,
|
|
3006
|
+
NgxGanttTableComponent,
|
|
3007
|
+
NgxGanttTableColumnComponent,
|
|
3008
|
+
GanttTableComponent,
|
|
3009
|
+
GanttMainComponent,
|
|
3010
|
+
GanttCalendarComponent,
|
|
3011
|
+
GanttLinksComponent,
|
|
3012
|
+
NgxGanttBarComponent,
|
|
3013
|
+
GanttIconComponent,
|
|
3014
|
+
GanttDragBackdropComponent,
|
|
3015
|
+
NgxGanttRangeComponent,
|
|
3016
|
+
NgxGanttRootComponent,
|
|
3017
|
+
IsGanttRangeItemPipe,
|
|
3018
|
+
IsGanttBarItemPipe,
|
|
3019
|
+
IsGanttCustomItemPipe], imports: [CommonModule, DragDropModule], exports: [NgxGanttComponent,
|
|
3020
|
+
NgxGanttTableComponent,
|
|
3021
|
+
NgxGanttTableColumnComponent,
|
|
3022
|
+
NgxGanttRootComponent,
|
|
3023
|
+
NgxGanttBarComponent,
|
|
3024
|
+
NgxGanttRangeComponent] });
|
|
3025
|
+
NgxGanttModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttModule, providers: [
|
|
3026
|
+
{
|
|
3027
|
+
provide: GANTT_GLOBAL_CONFIG,
|
|
3028
|
+
useValue: defaultConfig
|
|
3029
|
+
}
|
|
3030
|
+
], imports: [[CommonModule, DragDropModule]] });
|
|
3031
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttModule, decorators: [{
|
|
3032
|
+
type: NgModule,
|
|
3033
|
+
args: [{
|
|
3034
|
+
imports: [CommonModule, DragDropModule],
|
|
3035
|
+
exports: [
|
|
3036
|
+
NgxGanttComponent,
|
|
3037
|
+
NgxGanttTableComponent,
|
|
3038
|
+
NgxGanttTableColumnComponent,
|
|
3039
|
+
NgxGanttRootComponent,
|
|
3040
|
+
NgxGanttBarComponent,
|
|
3041
|
+
NgxGanttRangeComponent
|
|
3042
|
+
],
|
|
3043
|
+
declarations: [
|
|
3044
|
+
NgxGanttComponent,
|
|
3045
|
+
NgxGanttTableComponent,
|
|
3046
|
+
NgxGanttTableColumnComponent,
|
|
3047
|
+
GanttTableComponent,
|
|
3048
|
+
GanttMainComponent,
|
|
3049
|
+
GanttCalendarComponent,
|
|
3050
|
+
GanttLinksComponent,
|
|
3051
|
+
NgxGanttBarComponent,
|
|
3052
|
+
GanttIconComponent,
|
|
3053
|
+
GanttDragBackdropComponent,
|
|
3054
|
+
NgxGanttRangeComponent,
|
|
3055
|
+
NgxGanttRootComponent,
|
|
3056
|
+
IsGanttRangeItemPipe,
|
|
3057
|
+
IsGanttBarItemPipe,
|
|
3058
|
+
IsGanttCustomItemPipe
|
|
3059
|
+
],
|
|
3060
|
+
providers: [
|
|
3061
|
+
{
|
|
3062
|
+
provide: GANTT_GLOBAL_CONFIG,
|
|
3063
|
+
useValue: defaultConfig
|
|
3064
|
+
}
|
|
3065
|
+
]
|
|
3066
|
+
}]
|
|
3067
|
+
}] });
|
|
3068
|
+
|
|
3069
|
+
/*
|
|
3070
|
+
* Public API Surface of gantt
|
|
3071
|
+
*/
|
|
3072
|
+
|
|
3073
|
+
/**
|
|
3074
|
+
* Generated bundle index. Do not edit.
|
|
3075
|
+
*/
|
|
3076
|
+
|
|
3077
|
+
export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLinkLineType, GanttLinkType, GanttLoadOnScrollEvent, GanttPrintService, GanttSelectedEvent, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, LinkColors, NgxGanttBarComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, defaultConfig, primaryDatePointTop, secondaryDatePointTop };
|
|
3078
|
+
//# sourceMappingURL=worktile-gantt.mjs.map
|