@worktile/gantt 12.2.1 → 13.0.0-next.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-drag.d.ts +4 -2
- package/components/bar/bar.component.d.ts +4 -4
- package/components/bar/bar.component.scss +201 -0
- package/components/calendar/calendar.component.d.ts +3 -5
- package/components/calendar/calendar.component.scss +79 -0
- package/components/drag-backdrop/drag-backdrop.component.d.ts +1 -5
- package/components/drag-backdrop/drag-backdrop.component.scss +50 -0
- package/components/icon/icon.component.d.ts +2 -4
- package/components/icon/icon.component.scss +13 -0
- package/components/links/links.component.scss +29 -0
- package/components/main/gantt-main.component.d.ts +2 -3
- package/components/range/range.component.d.ts +2 -5
- package/components/range/range.component.scss +35 -0
- package/components/table/gantt-table.component.d.ts +2 -3
- 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/esm2020/components/bar/bar.component.mjs +101 -0
- package/esm2020/components/calendar/calendar.component.mjs +88 -0
- package/esm2020/components/drag-backdrop/drag-backdrop.component.mjs +13 -0
- package/esm2020/components/icon/icon.component.mjs +36 -0
- 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/esm2020/components/main/gantt-main.component.mjs +49 -0
- package/esm2020/components/range/range.component.mjs +25 -0
- package/esm2020/components/table/gantt-table.component.mjs +163 -0
- package/{esm2015/gantt-abstract.js → esm2020/gantt-abstract.mjs} +0 -0
- package/esm2020/gantt-dom.service.mjs +117 -0
- package/esm2020/gantt-drag-container.mjs +78 -0
- package/esm2020/gantt-item-upper.mjs +58 -0
- package/esm2020/gantt-print.service.mjs +94 -0
- package/esm2020/gantt-upper.mjs +339 -0
- package/esm2020/gantt.component.mjs +150 -0
- 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/esm2020/root.component.mjs +130 -0
- package/esm2020/table/gantt-column.component.mjs +36 -0
- package/esm2020/table/gantt-table.component.mjs +25 -0
- package/{esm2015/utils/date.js → esm2020/utils/date.mjs} +0 -0
- package/{esm2015/utils/helpers.js → esm2020/utils/helpers.mjs} +0 -0
- package/esm2020/utils/passive-listeners.mjs +30 -0
- package/esm2020/utils/set-style-with-vendor-prefix.mjs +15 -0
- package/{esm2015/views/day.js → esm2020/views/day.mjs} +1 -1
- 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 +3080 -0
- package/fesm2015/worktile-gantt.mjs.map +1 -0
- package/{fesm2015/worktile-gantt.js → fesm2020/worktile-gantt.mjs} +344 -288
- package/fesm2020/worktile-gantt.mjs.map +1 -0
- package/gantt-dom.service.d.ts +11 -4
- package/gantt-drag-container.d.ts +1 -1
- package/gantt-item-upper.d.ts +6 -6
- package/gantt-print.service.d.ts +1 -1
- package/gantt-upper.d.ts +6 -6
- package/gantt.component.d.ts +2 -4
- package/gantt.component.scss +83 -0
- package/package.json +23 -9
- package/root.component.d.ts +5 -3
- package/styles/index.scss +10 -0
- package/styles/variables.scss +46 -0
- package/table/gantt-column.component.d.ts +2 -3
- package/table/gantt-table.component.d.ts +2 -4
- package/utils/passive-listeners.d.ts +13 -0
- package/utils/set-style-with-vendor-prefix.d.ts +12 -0
- package/README.md +0 -24
- package/bundles/worktile-gantt.umd.js +0 -3622
- package/bundles/worktile-gantt.umd.js.map +0 -1
- package/esm2015/components/bar/bar-drag.js +0 -295
- package/esm2015/components/bar/bar.component.js +0 -98
- package/esm2015/components/calendar/calendar.component.js +0 -86
- package/esm2015/components/drag-backdrop/drag-backdrop.component.js +0 -21
- package/esm2015/components/icon/icon.component.js +0 -38
- package/esm2015/components/links/lines/curve.js +0 -96
- package/esm2015/components/links/links.component.js +0 -173
- package/esm2015/components/main/gantt-main.component.js +0 -53
- package/esm2015/components/range/range.component.js +0 -37
- package/esm2015/components/table/gantt-table.component.js +0 -163
- package/esm2015/gantt-dom.service.js +0 -103
- package/esm2015/gantt-drag-container.js +0 -77
- package/esm2015/gantt-item-upper.js +0 -58
- package/esm2015/gantt-print.service.js +0 -94
- package/esm2015/gantt-upper.js +0 -331
- package/esm2015/gantt.component.js +0 -155
- package/esm2015/root.component.js +0 -123
- package/esm2015/table/gantt-column.component.js +0 -37
- package/esm2015/table/gantt-table.component.js +0 -26
- package/fesm2015/worktile-gantt.js.map +0 -1
- package/main.bundle.scss +0 -687
|
@@ -0,0 +1,3080 @@
|
|
|
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
|
+
const targetRect = event.source.element.nativeElement.getBoundingClientRect();
|
|
1455
|
+
const distance = { x: targetRect.left - tableRect.left, y: targetRect.top - tableRect.top };
|
|
1456
|
+
this.draglineElementRef.nativeElement.style.left = `${distance.x}px`;
|
|
1457
|
+
this.draglineElementRef.nativeElement.style.display = 'block';
|
|
1458
|
+
}
|
|
1459
|
+
hideAuxiliaryLine() {
|
|
1460
|
+
this.draglineElementRef.nativeElement.style.display = 'none';
|
|
1461
|
+
}
|
|
1462
|
+
trackBy(index, item) {
|
|
1463
|
+
return item.id || index;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
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 });
|
|
1467
|
+
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 } });
|
|
1468
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttTableComponent, decorators: [{
|
|
1469
|
+
type: Component,
|
|
1470
|
+
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" }]
|
|
1471
|
+
}], ctorParameters: function () {
|
|
1472
|
+
return [{ type: undefined, decorators: [{
|
|
1473
|
+
type: Inject,
|
|
1474
|
+
args: [GANTT_ABSTRACT_TOKEN]
|
|
1475
|
+
}] }, { type: GanttUpper, decorators: [{
|
|
1476
|
+
type: Inject,
|
|
1477
|
+
args: [GANTT_UPPER_TOKEN]
|
|
1478
|
+
}] }, { type: i0.ElementRef }];
|
|
1479
|
+
}, propDecorators: { groups: [{
|
|
1480
|
+
type: Input
|
|
1481
|
+
}], items: [{
|
|
1482
|
+
type: Input
|
|
1483
|
+
}], columns: [{
|
|
1484
|
+
type: Input
|
|
1485
|
+
}], groupTemplate: [{
|
|
1486
|
+
type: Input
|
|
1487
|
+
}], emptyTemplate: [{
|
|
1488
|
+
type: Input
|
|
1489
|
+
}], rowBeforeTemplate: [{
|
|
1490
|
+
type: Input
|
|
1491
|
+
}], rowAfterTemplate: [{
|
|
1492
|
+
type: Input
|
|
1493
|
+
}], itemClick: [{
|
|
1494
|
+
type: Output
|
|
1495
|
+
}], draglineElementRef: [{
|
|
1496
|
+
type: ViewChild,
|
|
1497
|
+
args: ['dragLine', { static: true }]
|
|
1498
|
+
}], ganttTableClass: [{
|
|
1499
|
+
type: HostBinding,
|
|
1500
|
+
args: ['class.gantt-table']
|
|
1501
|
+
}], ganttTableEmptyClass: [{
|
|
1502
|
+
type: HostBinding,
|
|
1503
|
+
args: ['class.gantt-table-empty']
|
|
1504
|
+
}] } });
|
|
1505
|
+
|
|
1506
|
+
/** Cached result of whether the user's browser supports passive event listeners. */
|
|
1507
|
+
let supportsPassiveEvents;
|
|
1508
|
+
/**
|
|
1509
|
+
* Checks whether the user's browser supports passive event listeners.
|
|
1510
|
+
* See: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md
|
|
1511
|
+
*/
|
|
1512
|
+
function supportsPassiveEventListeners() {
|
|
1513
|
+
if (supportsPassiveEvents == null && typeof window !== 'undefined') {
|
|
1514
|
+
try {
|
|
1515
|
+
window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
|
|
1516
|
+
get: () => (supportsPassiveEvents = true)
|
|
1517
|
+
}));
|
|
1518
|
+
}
|
|
1519
|
+
finally {
|
|
1520
|
+
supportsPassiveEvents = supportsPassiveEvents || false;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
return supportsPassiveEvents;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Normalizes an `AddEventListener` object to something that can be passed
|
|
1527
|
+
* to `addEventListener` on any browser, no matter whether it supports the
|
|
1528
|
+
* `options` parameter.
|
|
1529
|
+
*/
|
|
1530
|
+
function normalizePassiveListenerOptions(options) {
|
|
1531
|
+
return supportsPassiveEventListeners() ? options : !!options.capture;
|
|
1532
|
+
}
|
|
1533
|
+
/** Options used to bind passive event listeners. */
|
|
1534
|
+
const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
|
|
1535
|
+
|
|
1536
|
+
const scrollThreshold = 50;
|
|
1537
|
+
var ScrollDirection;
|
|
1538
|
+
(function (ScrollDirection) {
|
|
1539
|
+
ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
|
|
1540
|
+
ScrollDirection[ScrollDirection["LEFT"] = 1] = "LEFT";
|
|
1541
|
+
ScrollDirection[ScrollDirection["RIGHT"] = 2] = "RIGHT";
|
|
1542
|
+
})(ScrollDirection || (ScrollDirection = {}));
|
|
1543
|
+
class GanttDomService {
|
|
1544
|
+
constructor(ngZone, platformId) {
|
|
1545
|
+
this.ngZone = ngZone;
|
|
1546
|
+
this.platformId = platformId;
|
|
1547
|
+
this.unsubscribe$ = new Subject();
|
|
1548
|
+
}
|
|
1549
|
+
monitorScrollChange() {
|
|
1550
|
+
this.ngZone.runOutsideAngular(() => merge(fromEvent(this.mainContainer, 'scroll', passiveListenerOptions), fromEvent(this.sideContainer, 'scroll', passiveListenerOptions))
|
|
1551
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1552
|
+
.subscribe((event) => {
|
|
1553
|
+
this.syncScroll(event);
|
|
1554
|
+
}));
|
|
1555
|
+
// fromEvent(this.mainContainer, 'scroll')
|
|
1556
|
+
// .pipe(startWith(), takeUntil(this.unsubscribe$))
|
|
1557
|
+
// .subscribe((event) => {
|
|
1558
|
+
// // if (this.mainContainer.scrollLeft > 0) {
|
|
1559
|
+
// // this.side.classList.add('gantt-side-has-shadow');
|
|
1560
|
+
// // } else {
|
|
1561
|
+
// // this.side.classList.remove('gantt-side-has-shadow');
|
|
1562
|
+
// // }
|
|
1563
|
+
// });
|
|
1564
|
+
}
|
|
1565
|
+
syncScroll(event) {
|
|
1566
|
+
const target = event.currentTarget;
|
|
1567
|
+
this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
|
|
1568
|
+
this.sideContainer.scrollTop = target.scrollTop;
|
|
1569
|
+
this.mainContainer.scrollTop = target.scrollTop;
|
|
1570
|
+
}
|
|
1571
|
+
disableBrowserWheelEvent() {
|
|
1572
|
+
const container = this.mainContainer;
|
|
1573
|
+
this.ngZone.runOutsideAngular(() => fromEvent(container, 'wheel')
|
|
1574
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1575
|
+
.subscribe((event) => {
|
|
1576
|
+
const delta = event.deltaX;
|
|
1577
|
+
if (!delta) {
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
if ((container.scrollLeft + container.offsetWidth === container.scrollWidth && delta > 0) ||
|
|
1581
|
+
(container.scrollLeft === 0 && delta < 0)) {
|
|
1582
|
+
event.preventDefault();
|
|
1583
|
+
}
|
|
1584
|
+
}));
|
|
1585
|
+
}
|
|
1586
|
+
initialize(root) {
|
|
1587
|
+
this.root = root.nativeElement;
|
|
1588
|
+
this.side = this.root.getElementsByClassName('gantt-side')[0];
|
|
1589
|
+
this.container = this.root.getElementsByClassName('gantt-container')[0];
|
|
1590
|
+
this.sideContainer = this.root.getElementsByClassName('gantt-side-container')[0];
|
|
1591
|
+
this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
|
|
1592
|
+
this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-overlay')[0];
|
|
1593
|
+
this.monitorScrollChange();
|
|
1594
|
+
this.disableBrowserWheelEvent();
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* @returns An observable that will emit outside the Angular zone. Note, consumers should re-enter the Angular zone
|
|
1598
|
+
* to run the change detection if needed.
|
|
1599
|
+
*/
|
|
1600
|
+
getViewerScroll(options) {
|
|
1601
|
+
return new Observable((subscriber) => this.ngZone.runOutsideAngular(() => fromEvent(this.mainContainer, 'scroll', options)
|
|
1602
|
+
.pipe(map(() => this.mainContainer.scrollLeft), pairwise(), map(([previous, current]) => {
|
|
1603
|
+
const event = {
|
|
1604
|
+
target: this.mainContainer,
|
|
1605
|
+
direction: ScrollDirection.NONE
|
|
1606
|
+
};
|
|
1607
|
+
if (current - previous < 0) {
|
|
1608
|
+
if (this.mainContainer.scrollLeft < scrollThreshold && this.mainContainer.scrollLeft > 0) {
|
|
1609
|
+
event.direction = ScrollDirection.LEFT;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
if (current - previous > 0) {
|
|
1613
|
+
if (this.mainContainer.scrollWidth - this.mainContainer.clientWidth - this.mainContainer.scrollLeft <
|
|
1614
|
+
scrollThreshold) {
|
|
1615
|
+
event.direction = ScrollDirection.RIGHT;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
return event;
|
|
1619
|
+
}))
|
|
1620
|
+
.subscribe(subscriber)));
|
|
1621
|
+
}
|
|
1622
|
+
getResize() {
|
|
1623
|
+
return isPlatformServer(this.platformId) ? EMPTY : fromEvent(window, 'resize').pipe(auditTime(150));
|
|
1624
|
+
}
|
|
1625
|
+
scrollMainContainer(left) {
|
|
1626
|
+
if (isNumber(left)) {
|
|
1627
|
+
const scrollLeft = left - this.mainContainer.clientWidth / 2;
|
|
1628
|
+
this.mainContainer.scrollLeft = scrollLeft > scrollThreshold ? scrollLeft : 0;
|
|
1629
|
+
this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
ngOnDestroy() {
|
|
1633
|
+
this.unsubscribe$.next();
|
|
1634
|
+
this.unsubscribe$.complete();
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
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 });
|
|
1638
|
+
GanttDomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDomService });
|
|
1639
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDomService, decorators: [{
|
|
1640
|
+
type: Injectable
|
|
1641
|
+
}], ctorParameters: function () {
|
|
1642
|
+
return [{ type: i0.NgZone }, { type: undefined, decorators: [{
|
|
1643
|
+
type: Inject,
|
|
1644
|
+
args: [PLATFORM_ID]
|
|
1645
|
+
}] }];
|
|
1646
|
+
} });
|
|
1647
|
+
|
|
1648
|
+
function getDependencyType(path, dependencyTypes) {
|
|
1649
|
+
if (dependencyTypes.includes(GanttLinkType.ss) && path.from.pos === InBarPosition.start && path.to.pos === InBarPosition.start) {
|
|
1650
|
+
return GanttLinkType.ss;
|
|
1651
|
+
}
|
|
1652
|
+
if (dependencyTypes.includes(GanttLinkType.ff) && path.from.pos === InBarPosition.finish && path.to.pos === InBarPosition.finish) {
|
|
1653
|
+
return GanttLinkType.ff;
|
|
1654
|
+
}
|
|
1655
|
+
if (dependencyTypes.includes(GanttLinkType.sf) && path.from.pos === InBarPosition.start && path.to.pos === InBarPosition.finish) {
|
|
1656
|
+
return GanttLinkType.sf;
|
|
1657
|
+
}
|
|
1658
|
+
return GanttLinkType.fs;
|
|
1659
|
+
}
|
|
1660
|
+
var InBarPosition;
|
|
1661
|
+
(function (InBarPosition) {
|
|
1662
|
+
InBarPosition["start"] = "start";
|
|
1663
|
+
InBarPosition["finish"] = "finish";
|
|
1664
|
+
})(InBarPosition || (InBarPosition = {}));
|
|
1665
|
+
class GanttDragContainer {
|
|
1666
|
+
constructor(ganttUpper) {
|
|
1667
|
+
this.ganttUpper = ganttUpper;
|
|
1668
|
+
this.dragStarted = new EventEmitter();
|
|
1669
|
+
this.dragMoved = new EventEmitter();
|
|
1670
|
+
this.dragEnded = new EventEmitter();
|
|
1671
|
+
this.linkDragStarted = new EventEmitter();
|
|
1672
|
+
this.linkDragEntered = new EventEmitter();
|
|
1673
|
+
this.linkDragEnded = new EventEmitter();
|
|
1674
|
+
this.linkDragPath = { from: null, to: null };
|
|
1675
|
+
}
|
|
1676
|
+
emitLinkDragStarted(from) {
|
|
1677
|
+
this.linkDraggingId = from.item.id;
|
|
1678
|
+
this.linkDragPath.from = from;
|
|
1679
|
+
this.linkDragStarted.emit({
|
|
1680
|
+
source: from.item.origin,
|
|
1681
|
+
target: null
|
|
1682
|
+
});
|
|
1683
|
+
}
|
|
1684
|
+
emitLinkDragEntered(to) {
|
|
1685
|
+
this.linkDragPath.to = to;
|
|
1686
|
+
this.linkDragEntered.emit({
|
|
1687
|
+
source: this.linkDragPath.from.item.origin,
|
|
1688
|
+
target: to.item.origin
|
|
1689
|
+
});
|
|
1690
|
+
}
|
|
1691
|
+
emitLinkDragLeaved() {
|
|
1692
|
+
this.linkDragPath.to = null;
|
|
1693
|
+
}
|
|
1694
|
+
emitLinkDragEnded(to) {
|
|
1695
|
+
var _a;
|
|
1696
|
+
if (to) {
|
|
1697
|
+
this.linkDragPath.to = to;
|
|
1698
|
+
const dependencyType = getDependencyType(this.linkDragPath, (_a = this.ganttUpper.linkOptions) === null || _a === void 0 ? void 0 : _a.dependencyTypes);
|
|
1699
|
+
this.linkDragPath.from.item.addLink({
|
|
1700
|
+
link: this.linkDragPath.to.item.id,
|
|
1701
|
+
type: dependencyType
|
|
1702
|
+
});
|
|
1703
|
+
this.linkDragEnded.emit({
|
|
1704
|
+
source: this.linkDragPath.from.item.origin,
|
|
1705
|
+
target: this.linkDragPath.to.item.origin,
|
|
1706
|
+
type: dependencyType
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
this.linkDraggingId = null;
|
|
1710
|
+
this.linkDragPath = { from: null, to: null };
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
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 });
|
|
1714
|
+
GanttDragContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragContainer });
|
|
1715
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragContainer, decorators: [{
|
|
1716
|
+
type: Injectable
|
|
1717
|
+
}], ctorParameters: function () {
|
|
1718
|
+
return [{ type: GanttUpper, decorators: [{
|
|
1719
|
+
type: Inject,
|
|
1720
|
+
args: [GANTT_UPPER_TOKEN]
|
|
1721
|
+
}] }];
|
|
1722
|
+
} });
|
|
1723
|
+
|
|
1724
|
+
class GanttDragBackdropComponent {
|
|
1725
|
+
}
|
|
1726
|
+
GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1727
|
+
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" });
|
|
1728
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
|
|
1729
|
+
type: Component,
|
|
1730
|
+
args: [{ selector: 'gantt-drag-backdrop', host: {
|
|
1731
|
+
class: 'gantt-drag-backdrop'
|
|
1732
|
+
}, 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" }]
|
|
1733
|
+
}] });
|
|
1734
|
+
|
|
1735
|
+
class GanttPrintService {
|
|
1736
|
+
constructor() { }
|
|
1737
|
+
setInlineStyles(targetElem) {
|
|
1738
|
+
const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
|
|
1739
|
+
for (const svgElement of svgElements) {
|
|
1740
|
+
this.recursElementChildren(svgElement);
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
recursElementChildren(node) {
|
|
1744
|
+
const transformProperties = [
|
|
1745
|
+
'fill',
|
|
1746
|
+
'color',
|
|
1747
|
+
'font-size',
|
|
1748
|
+
'stroke',
|
|
1749
|
+
'font',
|
|
1750
|
+
'text-anchor',
|
|
1751
|
+
'stroke-dasharray',
|
|
1752
|
+
'shape-rendering',
|
|
1753
|
+
'stroke-width'
|
|
1754
|
+
];
|
|
1755
|
+
if (!node.style) {
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
const styles = getComputedStyle(node);
|
|
1759
|
+
for (const transformProperty of transformProperties) {
|
|
1760
|
+
node.style[transformProperty] = styles[transformProperty];
|
|
1761
|
+
}
|
|
1762
|
+
for (const child of Array.from(node.childNodes)) {
|
|
1763
|
+
this.recursElementChildren(child);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
register(root) {
|
|
1767
|
+
this.root = root.nativeElement;
|
|
1768
|
+
this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
|
|
1769
|
+
}
|
|
1770
|
+
print(name = 'download', ignoreElementClass) {
|
|
1771
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1772
|
+
const root = this.root;
|
|
1773
|
+
const mainContainer = this.mainContainer;
|
|
1774
|
+
// set print width
|
|
1775
|
+
const printWidth = root.offsetWidth;
|
|
1776
|
+
// set print height
|
|
1777
|
+
const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
|
|
1778
|
+
const html2canvas = (yield import(/* webpackChunkName: 'html2canvas' */ 'html2canvas')).default;
|
|
1779
|
+
html2canvas(root, {
|
|
1780
|
+
logging: false,
|
|
1781
|
+
allowTaint: true,
|
|
1782
|
+
useCORS: true,
|
|
1783
|
+
width: printWidth,
|
|
1784
|
+
height: printHeight,
|
|
1785
|
+
ignoreElements: (element) => {
|
|
1786
|
+
if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
|
|
1787
|
+
return true;
|
|
1788
|
+
}
|
|
1789
|
+
if (element.classList.contains('gantt-calendar-today-overlay')) {
|
|
1790
|
+
return true;
|
|
1791
|
+
}
|
|
1792
|
+
},
|
|
1793
|
+
onclone: (cloneDocument) => {
|
|
1794
|
+
const ganttClass = root.className;
|
|
1795
|
+
const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
|
|
1796
|
+
const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
|
|
1797
|
+
const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
|
|
1798
|
+
const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
|
|
1799
|
+
// change targetDom width
|
|
1800
|
+
cloneGanttDom.style.width = `${printWidth}px`;
|
|
1801
|
+
cloneGanttDom.style.height = `${printHeight}px`;
|
|
1802
|
+
cloneGanttDom.style.overflow = `unset`;
|
|
1803
|
+
cloneGanttContainerDom.style.backgroundColor = '#fff';
|
|
1804
|
+
cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
|
|
1805
|
+
cloneCalendarOverlay.setAttribute('style', `background: transparent`);
|
|
1806
|
+
if (cloneLinksOverlay) {
|
|
1807
|
+
cloneLinksOverlay.setAttribute('height', `${printHeight}`);
|
|
1808
|
+
cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
|
|
1809
|
+
}
|
|
1810
|
+
// setInlineStyles for svg
|
|
1811
|
+
this.setInlineStyles(cloneGanttDom);
|
|
1812
|
+
}
|
|
1813
|
+
}).then((canvas) => {
|
|
1814
|
+
const link = document.createElement('a');
|
|
1815
|
+
const dataUrl = canvas.toDataURL('image/png');
|
|
1816
|
+
link.download = `${name}.png`;
|
|
1817
|
+
link.href = dataUrl;
|
|
1818
|
+
link.click();
|
|
1819
|
+
});
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
GanttPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttPrintService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1824
|
+
GanttPrintService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttPrintService });
|
|
1825
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttPrintService, decorators: [{
|
|
1826
|
+
type: Injectable
|
|
1827
|
+
}], ctorParameters: function () { return []; } });
|
|
1828
|
+
|
|
1829
|
+
const mainHeight = 5000;
|
|
1830
|
+
class GanttCalendarComponent {
|
|
1831
|
+
constructor(ganttUpper, ngZone, elementRef) {
|
|
1832
|
+
this.ganttUpper = ganttUpper;
|
|
1833
|
+
this.ngZone = ngZone;
|
|
1834
|
+
this.elementRef = elementRef;
|
|
1835
|
+
this.headerHeight = headerHeight;
|
|
1836
|
+
this.mainHeight = mainHeight;
|
|
1837
|
+
this.todayHeight = todayHeight;
|
|
1838
|
+
this.todayWidth = todayWidth;
|
|
1839
|
+
this.todayBorderRadius = todayBorderRadius;
|
|
1840
|
+
this.viewTypes = GanttViewType;
|
|
1841
|
+
this.className = true;
|
|
1842
|
+
this.unsubscribe$ = new Subject();
|
|
1843
|
+
}
|
|
1844
|
+
get view() {
|
|
1845
|
+
return this.ganttUpper.view;
|
|
1846
|
+
}
|
|
1847
|
+
setTodayPoint() {
|
|
1848
|
+
const x = this.view.getTodayXPoint();
|
|
1849
|
+
const today = new GanttDate().getDate();
|
|
1850
|
+
const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
|
|
1851
|
+
const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
|
|
1852
|
+
const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
|
|
1853
|
+
if (isNumber(x)) {
|
|
1854
|
+
if (rect) {
|
|
1855
|
+
rect.style.left = `${x - todayWidth / 2}px`;
|
|
1856
|
+
rect.style.top = `${headerHeight - todayHeight}px`;
|
|
1857
|
+
rect.innerHTML = today.toString();
|
|
1858
|
+
}
|
|
1859
|
+
if (line) {
|
|
1860
|
+
line.style.left = `${x}px`;
|
|
1861
|
+
line.style.top = `${headerHeight}px`;
|
|
1862
|
+
line.style.bottom = `${-mainHeight}px`;
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
else {
|
|
1866
|
+
todayEle.style.display = 'none';
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
ngOnInit() {
|
|
1870
|
+
// Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
|
|
1871
|
+
// the `onStable` will never emit any value.
|
|
1872
|
+
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
|
|
1873
|
+
// Normally this isn't in the zone, but it can cause performance regressions for apps
|
|
1874
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
1875
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1876
|
+
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
1877
|
+
merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
|
|
1878
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1879
|
+
.subscribe(() => {
|
|
1880
|
+
this.setTodayPoint();
|
|
1881
|
+
});
|
|
1882
|
+
});
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
trackBy(index, point) {
|
|
1886
|
+
return point.text || index;
|
|
1887
|
+
}
|
|
1888
|
+
ngOnDestroy() {
|
|
1889
|
+
this.unsubscribe$.next();
|
|
1890
|
+
this.unsubscribe$.complete();
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
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 });
|
|
1894
|
+
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"] }] });
|
|
1895
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttCalendarComponent, decorators: [{
|
|
1896
|
+
type: Component,
|
|
1897
|
+
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" }]
|
|
1898
|
+
}], ctorParameters: function () {
|
|
1899
|
+
return [{ type: GanttUpper, decorators: [{
|
|
1900
|
+
type: Inject,
|
|
1901
|
+
args: [GANTT_UPPER_TOKEN]
|
|
1902
|
+
}] }, { type: i0.NgZone }, { type: i0.ElementRef }];
|
|
1903
|
+
}, propDecorators: { className: [{
|
|
1904
|
+
type: HostBinding,
|
|
1905
|
+
args: ['class.gantt-calendar-overlay']
|
|
1906
|
+
}] } });
|
|
1907
|
+
|
|
1908
|
+
class NgxGanttRootComponent {
|
|
1909
|
+
constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
|
|
1910
|
+
this.elementRef = elementRef;
|
|
1911
|
+
this.ngZone = ngZone;
|
|
1912
|
+
this.dom = dom;
|
|
1913
|
+
this.dragContainer = dragContainer;
|
|
1914
|
+
this.ganttUpper = ganttUpper;
|
|
1915
|
+
this.printService = printService;
|
|
1916
|
+
this.unsubscribe$ = new Subject();
|
|
1917
|
+
this.ganttUpper.dragContainer = dragContainer;
|
|
1918
|
+
}
|
|
1919
|
+
get view() {
|
|
1920
|
+
return this.ganttUpper.view;
|
|
1921
|
+
}
|
|
1922
|
+
ngOnInit() {
|
|
1923
|
+
// Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
|
|
1924
|
+
// the `onStable` will never emit any value.
|
|
1925
|
+
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
|
|
1926
|
+
// Normally this isn't in the zone, but it can cause performance regressions for apps
|
|
1927
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
1928
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1929
|
+
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
1930
|
+
this.dom.initialize(this.elementRef);
|
|
1931
|
+
if (this.printService) {
|
|
1932
|
+
this.printService.register(this.elementRef);
|
|
1933
|
+
}
|
|
1934
|
+
this.setupScrollClass();
|
|
1935
|
+
this.setupResize();
|
|
1936
|
+
this.setupViewScroll();
|
|
1937
|
+
// 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
|
|
1938
|
+
this.elementRef.nativeElement.style.opacity = '1';
|
|
1939
|
+
this.ganttUpper.viewChange.pipe(startWith(null), takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
1940
|
+
this.scrollToToday();
|
|
1941
|
+
});
|
|
1942
|
+
});
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
ngOnDestroy() {
|
|
1946
|
+
this.unsubscribe$.next();
|
|
1947
|
+
}
|
|
1948
|
+
setupViewScroll() {
|
|
1949
|
+
if (this.ganttUpper.disabledLoadOnScroll) {
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
this.dom
|
|
1953
|
+
.getViewerScroll(passiveListenerOptions)
|
|
1954
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1955
|
+
.subscribe((event) => {
|
|
1956
|
+
if (event.direction === ScrollDirection.LEFT) {
|
|
1957
|
+
const dates = this.view.addStartDate();
|
|
1958
|
+
if (dates) {
|
|
1959
|
+
event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
|
|
1960
|
+
if (this.ganttUpper.loadOnScroll.observers) {
|
|
1961
|
+
this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
if (event.direction === ScrollDirection.RIGHT) {
|
|
1966
|
+
const dates = this.view.addEndDate();
|
|
1967
|
+
if (dates && this.ganttUpper.loadOnScroll.observers) {
|
|
1968
|
+
this.ngZone.run(() => this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() }));
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
setupResize() {
|
|
1974
|
+
this.dom
|
|
1975
|
+
.getResize()
|
|
1976
|
+
.pipe(takeUntil(this.unsubscribe$))
|
|
1977
|
+
.subscribe(() => {
|
|
1978
|
+
this.setupScrollClass();
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
setupScrollClass() {
|
|
1982
|
+
const mainContainer = this.dom.mainContainer;
|
|
1983
|
+
const height = mainContainer.offsetHeight;
|
|
1984
|
+
const scrollHeight = mainContainer.scrollHeight;
|
|
1985
|
+
if (scrollHeight > height) {
|
|
1986
|
+
this.elementRef.nativeElement.className = 'gantt gantt-scroll';
|
|
1987
|
+
}
|
|
1988
|
+
else {
|
|
1989
|
+
this.elementRef.nativeElement.className = 'gantt';
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
scrollToToday() {
|
|
1993
|
+
const x = this.view.getTodayXPoint();
|
|
1994
|
+
this.dom.scrollMainContainer(x);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
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 });
|
|
1998
|
+
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"] }] });
|
|
1999
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
|
|
2000
|
+
type: Component,
|
|
2001
|
+
args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
|
|
2002
|
+
class: 'gantt'
|
|
2003
|
+
}, 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" }]
|
|
2004
|
+
}], ctorParameters: function () {
|
|
2005
|
+
return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
|
|
2006
|
+
type: Inject,
|
|
2007
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2008
|
+
}] }, { type: GanttPrintService, decorators: [{
|
|
2009
|
+
type: Optional
|
|
2010
|
+
}] }];
|
|
2011
|
+
}, propDecorators: { sideWidth: [{
|
|
2012
|
+
type: Input
|
|
2013
|
+
}], sideTemplate: [{
|
|
2014
|
+
type: ContentChild,
|
|
2015
|
+
args: ['sideTemplate', { static: true }]
|
|
2016
|
+
}], mainTemplate: [{
|
|
2017
|
+
type: ContentChild,
|
|
2018
|
+
args: ['mainTemplate', { static: true }]
|
|
2019
|
+
}], backdrop: [{
|
|
2020
|
+
type: ViewChild,
|
|
2021
|
+
args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
|
|
2022
|
+
}] } });
|
|
2023
|
+
|
|
2024
|
+
class GanttLinkLine {
|
|
2025
|
+
constructor() { }
|
|
2026
|
+
generatePath(source, target, type) {
|
|
2027
|
+
if (source.before && source.after && target.before && target.after) {
|
|
2028
|
+
let path = '';
|
|
2029
|
+
switch (type) {
|
|
2030
|
+
case GanttLinkType.ss:
|
|
2031
|
+
path = this.generateSSPath(source, target);
|
|
2032
|
+
break;
|
|
2033
|
+
case GanttLinkType.ff:
|
|
2034
|
+
path = this.generateFFPath(source, target);
|
|
2035
|
+
break;
|
|
2036
|
+
case GanttLinkType.sf:
|
|
2037
|
+
path = this.generateFSAndSFPath(source, target, type);
|
|
2038
|
+
break;
|
|
2039
|
+
default:
|
|
2040
|
+
path = this.generateFSAndSFPath(source, target);
|
|
2041
|
+
}
|
|
2042
|
+
return path;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
let GanttLinkLineCurve = class GanttLinkLineCurve extends GanttLinkLine {
|
|
2048
|
+
constructor(ganttUpper) {
|
|
2049
|
+
super();
|
|
2050
|
+
this.ganttUpper = ganttUpper;
|
|
2051
|
+
}
|
|
2052
|
+
generateSSPath(source, target) {
|
|
2053
|
+
const x1 = source.before.x;
|
|
2054
|
+
const y1 = source.before.y;
|
|
2055
|
+
const x4 = target.before.x;
|
|
2056
|
+
const y4 = target.before.y;
|
|
2057
|
+
const isMirror = y4 > y1 ? 0 : 1;
|
|
2058
|
+
const radius = Math.abs(y4 - y1) / 2;
|
|
2059
|
+
if (x4 > x1) {
|
|
2060
|
+
return `M ${x1} ${y1}
|
|
2061
|
+
A ${radius} ${radius} 0 1 ${isMirror} ${x1} ${y4}
|
|
2062
|
+
L ${x4} ${y4}`;
|
|
2063
|
+
}
|
|
2064
|
+
else {
|
|
2065
|
+
return `M ${x1} ${y1}
|
|
2066
|
+
L ${x4} ${y1}
|
|
2067
|
+
A ${radius} ${radius} 0 1 ${isMirror} ${x4} ${y4}`;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
generateFFPath(source, target) {
|
|
2071
|
+
const x1 = source.after.x;
|
|
2072
|
+
const y1 = source.after.y;
|
|
2073
|
+
const x4 = target.after.x;
|
|
2074
|
+
const y4 = target.after.y;
|
|
2075
|
+
const isMirror = y4 > y1 ? 1 : 0;
|
|
2076
|
+
const radius = Math.abs(y4 - y1) / 2;
|
|
2077
|
+
if (x4 > x1) {
|
|
2078
|
+
return `M ${x1} ${y1}
|
|
2079
|
+
L ${x4} ${y1}
|
|
2080
|
+
A ${radius} ${radius} 0 1 ${isMirror} ${x4} ${y4}`;
|
|
2081
|
+
}
|
|
2082
|
+
else {
|
|
2083
|
+
return `M ${x1} ${y1}
|
|
2084
|
+
A ${radius} ${radius} 0 1 ${isMirror} ${x1} ${y4}
|
|
2085
|
+
L ${x4} ${y4}`;
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
generateFSAndSFPath(source, target, type) {
|
|
2089
|
+
var _a;
|
|
2090
|
+
let x1 = source.after.x;
|
|
2091
|
+
let y1 = source.after.y;
|
|
2092
|
+
let x4 = target.before.x;
|
|
2093
|
+
let y4 = target.before.y;
|
|
2094
|
+
const bezierWeight = 0.5;
|
|
2095
|
+
if (type === GanttLinkType.sf) {
|
|
2096
|
+
x1 = target.after.x;
|
|
2097
|
+
y1 = target.after.y;
|
|
2098
|
+
x4 = source.before.x;
|
|
2099
|
+
y4 = source.before.y;
|
|
2100
|
+
}
|
|
2101
|
+
let dx = Math.abs(x4 - x1) * bezierWeight;
|
|
2102
|
+
let x2 = x1 + dx;
|
|
2103
|
+
let x3 = x4 - dx;
|
|
2104
|
+
const centerX = (x1 + x4) / 2;
|
|
2105
|
+
const centerY = (y1 + y4) / 2;
|
|
2106
|
+
let controlX = this.ganttUpper.styles.lineHeight / 2;
|
|
2107
|
+
const controlY = this.ganttUpper.styles.lineHeight / 2;
|
|
2108
|
+
if (x1 >= x4) {
|
|
2109
|
+
if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
|
|
2110
|
+
return `M ${x1} ${y1}
|
|
2111
|
+
C ${x1 + controlX} ${y1} ${x1 + controlX} ${y4 > y1 ? y1 + controlX : y1 - controlX} ${x1} ${y4 > y1 ? y1 + controlY : y1 - controlY}
|
|
2112
|
+
L ${x4} ${y4 > y1 ? y4 - controlY : y4 + controlY}
|
|
2113
|
+
C ${x4 - controlY} ${y4 > y1 ? y4 - controlY : y4 + controlY} ${x4 - controlX} ${y4} ${x4} ${y4}
|
|
2114
|
+
`;
|
|
2115
|
+
}
|
|
2116
|
+
else {
|
|
2117
|
+
controlX = this.ganttUpper.styles.lineHeight;
|
|
2118
|
+
return `M ${x1} ${y1}
|
|
2119
|
+
C ${x1 + controlX} ${y1} ${x1 + controlX} ${y4 > y1 ? y1 + controlX : y1 - controlX} ${centerX} ${centerY}
|
|
2120
|
+
C ${x4 - controlX} ${y4 > y1 ? y4 - controlX : y4 + controlX} ${x4 - controlX} ${y4} ${x4} ${y4}
|
|
2121
|
+
`;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
else if (((_a = this.ganttUpper.linkOptions) === null || _a === void 0 ? void 0 : _a.showArrow) && x4 - x1 < 200) {
|
|
2125
|
+
dx = Math.max(Math.abs(y4 - y1) * bezierWeight, 60);
|
|
2126
|
+
x2 = x1 + dx;
|
|
2127
|
+
x3 = x4 - dx;
|
|
2128
|
+
return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
|
|
2129
|
+
}
|
|
2130
|
+
return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
|
|
2131
|
+
}
|
|
2132
|
+
};
|
|
2133
|
+
GanttLinkLineCurve = __decorate([
|
|
2134
|
+
__param(0, Inject(GANTT_UPPER_TOKEN))
|
|
2135
|
+
], GanttLinkLineCurve);
|
|
2136
|
+
|
|
2137
|
+
class GanttLinkLineStraight extends GanttLinkLine {
|
|
2138
|
+
constructor() {
|
|
2139
|
+
super();
|
|
2140
|
+
this.pathControl = 20;
|
|
2141
|
+
}
|
|
2142
|
+
generateSSPath(source, target) {
|
|
2143
|
+
const x1 = source.before.x;
|
|
2144
|
+
const y1 = source.before.y;
|
|
2145
|
+
const x4 = target.before.x;
|
|
2146
|
+
const y4 = target.before.y;
|
|
2147
|
+
const control = this.pathControl;
|
|
2148
|
+
return `M ${x1} ${y1}
|
|
2149
|
+
L ${x4 > x1 ? x1 - control : x4 - control} ${y1}
|
|
2150
|
+
L ${x4 > x1 ? x1 - control : x4 - control} ${y4}
|
|
2151
|
+
L ${x4} ${y4}`;
|
|
2152
|
+
}
|
|
2153
|
+
generateFFPath(source, target) {
|
|
2154
|
+
const x1 = source.after.x;
|
|
2155
|
+
const y1 = source.after.y;
|
|
2156
|
+
const x4 = target.after.x;
|
|
2157
|
+
const y4 = target.after.y;
|
|
2158
|
+
const control = this.pathControl;
|
|
2159
|
+
return `M ${x1} ${y1}
|
|
2160
|
+
L ${x4 > x1 ? x4 + control : x1 + control} ${y1}
|
|
2161
|
+
L ${x4 > x1 ? x4 + control : x1 + control} ${y4}
|
|
2162
|
+
L ${x4} ${y4}`;
|
|
2163
|
+
}
|
|
2164
|
+
generateFSAndSFPath(source, target, type) {
|
|
2165
|
+
let x1 = source.after.x;
|
|
2166
|
+
let y1 = source.after.y;
|
|
2167
|
+
let x4 = target.before.x;
|
|
2168
|
+
let y4 = target.before.y;
|
|
2169
|
+
const control = this.pathControl;
|
|
2170
|
+
if (type === GanttLinkType.sf) {
|
|
2171
|
+
x1 = target.after.x;
|
|
2172
|
+
y1 = target.after.y;
|
|
2173
|
+
x4 = source.before.x;
|
|
2174
|
+
y4 = source.before.y;
|
|
2175
|
+
}
|
|
2176
|
+
if (x4 - x1 >= 40) {
|
|
2177
|
+
return `M ${x1} ${y1}
|
|
2178
|
+
L ${x1 + control} ${y1}
|
|
2179
|
+
L ${x1 + control} ${y4}
|
|
2180
|
+
L ${x4} ${y4}`;
|
|
2181
|
+
}
|
|
2182
|
+
else {
|
|
2183
|
+
return `M ${x1} ${y1}
|
|
2184
|
+
L ${x1 + control} ${y1}
|
|
2185
|
+
L ${x1 + control} ${y4 > y1 ? y1 + control : y1 - control}
|
|
2186
|
+
L ${x4 - control} ${y4 > y1 ? y1 + control : y1 - control}
|
|
2187
|
+
L ${x4 - control} ${y4}
|
|
2188
|
+
L ${x4} ${y4}`;
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
function createLineGenerator(type, ganttUpper) {
|
|
2194
|
+
switch (type) {
|
|
2195
|
+
case GanttLinkLineType.curve:
|
|
2196
|
+
return new GanttLinkLineCurve(ganttUpper);
|
|
2197
|
+
case GanttLinkLineType.straight:
|
|
2198
|
+
return new GanttLinkLineStraight();
|
|
2199
|
+
default:
|
|
2200
|
+
throw new Error('gantt link path type invalid');
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
class GanttLinksComponent {
|
|
2205
|
+
constructor(ganttUpper, cdr, elementRef, ganttDragContainer) {
|
|
2206
|
+
this.ganttUpper = ganttUpper;
|
|
2207
|
+
this.cdr = cdr;
|
|
2208
|
+
this.elementRef = elementRef;
|
|
2209
|
+
this.ganttDragContainer = ganttDragContainer;
|
|
2210
|
+
this.groups = [];
|
|
2211
|
+
this.items = [];
|
|
2212
|
+
this.lineClick = new EventEmitter();
|
|
2213
|
+
this.links = [];
|
|
2214
|
+
this.ganttLinkTypes = GanttLinkType;
|
|
2215
|
+
this.showArrow = false;
|
|
2216
|
+
this.linkItems = [];
|
|
2217
|
+
this.firstChange = true;
|
|
2218
|
+
this.unsubscribe$ = new Subject();
|
|
2219
|
+
this.ganttLinksOverlay = true;
|
|
2220
|
+
}
|
|
2221
|
+
ngOnInit() {
|
|
2222
|
+
this.linkLine = createLineGenerator(this.ganttUpper.linkOptions.lineType, this.ganttUpper);
|
|
2223
|
+
this.showArrow = this.ganttUpper.linkOptions.showArrow;
|
|
2224
|
+
this.buildLinks();
|
|
2225
|
+
this.firstChange = false;
|
|
2226
|
+
this.ganttDragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2227
|
+
this.elementRef.nativeElement.style.visibility = 'hidden';
|
|
2228
|
+
});
|
|
2229
|
+
merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded)
|
|
2230
|
+
.pipe(skip(1), debounceTime(0), takeUntil(this.unsubscribe$))
|
|
2231
|
+
.subscribe(() => {
|
|
2232
|
+
this.elementRef.nativeElement.style.visibility = 'visible';
|
|
2233
|
+
this.buildLinks();
|
|
2234
|
+
this.cdr.detectChanges();
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
ngOnChanges() {
|
|
2238
|
+
if (!this.firstChange) {
|
|
2239
|
+
this.buildLinks();
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
computeItemPosition() {
|
|
2243
|
+
const lineHeight = this.ganttUpper.styles.lineHeight;
|
|
2244
|
+
const barHeight = this.ganttUpper.styles.barHeight;
|
|
2245
|
+
this.linkItems = [];
|
|
2246
|
+
if (this.groups.length > 0) {
|
|
2247
|
+
let itemNum = 0;
|
|
2248
|
+
let groupNum = 0;
|
|
2249
|
+
this.groups.forEach((group) => {
|
|
2250
|
+
groupNum++;
|
|
2251
|
+
if (group.expanded) {
|
|
2252
|
+
const items = recursiveItems(group.items);
|
|
2253
|
+
items.forEach((item, itemIndex) => {
|
|
2254
|
+
const y = (groupNum + itemNum + itemIndex) * lineHeight + item.refs.y + barHeight / 2;
|
|
2255
|
+
this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
|
|
2256
|
+
x: item.refs.x,
|
|
2257
|
+
y
|
|
2258
|
+
}, after: {
|
|
2259
|
+
x: item.refs.x + item.refs.width,
|
|
2260
|
+
y
|
|
2261
|
+
} }));
|
|
2262
|
+
});
|
|
2263
|
+
itemNum += items.length;
|
|
2264
|
+
}
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
else {
|
|
2268
|
+
const items = recursiveItems(this.items);
|
|
2269
|
+
items.forEach((item, itemIndex) => {
|
|
2270
|
+
const y = itemIndex * lineHeight + item.refs.y + barHeight / 2;
|
|
2271
|
+
this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
|
|
2272
|
+
x: item.refs.x,
|
|
2273
|
+
y
|
|
2274
|
+
}, after: {
|
|
2275
|
+
x: item.refs.x + item.refs.width,
|
|
2276
|
+
y
|
|
2277
|
+
} }));
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
buildLinks() {
|
|
2282
|
+
this.computeItemPosition();
|
|
2283
|
+
this.links = [];
|
|
2284
|
+
this.linkItems.forEach((source) => {
|
|
2285
|
+
if (source.origin.start || source.origin.end) {
|
|
2286
|
+
source.links.forEach((link) => {
|
|
2287
|
+
const target = this.linkItems.find((item) => item.id === link.link);
|
|
2288
|
+
if (target && (target.origin.start || target.origin.end)) {
|
|
2289
|
+
let defaultColor = LinkColors.default;
|
|
2290
|
+
let activeColor = LinkColors.active;
|
|
2291
|
+
if (link.type === GanttLinkType.fs && source.end.getTime() > target.start.getTime()) {
|
|
2292
|
+
defaultColor = LinkColors.blocked;
|
|
2293
|
+
activeColor = LinkColors.blocked;
|
|
2294
|
+
}
|
|
2295
|
+
if (link.color) {
|
|
2296
|
+
if (typeof link.color === 'string') {
|
|
2297
|
+
defaultColor = link.color;
|
|
2298
|
+
activeColor = link.color;
|
|
2299
|
+
}
|
|
2300
|
+
else {
|
|
2301
|
+
defaultColor = link.color.default;
|
|
2302
|
+
activeColor = link.color.active;
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
this.links.push({
|
|
2306
|
+
path: this.linkLine.generatePath(source, target, link.type),
|
|
2307
|
+
source: source.origin,
|
|
2308
|
+
target: target.origin,
|
|
2309
|
+
type: link.type,
|
|
2310
|
+
color: defaultColor,
|
|
2311
|
+
defaultColor,
|
|
2312
|
+
activeColor
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
trackBy(index) {
|
|
2320
|
+
return index;
|
|
2321
|
+
}
|
|
2322
|
+
onLineClick(event, link) {
|
|
2323
|
+
this.lineClick.emit({
|
|
2324
|
+
event,
|
|
2325
|
+
source: link.source,
|
|
2326
|
+
target: link.target
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
mouseEnterPath(link, index) {
|
|
2330
|
+
link.color = link.activeColor || link.defaultColor;
|
|
2331
|
+
if (index < this.links.length - 1) {
|
|
2332
|
+
this.links.splice(index, 1);
|
|
2333
|
+
this.links.push(link);
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
mouseLeavePath(link) {
|
|
2337
|
+
link.color = link.defaultColor;
|
|
2338
|
+
}
|
|
2339
|
+
ngOnDestroy() {
|
|
2340
|
+
this.unsubscribe$.next();
|
|
2341
|
+
this.unsubscribe$.complete();
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
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 });
|
|
2345
|
+
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"] }] });
|
|
2346
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttLinksComponent, decorators: [{
|
|
2347
|
+
type: Component,
|
|
2348
|
+
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" }]
|
|
2349
|
+
}], ctorParameters: function () {
|
|
2350
|
+
return [{ type: GanttUpper, decorators: [{
|
|
2351
|
+
type: Inject,
|
|
2352
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2353
|
+
}] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: GanttDragContainer }];
|
|
2354
|
+
}, propDecorators: { groups: [{
|
|
2355
|
+
type: Input
|
|
2356
|
+
}], items: [{
|
|
2357
|
+
type: Input
|
|
2358
|
+
}], lineClick: [{
|
|
2359
|
+
type: Output
|
|
2360
|
+
}], ganttLinksOverlay: [{
|
|
2361
|
+
type: HostBinding,
|
|
2362
|
+
args: ['class.gantt-links-overlay']
|
|
2363
|
+
}] } });
|
|
2364
|
+
|
|
2365
|
+
class GanttItemUpper {
|
|
2366
|
+
constructor(elementRef, ganttUpper) {
|
|
2367
|
+
this.elementRef = elementRef;
|
|
2368
|
+
this.ganttUpper = ganttUpper;
|
|
2369
|
+
this.firstChange = true;
|
|
2370
|
+
this.unsubscribe$ = new Subject();
|
|
2371
|
+
}
|
|
2372
|
+
ngOnInit() {
|
|
2373
|
+
this.firstChange = false;
|
|
2374
|
+
this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2375
|
+
this.setPositions();
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
ngOnChanges() {
|
|
2379
|
+
if (!this.firstChange) {
|
|
2380
|
+
this.setPositions();
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
setPositions() {
|
|
2384
|
+
const itemElement = this.elementRef.nativeElement;
|
|
2385
|
+
itemElement.style.left = this.item.refs.x + 'px';
|
|
2386
|
+
itemElement.style.top = this.item.refs.y + 'px';
|
|
2387
|
+
itemElement.style.width = this.item.refs.width + 'px';
|
|
2388
|
+
if (this.item.type === GanttItemType.bar) {
|
|
2389
|
+
itemElement.style.height = this.ganttUpper.styles.barHeight + 'px';
|
|
2390
|
+
}
|
|
2391
|
+
else if (this.item.type === GanttItemType.range) {
|
|
2392
|
+
itemElement.style.height = rangeHeight + 'px';
|
|
2393
|
+
}
|
|
2394
|
+
else {
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
ngOnDestroy() {
|
|
2398
|
+
this.unsubscribe$.next();
|
|
2399
|
+
this.unsubscribe$.complete();
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
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 });
|
|
2403
|
+
GanttItemUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.8", type: GanttItemUpper, inputs: { template: "template", item: "item" }, usesOnChanges: true, ngImport: i0 });
|
|
2404
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttItemUpper, decorators: [{
|
|
2405
|
+
type: Directive
|
|
2406
|
+
}], ctorParameters: function () {
|
|
2407
|
+
return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
|
|
2408
|
+
type: Inject,
|
|
2409
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2410
|
+
}] }];
|
|
2411
|
+
}, propDecorators: { template: [{
|
|
2412
|
+
type: Input
|
|
2413
|
+
}], item: [{
|
|
2414
|
+
type: Input
|
|
2415
|
+
}] } });
|
|
2416
|
+
|
|
2417
|
+
class NgxGanttRangeComponent extends GanttItemUpper {
|
|
2418
|
+
constructor(elementRef, ganttUpper) {
|
|
2419
|
+
super(elementRef, ganttUpper);
|
|
2420
|
+
this.ganttRangeClass = true;
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
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 });
|
|
2424
|
+
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"] }] });
|
|
2425
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttRangeComponent, decorators: [{
|
|
2426
|
+
type: Component,
|
|
2427
|
+
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" }]
|
|
2428
|
+
}], ctorParameters: function () {
|
|
2429
|
+
return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
|
|
2430
|
+
type: Inject,
|
|
2431
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2432
|
+
}] }];
|
|
2433
|
+
}, propDecorators: { ganttRangeClass: [{
|
|
2434
|
+
type: HostBinding,
|
|
2435
|
+
args: ['class.gantt-range']
|
|
2436
|
+
}] } });
|
|
2437
|
+
|
|
2438
|
+
const dragMinWidth = 10;
|
|
2439
|
+
const activeClass = 'gantt-bar-active';
|
|
2440
|
+
const dropActiveClass = 'gantt-bar-drop-active';
|
|
2441
|
+
const singleDropActiveClass = 'gantt-bar-single-drop-active';
|
|
2442
|
+
function createSvgElement(qualifiedName, className) {
|
|
2443
|
+
const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
|
|
2444
|
+
element.classList.add(className);
|
|
2445
|
+
return element;
|
|
2446
|
+
}
|
|
2447
|
+
class GanttBarDrag {
|
|
2448
|
+
constructor(dragDrop, dom, dragContainer, root) {
|
|
2449
|
+
this.dragDrop = dragDrop;
|
|
2450
|
+
this.dom = dom;
|
|
2451
|
+
this.dragContainer = dragContainer;
|
|
2452
|
+
this.root = root;
|
|
2453
|
+
this.dragRefs = [];
|
|
2454
|
+
this.destroy$ = new Subject();
|
|
2455
|
+
}
|
|
2456
|
+
get dragDisabled() {
|
|
2457
|
+
return !this.item.draggable || !this.ganttUpper.draggable;
|
|
2458
|
+
}
|
|
2459
|
+
get linkDragDisabled() {
|
|
2460
|
+
return !this.item.linkable || !this.ganttUpper.linkable;
|
|
2461
|
+
}
|
|
2462
|
+
createMouseEvents() {
|
|
2463
|
+
var _a, _b, _c;
|
|
2464
|
+
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 &&
|
|
2465
|
+
((_c = this.ganttUpper.config.linkOptions) === null || _c === void 0 ? void 0 : _c.dependencyTypes[0]) === GanttLinkType.fs
|
|
2466
|
+
? singleDropActiveClass
|
|
2467
|
+
: dropActiveClass;
|
|
2468
|
+
fromEvent(this.barElement, 'mouseenter', passiveListenerOptions)
|
|
2469
|
+
.pipe(takeUntil(this.destroy$))
|
|
2470
|
+
.subscribe(() => {
|
|
2471
|
+
if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
|
|
2472
|
+
if (this.item.linkable) {
|
|
2473
|
+
this.barElement.classList.add(dropClass);
|
|
2474
|
+
this.dragContainer.emitLinkDragEntered({
|
|
2475
|
+
item: this.item,
|
|
2476
|
+
element: this.barElement
|
|
2477
|
+
});
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
else {
|
|
2481
|
+
this.barElement.classList.add(activeClass);
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
fromEvent(this.barElement, 'mouseleave', passiveListenerOptions)
|
|
2485
|
+
.pipe(takeUntil(this.destroy$))
|
|
2486
|
+
.subscribe(() => {
|
|
2487
|
+
if (!this.dragContainer.linkDraggingId) {
|
|
2488
|
+
this.barElement.classList.remove(activeClass);
|
|
2489
|
+
}
|
|
2490
|
+
else {
|
|
2491
|
+
this.dragContainer.emitLinkDragLeaved();
|
|
2492
|
+
}
|
|
2493
|
+
this.barElement.classList.remove(dropClass);
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
createBarDrag() {
|
|
2497
|
+
const dragRef = this.dragDrop.createDrag(this.barElement);
|
|
2498
|
+
dragRef.lockAxis = 'x';
|
|
2499
|
+
dragRef.started.subscribe(() => {
|
|
2500
|
+
this.setDraggingStyles();
|
|
2501
|
+
this.dragContainer.dragStarted.emit({ item: this.item.origin });
|
|
2502
|
+
});
|
|
2503
|
+
dragRef.moved.subscribe((event) => {
|
|
2504
|
+
const currentX = this.item.refs.x + event.distance.x;
|
|
2505
|
+
const currentDate = this.ganttUpper.view.getDateByXPoint(currentX);
|
|
2506
|
+
const currentStartX = this.ganttUpper.view.getXPointByDate(currentDate);
|
|
2507
|
+
const dayWidth = this.ganttUpper.view.getDayOccupancyWidth(currentDate);
|
|
2508
|
+
const diffDays = differenceInCalendarDays(this.item.end.value, this.item.start.value);
|
|
2509
|
+
let start = currentDate;
|
|
2510
|
+
let end = currentDate.addDays(diffDays);
|
|
2511
|
+
if (currentX > currentStartX + dayWidth / 2) {
|
|
2512
|
+
start = start.addDays(1);
|
|
2513
|
+
end = end.addDays(1);
|
|
2514
|
+
}
|
|
2515
|
+
this.openDragBackdrop(this.barElement, start, end);
|
|
2516
|
+
this.item.updateDate(start, end);
|
|
2517
|
+
this.dragContainer.dragMoved.emit({ item: this.item.origin });
|
|
2518
|
+
});
|
|
2519
|
+
dragRef.ended.subscribe((event) => {
|
|
2520
|
+
this.clearDraggingStyles();
|
|
2521
|
+
this.closeDragBackdrop();
|
|
2522
|
+
event.source.reset();
|
|
2523
|
+
this.dragContainer.dragEnded.emit({ item: this.item.origin });
|
|
2524
|
+
});
|
|
2525
|
+
this.barDragRef = dragRef;
|
|
2526
|
+
return dragRef;
|
|
2527
|
+
}
|
|
2528
|
+
createBarHandleDrags() {
|
|
2529
|
+
const dragRefs = [];
|
|
2530
|
+
const handles = this.barElement.querySelectorAll('.drag-handles .handle');
|
|
2531
|
+
handles.forEach((handle, index) => {
|
|
2532
|
+
const isBefore = index === 0;
|
|
2533
|
+
const dragRef = this.dragDrop.createDrag(handle);
|
|
2534
|
+
dragRef.lockAxis = 'x';
|
|
2535
|
+
dragRef.withBoundaryElement(this.dom.root);
|
|
2536
|
+
dragRef.started.subscribe(() => {
|
|
2537
|
+
this.setDraggingStyles();
|
|
2538
|
+
this.dragContainer.dragStarted.emit({ item: this.item.origin });
|
|
2539
|
+
});
|
|
2540
|
+
dragRef.moved.subscribe((event) => {
|
|
2541
|
+
if (isBefore) {
|
|
2542
|
+
const x = this.item.refs.x + event.distance.x;
|
|
2543
|
+
const width = this.item.refs.width + event.distance.x * -1;
|
|
2544
|
+
if (width > dragMinWidth) {
|
|
2545
|
+
this.barElement.style.width = width + 'px';
|
|
2546
|
+
this.barElement.style.left = x + 'px';
|
|
2547
|
+
this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), this.item.end);
|
|
2548
|
+
this.item.updateDate(this.ganttUpper.view.getDateByXPoint(x), this.item.end);
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
else {
|
|
2552
|
+
const width = this.item.refs.width + event.distance.x;
|
|
2553
|
+
if (width > dragMinWidth) {
|
|
2554
|
+
this.barElement.style.width = width + 'px';
|
|
2555
|
+
this.openDragBackdrop(this.barElement, this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
|
|
2556
|
+
}
|
|
2557
|
+
this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
|
|
2558
|
+
}
|
|
2559
|
+
this.dragContainer.dragMoved.emit({ item: this.item.origin });
|
|
2560
|
+
event.source.reset();
|
|
2561
|
+
});
|
|
2562
|
+
dragRef.ended.subscribe((event) => {
|
|
2563
|
+
if (isBefore) {
|
|
2564
|
+
const width = this.item.refs.width + event.distance.x * -1;
|
|
2565
|
+
if (width > dragMinWidth) {
|
|
2566
|
+
this.item.updateDate(this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x), this.item.end);
|
|
2567
|
+
}
|
|
2568
|
+
else {
|
|
2569
|
+
this.item.updateDate(this.item.end.startOfDay(), this.item.end);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
else {
|
|
2573
|
+
const width = this.item.refs.width + event.distance.x;
|
|
2574
|
+
if (width > dragMinWidth) {
|
|
2575
|
+
this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + this.item.refs.width + event.distance.x));
|
|
2576
|
+
}
|
|
2577
|
+
else {
|
|
2578
|
+
this.item.updateDate(this.item.start, this.item.start.endOfDay());
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
this.clearDraggingStyles();
|
|
2582
|
+
this.closeDragBackdrop();
|
|
2583
|
+
this.dragContainer.dragEnded.emit({ item: this.item.origin });
|
|
2584
|
+
});
|
|
2585
|
+
dragRefs.push(dragRef);
|
|
2586
|
+
});
|
|
2587
|
+
return dragRefs;
|
|
2588
|
+
}
|
|
2589
|
+
createLinkHandleDrags() {
|
|
2590
|
+
const dragRefs = [];
|
|
2591
|
+
const handles = this.barElement.querySelectorAll('.link-handles .handle');
|
|
2592
|
+
handles.forEach((handle, index) => {
|
|
2593
|
+
const isBegin = index === 0;
|
|
2594
|
+
const dragRef = this.dragDrop.createDrag(handle);
|
|
2595
|
+
dragRef.withBoundaryElement(this.dom.root);
|
|
2596
|
+
dragRef.beforeStarted.subscribe(() => {
|
|
2597
|
+
handle.style.pointerEvents = 'none';
|
|
2598
|
+
if (this.barDragRef) {
|
|
2599
|
+
this.barDragRef.disabled = true;
|
|
2600
|
+
}
|
|
2601
|
+
this.createLinkDraggingLine();
|
|
2602
|
+
this.dragContainer.emitLinkDragStarted({
|
|
2603
|
+
element: this.barElement,
|
|
2604
|
+
item: this.item,
|
|
2605
|
+
pos: isBegin ? InBarPosition.start : InBarPosition.finish
|
|
2606
|
+
});
|
|
2607
|
+
});
|
|
2608
|
+
dragRef.moved.subscribe(() => {
|
|
2609
|
+
const positions = this.calcLinkLinePositions(handle, isBegin);
|
|
2610
|
+
this.linkDraggingLine.setAttribute('x1', positions.x1.toString());
|
|
2611
|
+
this.linkDraggingLine.setAttribute('y1', positions.y1.toString());
|
|
2612
|
+
this.linkDraggingLine.setAttribute('x2', positions.x2.toString());
|
|
2613
|
+
this.linkDraggingLine.setAttribute('y2', positions.y2.toString());
|
|
2614
|
+
});
|
|
2615
|
+
dragRef.ended.subscribe((event) => {
|
|
2616
|
+
handle.style.pointerEvents = '';
|
|
2617
|
+
if (this.barDragRef) {
|
|
2618
|
+
this.barDragRef.disabled = false;
|
|
2619
|
+
}
|
|
2620
|
+
// 计算line拖动的落点位于目标Bar的值,如果值大于Bar宽度的一半,说明是拖动到Begin位置,否则则为拖动到End位置
|
|
2621
|
+
if (this.dragContainer.linkDragPath.to) {
|
|
2622
|
+
const placePointX = event.source.getRootElement().getBoundingClientRect().x -
|
|
2623
|
+
this.dragContainer.linkDragPath.to.element.getBoundingClientRect().x;
|
|
2624
|
+
this.dragContainer.emitLinkDragEnded(Object.assign(Object.assign({}, this.dragContainer.linkDragPath.to), { pos: placePointX < this.dragContainer.linkDragPath.to.item.refs.width / 2
|
|
2625
|
+
? InBarPosition.start
|
|
2626
|
+
: InBarPosition.finish }));
|
|
2627
|
+
}
|
|
2628
|
+
else {
|
|
2629
|
+
this.dragContainer.emitLinkDragEnded();
|
|
2630
|
+
}
|
|
2631
|
+
event.source.reset();
|
|
2632
|
+
this.barElement.classList.remove(activeClass);
|
|
2633
|
+
this.destroyLinkDraggingLine();
|
|
2634
|
+
});
|
|
2635
|
+
dragRefs.push(dragRef);
|
|
2636
|
+
});
|
|
2637
|
+
return dragRefs;
|
|
2638
|
+
}
|
|
2639
|
+
openDragBackdrop(dragElement, start, end) {
|
|
2640
|
+
const dragBackdropElement = this.root.backdrop.nativeElement;
|
|
2641
|
+
const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask');
|
|
2642
|
+
const rootRect = this.dom.root.getBoundingClientRect();
|
|
2643
|
+
const dragRect = dragElement.getBoundingClientRect();
|
|
2644
|
+
const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
|
|
2645
|
+
const width = dragRect.right - dragRect.left;
|
|
2646
|
+
// Note: updating styles will cause re-layout so we have to place them consistently one by one.
|
|
2647
|
+
dragMaskElement.style.left = left + 'px';
|
|
2648
|
+
dragMaskElement.style.width = width + 'px';
|
|
2649
|
+
dragMaskElement.style.display = 'block';
|
|
2650
|
+
dragBackdropElement.style.display = 'block';
|
|
2651
|
+
// This will invalidate the layout, but we won't need re-layout, because we set styles previously.
|
|
2652
|
+
dragMaskElement.querySelector('.start').innerHTML = start.format('MM-dd');
|
|
2653
|
+
dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
|
|
2654
|
+
}
|
|
2655
|
+
closeDragBackdrop() {
|
|
2656
|
+
const dragBackdropElement = this.root.backdrop.nativeElement;
|
|
2657
|
+
const dragMaskElement = dragBackdropElement.querySelector('.gantt-drag-mask');
|
|
2658
|
+
dragMaskElement.style.display = 'none';
|
|
2659
|
+
dragBackdropElement.style.display = 'none';
|
|
2660
|
+
}
|
|
2661
|
+
setDraggingStyles() {
|
|
2662
|
+
this.barElement.style.pointerEvents = 'none';
|
|
2663
|
+
this.barElement.classList.add('gantt-bar-draggable-drag');
|
|
2664
|
+
}
|
|
2665
|
+
clearDraggingStyles() {
|
|
2666
|
+
this.barElement.style.pointerEvents = '';
|
|
2667
|
+
this.barElement.classList.remove('gantt-bar-draggable-drag');
|
|
2668
|
+
}
|
|
2669
|
+
calcLinkLinePositions(target, isBefore) {
|
|
2670
|
+
const rootRect = this.dom.root.getBoundingClientRect();
|
|
2671
|
+
const targetRect = target.getBoundingClientRect();
|
|
2672
|
+
const layerRect = target.parentElement.parentElement.getBoundingClientRect();
|
|
2673
|
+
return {
|
|
2674
|
+
x1: layerRect.left + (isBefore ? 0 : layerRect.width) - rootRect.left,
|
|
2675
|
+
y1: layerRect.top + layerRect.height / 2 - rootRect.top,
|
|
2676
|
+
x2: targetRect.left - rootRect.left + targetRect.width / 2,
|
|
2677
|
+
y2: targetRect.top - rootRect.top + targetRect.height / 2
|
|
2678
|
+
};
|
|
2679
|
+
}
|
|
2680
|
+
createLinkDraggingLine() {
|
|
2681
|
+
if (!this.linkDraggingLine) {
|
|
2682
|
+
const svgElement = createSvgElement('svg', 'gantt-link-drag-container');
|
|
2683
|
+
const linElement = createSvgElement('line', 'link-dragging-line');
|
|
2684
|
+
linElement.style.pointerEvents = 'none';
|
|
2685
|
+
svgElement.appendChild(linElement);
|
|
2686
|
+
this.dom.root.appendChild(svgElement);
|
|
2687
|
+
this.linkDraggingLine = linElement;
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
destroyLinkDraggingLine() {
|
|
2691
|
+
if (this.linkDraggingLine) {
|
|
2692
|
+
this.linkDraggingLine.parentElement.remove();
|
|
2693
|
+
this.linkDraggingLine = null;
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
createDrags(elementRef, item, ganttUpper) {
|
|
2697
|
+
this.item = item;
|
|
2698
|
+
this.barElement = elementRef.nativeElement;
|
|
2699
|
+
this.ganttUpper = ganttUpper;
|
|
2700
|
+
// if (!item.draggable || (this.dragDisabled && this.linkDragDisabled)) {
|
|
2701
|
+
if (this.dragDisabled && this.linkDragDisabled) {
|
|
2702
|
+
return;
|
|
2703
|
+
}
|
|
2704
|
+
else {
|
|
2705
|
+
this.createMouseEvents();
|
|
2706
|
+
if (!this.dragDisabled) {
|
|
2707
|
+
const dragRef = this.createBarDrag();
|
|
2708
|
+
const dragHandlesRefs = this.createBarHandleDrags();
|
|
2709
|
+
this.dragRefs.push(dragRef, ...dragHandlesRefs);
|
|
2710
|
+
}
|
|
2711
|
+
if (!this.linkDragDisabled) {
|
|
2712
|
+
const linkDragRefs = this.createLinkHandleDrags();
|
|
2713
|
+
this.dragRefs.push(...linkDragRefs);
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
ngOnDestroy() {
|
|
2718
|
+
this.closeDragBackdrop();
|
|
2719
|
+
this.dragRefs.forEach((dragRef) => dragRef.dispose());
|
|
2720
|
+
this.destroy$.next();
|
|
2721
|
+
this.destroy$.complete();
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
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 });
|
|
2725
|
+
GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttBarDrag });
|
|
2726
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttBarDrag, decorators: [{
|
|
2727
|
+
type: Injectable
|
|
2728
|
+
}], ctorParameters: function () {
|
|
2729
|
+
return [{ type: i1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: NgxGanttRootComponent, decorators: [{
|
|
2730
|
+
type: SkipSelf
|
|
2731
|
+
}] }];
|
|
2732
|
+
} });
|
|
2733
|
+
|
|
2734
|
+
function linearGradient(sideOrCorner, color, stop) {
|
|
2735
|
+
return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
|
|
2736
|
+
}
|
|
2737
|
+
class NgxGanttBarComponent extends GanttItemUpper {
|
|
2738
|
+
constructor(dragContainer, drag, elementRef, ganttUpper, ngZone) {
|
|
2739
|
+
super(elementRef, ganttUpper);
|
|
2740
|
+
this.dragContainer = dragContainer;
|
|
2741
|
+
this.drag = drag;
|
|
2742
|
+
this.ganttUpper = ganttUpper;
|
|
2743
|
+
this.ngZone = ngZone;
|
|
2744
|
+
this.barClick = new EventEmitter();
|
|
2745
|
+
this.ganttItemClass = true;
|
|
2746
|
+
this.color = 'red';
|
|
2747
|
+
}
|
|
2748
|
+
ngOnInit() {
|
|
2749
|
+
super.ngOnInit();
|
|
2750
|
+
this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2751
|
+
this.setContentBackground();
|
|
2752
|
+
});
|
|
2753
|
+
}
|
|
2754
|
+
ngAfterViewInit() {
|
|
2755
|
+
this.drag.createDrags(this.elementRef, this.item, this.ganttUpper);
|
|
2756
|
+
this.setContentBackground();
|
|
2757
|
+
this.handles.changes
|
|
2758
|
+
.pipe(startWith(this.handles), switchMap(() =>
|
|
2759
|
+
// Note: we need to explicitly subscribe outside of the Angular zone since `addEventListener`
|
|
2760
|
+
// is called when the `fromEvent` is subscribed.
|
|
2761
|
+
new Observable((subscriber) => this.ngZone.runOutsideAngular(() => merge(...this.handles.toArray().map((handle) => fromEvent(handle.nativeElement, 'mousedown'))).subscribe(subscriber)))), takeUntil(this.unsubscribe$))
|
|
2762
|
+
.subscribe((event) => {
|
|
2763
|
+
event.stopPropagation();
|
|
2764
|
+
});
|
|
2765
|
+
}
|
|
2766
|
+
onBarClick(event) {
|
|
2767
|
+
this.barClick.emit({ event, item: this.item.origin });
|
|
2768
|
+
}
|
|
2769
|
+
setContentBackground() {
|
|
2770
|
+
const contentElement = this.contentElementRef.nativeElement;
|
|
2771
|
+
const color = this.item.color || barBackground;
|
|
2772
|
+
const style = this.item.barStyle || {};
|
|
2773
|
+
if (this.item.origin.start && this.item.origin.end) {
|
|
2774
|
+
style.background = color;
|
|
2775
|
+
style.borderRadius = '';
|
|
2776
|
+
}
|
|
2777
|
+
if (this.item.origin.start && !this.item.origin.end) {
|
|
2778
|
+
style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
|
|
2779
|
+
style.borderRadius = '4px 12.5px 12.5px 4px';
|
|
2780
|
+
}
|
|
2781
|
+
if (!this.item.origin.start && this.item.origin.end) {
|
|
2782
|
+
style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
|
|
2783
|
+
style.borderRadius = '12.5px 4px 4px 12.5px';
|
|
2784
|
+
}
|
|
2785
|
+
if (this.item.progress >= 0) {
|
|
2786
|
+
const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
|
|
2787
|
+
style.background = hexToRgb(color, 0.3);
|
|
2788
|
+
style.borderRadius = '';
|
|
2789
|
+
contentProgressElement.style.background = color;
|
|
2790
|
+
}
|
|
2791
|
+
for (const key in style) {
|
|
2792
|
+
if (style.hasOwnProperty(key)) {
|
|
2793
|
+
contentElement.style[key] = style[key];
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
stopPropagation(event) {
|
|
2798
|
+
event.stopPropagation();
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
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 });
|
|
2802
|
+
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"] }] });
|
|
2803
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
|
|
2804
|
+
type: Component,
|
|
2805
|
+
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" }]
|
|
2806
|
+
}], ctorParameters: function () {
|
|
2807
|
+
return [{ type: GanttDragContainer }, { type: GanttBarDrag }, { type: i0.ElementRef }, { type: GanttUpper, decorators: [{
|
|
2808
|
+
type: Inject,
|
|
2809
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2810
|
+
}] }, { type: i0.NgZone }];
|
|
2811
|
+
}, propDecorators: { barClick: [{
|
|
2812
|
+
type: Output
|
|
2813
|
+
}], contentElementRef: [{
|
|
2814
|
+
type: ViewChild,
|
|
2815
|
+
args: ['content']
|
|
2816
|
+
}], ganttItemClass: [{
|
|
2817
|
+
type: HostBinding,
|
|
2818
|
+
args: ['class.gantt-bar']
|
|
2819
|
+
}], handles: [{
|
|
2820
|
+
type: ViewChildren,
|
|
2821
|
+
args: ['handle']
|
|
2822
|
+
}] } });
|
|
2823
|
+
|
|
2824
|
+
class GanttMainComponent {
|
|
2825
|
+
constructor(ganttUpper) {
|
|
2826
|
+
this.ganttUpper = ganttUpper;
|
|
2827
|
+
this.barClick = new EventEmitter();
|
|
2828
|
+
this.lineClick = new EventEmitter();
|
|
2829
|
+
this.ganttMainClass = true;
|
|
2830
|
+
}
|
|
2831
|
+
trackBy(index, item) {
|
|
2832
|
+
return item.id || index;
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
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 });
|
|
2836
|
+
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 } });
|
|
2837
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: GanttMainComponent, decorators: [{
|
|
2838
|
+
type: Component,
|
|
2839
|
+
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" }]
|
|
2840
|
+
}], ctorParameters: function () {
|
|
2841
|
+
return [{ type: GanttUpper, decorators: [{
|
|
2842
|
+
type: Inject,
|
|
2843
|
+
args: [GANTT_UPPER_TOKEN]
|
|
2844
|
+
}] }];
|
|
2845
|
+
}, propDecorators: { groups: [{
|
|
2846
|
+
type: Input
|
|
2847
|
+
}], items: [{
|
|
2848
|
+
type: Input
|
|
2849
|
+
}], groupHeaderTemplate: [{
|
|
2850
|
+
type: Input
|
|
2851
|
+
}], itemTemplate: [{
|
|
2852
|
+
type: Input
|
|
2853
|
+
}], barTemplate: [{
|
|
2854
|
+
type: Input
|
|
2855
|
+
}], rangeTemplate: [{
|
|
2856
|
+
type: Input
|
|
2857
|
+
}], barClick: [{
|
|
2858
|
+
type: Output
|
|
2859
|
+
}], lineClick: [{
|
|
2860
|
+
type: Output
|
|
2861
|
+
}], ganttMainClass: [{
|
|
2862
|
+
type: HostBinding,
|
|
2863
|
+
args: ['class.gantt-main-container']
|
|
2864
|
+
}] } });
|
|
2865
|
+
|
|
2866
|
+
class NgxGanttComponent extends GanttUpper {
|
|
2867
|
+
constructor(elementRef, cdr, ngZone, config) {
|
|
2868
|
+
super(elementRef, cdr, ngZone, config);
|
|
2869
|
+
this.maxLevel = 2;
|
|
2870
|
+
this.linkDragStarted = new EventEmitter();
|
|
2871
|
+
this.linkDragEnded = new EventEmitter();
|
|
2872
|
+
this.lineClick = new EventEmitter();
|
|
2873
|
+
this.selectedChange = new EventEmitter();
|
|
2874
|
+
this.ngUnsubscribe$ = new Subject();
|
|
2875
|
+
this.sideTableWidth = sideWidth;
|
|
2876
|
+
}
|
|
2877
|
+
ngOnInit() {
|
|
2878
|
+
super.ngOnInit();
|
|
2879
|
+
// Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
|
|
2880
|
+
// the `onStable` will never emit any value.
|
|
2881
|
+
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
|
|
2882
|
+
// Normally this isn't in the zone, but it can cause performance regressions for apps
|
|
2883
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
2884
|
+
this.ngZone.runOutsideAngular(() => {
|
|
2885
|
+
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2886
|
+
this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
|
|
2887
|
+
this.linkDragStarted.emit(event);
|
|
2888
|
+
});
|
|
2889
|
+
this.dragContainer.linkDragEnded.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
|
|
2890
|
+
this.linkDragEnded.emit(event);
|
|
2891
|
+
});
|
|
2892
|
+
});
|
|
2893
|
+
});
|
|
2894
|
+
}
|
|
2895
|
+
ngAfterViewInit() {
|
|
2896
|
+
this.columns.changes.pipe(startWith(true), takeUntil(this.ngUnsubscribe$)).subscribe(() => {
|
|
2897
|
+
this.columns.forEach((column) => {
|
|
2898
|
+
if (!column.columnWidth) {
|
|
2899
|
+
column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
|
|
2900
|
+
}
|
|
2901
|
+
});
|
|
2902
|
+
this.cdr.detectChanges();
|
|
2903
|
+
});
|
|
2904
|
+
}
|
|
2905
|
+
expandChildren(item) {
|
|
2906
|
+
if (!item.expanded) {
|
|
2907
|
+
item.setExpand(true);
|
|
2908
|
+
if (this.async && this.childrenResolve && item.children.length === 0) {
|
|
2909
|
+
item.loading = true;
|
|
2910
|
+
this.childrenResolve(item.origin)
|
|
2911
|
+
.pipe(take(1), finalize(() => {
|
|
2912
|
+
item.loading = false;
|
|
2913
|
+
this.expandChange.emit();
|
|
2914
|
+
this.cdr.detectChanges();
|
|
2915
|
+
}))
|
|
2916
|
+
.subscribe((items) => {
|
|
2917
|
+
item.addChildren(items);
|
|
2918
|
+
this.computeItemsRefs(...item.children);
|
|
2919
|
+
});
|
|
2920
|
+
}
|
|
2921
|
+
else {
|
|
2922
|
+
this.computeItemsRefs(...item.children);
|
|
2923
|
+
this.expandChange.emit();
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
else {
|
|
2927
|
+
item.setExpand(false);
|
|
2928
|
+
this.expandChange.emit();
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
selectItem(selectEvent) {
|
|
2932
|
+
var _a;
|
|
2933
|
+
if (!this.selectable) {
|
|
2934
|
+
return;
|
|
2935
|
+
}
|
|
2936
|
+
const { event, selectedValue } = selectEvent;
|
|
2937
|
+
this.selectionModel.toggle(selectedValue.id);
|
|
2938
|
+
const selectedIds = this.selectionModel.selected;
|
|
2939
|
+
if (this.multiple) {
|
|
2940
|
+
const _selectedValue = this.getGanttItems(selectedIds).map((item) => item.origin);
|
|
2941
|
+
this.selectedChange.emit({ event, selectedValue: _selectedValue });
|
|
2942
|
+
}
|
|
2943
|
+
else {
|
|
2944
|
+
const _selectedValue = (_a = this.getGanttItem(selectedIds[0])) === null || _a === void 0 ? void 0 : _a.origin;
|
|
2945
|
+
this.selectedChange.emit({ event, selectedValue: _selectedValue });
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
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 });
|
|
2950
|
+
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: [
|
|
2951
|
+
{
|
|
2952
|
+
provide: GANTT_UPPER_TOKEN,
|
|
2953
|
+
useExisting: NgxGanttComponent
|
|
2954
|
+
},
|
|
2955
|
+
{
|
|
2956
|
+
provide: GANTT_ABSTRACT_TOKEN,
|
|
2957
|
+
useExisting: forwardRef(() => NgxGanttComponent)
|
|
2958
|
+
}
|
|
2959
|
+
], 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 });
|
|
2960
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttComponent, decorators: [{
|
|
2961
|
+
type: Component,
|
|
2962
|
+
args: [{ selector: 'ngx-gantt', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
2963
|
+
{
|
|
2964
|
+
provide: GANTT_UPPER_TOKEN,
|
|
2965
|
+
useExisting: NgxGanttComponent
|
|
2966
|
+
},
|
|
2967
|
+
{
|
|
2968
|
+
provide: GANTT_ABSTRACT_TOKEN,
|
|
2969
|
+
useExisting: forwardRef(() => NgxGanttComponent)
|
|
2970
|
+
}
|
|
2971
|
+
], 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" }]
|
|
2972
|
+
}], ctorParameters: function () {
|
|
2973
|
+
return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
|
2974
|
+
type: Inject,
|
|
2975
|
+
args: [GANTT_GLOBAL_CONFIG]
|
|
2976
|
+
}] }];
|
|
2977
|
+
}, propDecorators: { maxLevel: [{
|
|
2978
|
+
type: Input
|
|
2979
|
+
}], async: [{
|
|
2980
|
+
type: Input
|
|
2981
|
+
}], childrenResolve: [{
|
|
2982
|
+
type: Input
|
|
2983
|
+
}], linkable: [{
|
|
2984
|
+
type: Input
|
|
2985
|
+
}], linkDragStarted: [{
|
|
2986
|
+
type: Output
|
|
2987
|
+
}], linkDragEnded: [{
|
|
2988
|
+
type: Output
|
|
2989
|
+
}], lineClick: [{
|
|
2990
|
+
type: Output
|
|
2991
|
+
}], selectedChange: [{
|
|
2992
|
+
type: Output
|
|
2993
|
+
}], table: [{
|
|
2994
|
+
type: ContentChild,
|
|
2995
|
+
args: [NgxGanttTableComponent]
|
|
2996
|
+
}], columns: [{
|
|
2997
|
+
type: ContentChildren,
|
|
2998
|
+
args: [NgxGanttTableColumnComponent, { descendants: true }]
|
|
2999
|
+
}], tableEmptyTemplate: [{
|
|
3000
|
+
type: ContentChild,
|
|
3001
|
+
args: ['tableEmpty', { static: true }]
|
|
3002
|
+
}] } });
|
|
3003
|
+
|
|
3004
|
+
class NgxGanttModule {
|
|
3005
|
+
}
|
|
3006
|
+
NgxGanttModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
3007
|
+
NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttModule, declarations: [NgxGanttComponent,
|
|
3008
|
+
NgxGanttTableComponent,
|
|
3009
|
+
NgxGanttTableColumnComponent,
|
|
3010
|
+
GanttTableComponent,
|
|
3011
|
+
GanttMainComponent,
|
|
3012
|
+
GanttCalendarComponent,
|
|
3013
|
+
GanttLinksComponent,
|
|
3014
|
+
NgxGanttBarComponent,
|
|
3015
|
+
GanttIconComponent,
|
|
3016
|
+
GanttDragBackdropComponent,
|
|
3017
|
+
NgxGanttRangeComponent,
|
|
3018
|
+
NgxGanttRootComponent,
|
|
3019
|
+
IsGanttRangeItemPipe,
|
|
3020
|
+
IsGanttBarItemPipe,
|
|
3021
|
+
IsGanttCustomItemPipe], imports: [CommonModule, DragDropModule], exports: [NgxGanttComponent,
|
|
3022
|
+
NgxGanttTableComponent,
|
|
3023
|
+
NgxGanttTableColumnComponent,
|
|
3024
|
+
NgxGanttRootComponent,
|
|
3025
|
+
NgxGanttBarComponent,
|
|
3026
|
+
NgxGanttRangeComponent] });
|
|
3027
|
+
NgxGanttModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttModule, providers: [
|
|
3028
|
+
{
|
|
3029
|
+
provide: GANTT_GLOBAL_CONFIG,
|
|
3030
|
+
useValue: defaultConfig
|
|
3031
|
+
}
|
|
3032
|
+
], imports: [[CommonModule, DragDropModule]] });
|
|
3033
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.8", ngImport: i0, type: NgxGanttModule, decorators: [{
|
|
3034
|
+
type: NgModule,
|
|
3035
|
+
args: [{
|
|
3036
|
+
imports: [CommonModule, DragDropModule],
|
|
3037
|
+
exports: [
|
|
3038
|
+
NgxGanttComponent,
|
|
3039
|
+
NgxGanttTableComponent,
|
|
3040
|
+
NgxGanttTableColumnComponent,
|
|
3041
|
+
NgxGanttRootComponent,
|
|
3042
|
+
NgxGanttBarComponent,
|
|
3043
|
+
NgxGanttRangeComponent
|
|
3044
|
+
],
|
|
3045
|
+
declarations: [
|
|
3046
|
+
NgxGanttComponent,
|
|
3047
|
+
NgxGanttTableComponent,
|
|
3048
|
+
NgxGanttTableColumnComponent,
|
|
3049
|
+
GanttTableComponent,
|
|
3050
|
+
GanttMainComponent,
|
|
3051
|
+
GanttCalendarComponent,
|
|
3052
|
+
GanttLinksComponent,
|
|
3053
|
+
NgxGanttBarComponent,
|
|
3054
|
+
GanttIconComponent,
|
|
3055
|
+
GanttDragBackdropComponent,
|
|
3056
|
+
NgxGanttRangeComponent,
|
|
3057
|
+
NgxGanttRootComponent,
|
|
3058
|
+
IsGanttRangeItemPipe,
|
|
3059
|
+
IsGanttBarItemPipe,
|
|
3060
|
+
IsGanttCustomItemPipe
|
|
3061
|
+
],
|
|
3062
|
+
providers: [
|
|
3063
|
+
{
|
|
3064
|
+
provide: GANTT_GLOBAL_CONFIG,
|
|
3065
|
+
useValue: defaultConfig
|
|
3066
|
+
}
|
|
3067
|
+
]
|
|
3068
|
+
}]
|
|
3069
|
+
}] });
|
|
3070
|
+
|
|
3071
|
+
/*
|
|
3072
|
+
* Public API Surface of gantt
|
|
3073
|
+
*/
|
|
3074
|
+
|
|
3075
|
+
/**
|
|
3076
|
+
* Generated bundle index. Do not edit.
|
|
3077
|
+
*/
|
|
3078
|
+
|
|
3079
|
+
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 };
|
|
3080
|
+
//# sourceMappingURL=worktile-gantt.mjs.map
|