@worktile/gantt 11.0.2 → 12.0.1
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/.all-contributorsrc +53 -0
- package/.angulardoc.json +4 -0
- package/.circleci/config.yml +17 -0
- package/.coveralls.yml +1 -0
- package/.docgenirc.js +64 -0
- package/.editorconfig +22 -0
- package/.prettierrc +24 -0
- package/.travis.yml +23 -0
- package/CHANGELOG.md +564 -0
- package/Dockerfile +4 -0
- package/LICENSE +21 -0
- package/README.md +116 -13
- package/angular.json +136 -0
- package/docs/guides/basic/components.md +54 -0
- package/docs/guides/basic/event.md +70 -0
- package/docs/guides/basic/index.md +4 -0
- package/docs/guides/basic/style.md +68 -0
- package/docs/guides/basic/type.md +70 -0
- package/docs/guides/basic/usage.md +189 -0
- package/docs/guides/index.md +5 -0
- package/docs/guides/intro/getting-started.md +79 -0
- package/docs/guides/intro/index.md +51 -0
- package/docs/index.md +0 -0
- package/example/browserslist +12 -0
- package/example/src/app/app-routing.module.ts +26 -0
- package/example/src/app/app.component.html +2 -0
- package/example/src/app/app.component.ts +11 -0
- package/example/src/app/app.module.ts +57 -0
- package/example/src/app/components/components.component.html +6 -0
- package/example/src/app/components/components.component.ts +33 -0
- package/example/src/app/configuration/parameters/api/zh-cn.js +350 -0
- package/example/src/app/configuration/parameters/doc/zh-cn.md +5 -0
- package/example/src/app/gantt/gantt.component.html +51 -0
- package/example/src/app/gantt/gantt.component.ts +119 -0
- package/example/src/app/gantt-advanced/component/flat.component.html +30 -0
- package/example/src/app/gantt-advanced/component/flat.component.ts +72 -0
- package/example/src/app/gantt-advanced/component/flat.scss +31 -0
- package/example/src/app/gantt-advanced/gantt-advanced.component.html +32 -0
- package/example/src/app/gantt-advanced/gantt-advanced.component.ts +34 -0
- package/example/src/app/gantt-advanced/mocks.ts +158 -0
- package/example/src/app/gantt-groups/gantt-groups.component.html +42 -0
- package/example/src/app/gantt-groups/gantt-groups.component.ts +62 -0
- package/example/src/app/gantt-range/gantt-range.component.html +66 -0
- package/example/src/app/gantt-range/gantt-range.component.ts +67 -0
- package/example/src/app/gantt-range/mocks.ts +150 -0
- package/example/src/app/helper.ts +38 -0
- package/example/src/assets/.gitkeep +0 -0
- package/example/src/environments/environment.prod.ts +3 -0
- package/example/src/environments/environment.ts +16 -0
- package/example/src/favicon.ico +0 -0
- package/example/src/index.html +13 -0
- package/example/src/main.ts +12 -0
- package/example/src/polyfills.ts +63 -0
- package/example/src/styles.scss +56 -0
- package/example/tsconfig.app.json +18 -0
- package/nginx.conf +17 -0
- package/package.json +113 -17
- package/packages/gantt/README.md +24 -0
- package/packages/gantt/karma.conf.js +46 -0
- package/packages/gantt/ng-package.json +7 -0
- package/packages/gantt/ng-package.prod.json +7 -0
- package/packages/gantt/package.json +16 -0
- package/packages/gantt/src/class/date-point.ts +14 -0
- package/{class/event.d.ts → packages/gantt/src/class/event.ts} +12 -6
- package/packages/gantt/src/class/group.ts +36 -0
- package/{class/index.d.ts → packages/gantt/src/class/index.ts} +0 -0
- package/packages/gantt/src/class/item.ts +129 -0
- package/packages/gantt/src/class/test/group.spec.ts +21 -0
- package/packages/gantt/src/class/test/item.spec.ts +102 -0
- package/packages/gantt/src/class/view-type.ts +7 -0
- package/packages/gantt/src/components/bar/bar-drag.ts +298 -0
- package/packages/gantt/src/components/bar/bar.component.html +17 -0
- package/packages/gantt/src/components/bar/bar.component.scss +169 -0
- package/packages/gantt/src/components/bar/bar.component.ts +109 -0
- package/packages/gantt/src/components/bar/test/bar.component.spec.ts +54 -0
- package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +196 -0
- package/packages/gantt/src/components/calendar/calendar.component.html +52 -0
- package/packages/gantt/src/components/calendar/calendar.component.scss +77 -0
- package/packages/gantt/src/components/calendar/calendar.component.ts +100 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +6 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +48 -0
- package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +13 -0
- package/packages/gantt/src/components/icon/icon.component.scss +13 -0
- package/packages/gantt/src/components/icon/icon.component.ts +28 -0
- package/packages/gantt/src/components/icon/icons.ts +86 -0
- package/packages/gantt/src/components/links/links.component.html +19 -0
- package/packages/gantt/src/components/links/links.component.scss +27 -0
- package/packages/gantt/src/components/links/links.component.ts +263 -0
- package/packages/gantt/src/components/main/gantt-main.component.html +35 -0
- package/packages/gantt/src/components/main/gantt-main.component.ts +35 -0
- package/packages/gantt/src/components/range/range.component.html +8 -0
- package/packages/gantt/src/components/range/range.component.scss +35 -0
- package/packages/gantt/src/components/range/range.component.ts +27 -0
- package/packages/gantt/src/components/range/test/range.component.spec.ts +80 -0
- package/packages/gantt/src/components/table/gantt-table.component.html +105 -0
- package/packages/gantt/src/components/table/gantt-table.component.scss +144 -0
- package/packages/gantt/src/components/table/gantt-table.component.ts +166 -0
- package/packages/gantt/src/components/table/test/table.spec.ts +129 -0
- package/packages/gantt/src/gantt-abstract.ts +14 -0
- package/packages/gantt/src/gantt-dom.service.ts +134 -0
- package/packages/gantt/src/gantt-drag-container.ts +73 -0
- package/packages/gantt/src/gantt-item-upper.ts +50 -0
- package/packages/gantt/src/gantt-print.service.ts +104 -0
- package/packages/gantt/src/gantt-upper.ts +289 -0
- package/packages/gantt/src/gantt.component.html +18 -0
- package/packages/gantt/src/gantt.component.scss +77 -0
- package/packages/gantt/src/gantt.component.ts +134 -0
- package/packages/gantt/src/gantt.module.ts +47 -0
- package/packages/gantt/src/gantt.pipe.ts +31 -0
- package/packages/gantt/src/gantt.styles.ts +28 -0
- package/{public-api.d.ts → packages/gantt/src/public-api.ts} +6 -0
- package/packages/gantt/src/root.component.html +12 -0
- package/packages/gantt/src/root.component.ts +121 -0
- package/packages/gantt/src/styles/index.scss +9 -0
- package/packages/gantt/src/styles/variables.scss +46 -0
- package/packages/gantt/src/table/gantt-column.component.ts +25 -0
- package/packages/gantt/src/table/gantt-table.component.ts +14 -0
- package/packages/gantt/src/table/test/table.spec.ts +56 -0
- package/packages/gantt/src/test/gantt.component.spec.ts +404 -0
- package/packages/gantt/src/test/mocks/data.ts +303 -0
- package/packages/gantt/src/test.ts +21 -0
- package/packages/gantt/src/utils/date.ts +276 -0
- package/packages/gantt/src/utils/helpers.ts +66 -0
- package/packages/gantt/src/utils/test/date.spec.ts +105 -0
- package/packages/gantt/src/utils/test/helpers.spec.ts +73 -0
- package/packages/gantt/src/utils/testing.ts +64 -0
- package/packages/gantt/src/views/day.ts +74 -0
- package/packages/gantt/src/views/factory.ts +25 -0
- package/packages/gantt/src/views/month.ts +66 -0
- package/packages/gantt/src/views/quarter.ts +68 -0
- package/packages/gantt/src/views/test/day.spec.ts +45 -0
- package/packages/gantt/src/views/test/factory.spec.ts +41 -0
- package/packages/gantt/src/views/test/mock.ts +14 -0
- package/packages/gantt/src/views/test/month.spec.ts +45 -0
- package/packages/gantt/src/views/test/quarter.spec.ts +45 -0
- package/packages/gantt/src/views/test/view.spec.ts +144 -0
- package/packages/gantt/src/views/test/week.spec.ts +45 -0
- package/packages/gantt/src/views/test/year.spec.ts +45 -0
- package/packages/gantt/src/views/view.ts +186 -0
- package/packages/gantt/src/views/week.ts +66 -0
- package/packages/gantt/src/views/year.ts +62 -0
- package/packages/gantt/tsconfig.lib.json +20 -0
- package/packages/gantt/tsconfig.lib.prod.json +9 -0
- package/packages/gantt/tsconfig.schematics.json +25 -0
- package/packages/gantt/tsconfig.spec.json +17 -0
- package/packages/gantt/tslint.json +18 -0
- package/scss-bundle.config.json +7 -0
- package/tsconfig.json +26 -0
- package/tslint.json +51 -0
- package/bundles/worktile-gantt.umd.js +0 -3129
- package/bundles/worktile-gantt.umd.js.map +0 -1
- package/bundles/worktile-gantt.umd.min.js +0 -16
- package/bundles/worktile-gantt.umd.min.js.map +0 -1
- package/class/date-point.d.ts +0 -15
- package/class/group.d.ts +0 -22
- package/class/item.d.ts +0 -70
- package/class/view-type.d.ts +0 -7
- package/components/bar/bar-drag.d.ts +0 -34
- package/components/bar/bar.component.d.ts +0 -23
- package/components/calendar/calendar.component.d.ts +0 -25
- package/components/drag-backdrop/drag-backdrop.component.d.ts +0 -6
- package/components/icon/icon.component.d.ts +0 -10
- package/components/icon/icons.d.ts +0 -8
- package/components/links/links.component.d.ts +0 -44
- package/components/main/gantt-main.component.d.ts +0 -18
- package/components/range/range.component.d.ts +0 -10
- package/components/table/gantt-table.component.d.ts +0 -31
- package/esm2015/class/date-point.js +0 -10
- package/esm2015/class/event.js +0 -13
- package/esm2015/class/group.js +0 -17
- package/esm2015/class/index.js +0 -6
- package/esm2015/class/item.js +0 -78
- package/esm2015/class/view-type.js +0 -9
- package/esm2015/components/bar/bar-drag.js +0 -266
- package/esm2015/components/bar/bar.component.js +0 -91
- package/esm2015/components/calendar/calendar.component.js +0 -82
- package/esm2015/components/drag-backdrop/drag-backdrop.component.js +0 -18
- package/esm2015/components/icon/icon.component.js +0 -36
- package/esm2015/components/icon/icons.js +0 -87
- package/esm2015/components/links/links.component.js +0 -207
- package/esm2015/components/main/gantt-main.component.js +0 -35
- package/esm2015/components/range/range.component.js +0 -32
- package/esm2015/components/table/gantt-table.component.js +0 -128
- package/esm2015/gantt-dom.service.js +0 -101
- package/esm2015/gantt-drag-container.js +0 -57
- package/esm2015/gantt-item-upper.js +0 -55
- package/esm2015/gantt-print.service.js +0 -92
- package/esm2015/gantt-upper.js +0 -231
- package/esm2015/gantt.component.js +0 -105
- package/esm2015/gantt.module.js +0 -43
- package/esm2015/gantt.pipe.js +0 -33
- package/esm2015/gantt.styles.js +0 -15
- package/esm2015/public-api.js +0 -16
- package/esm2015/root.component.js +0 -111
- package/esm2015/table/gantt-column.component.js +0 -28
- package/esm2015/table/gantt-table.component.js +0 -18
- package/esm2015/utils/date.js +0 -160
- package/esm2015/utils/helpers.js +0 -45
- package/esm2015/views/day.js +0 -54
- package/esm2015/views/factory.js +0 -23
- package/esm2015/views/month.js +0 -48
- package/esm2015/views/quarter.js +0 -51
- package/esm2015/views/view.js +0 -121
- package/esm2015/views/week.js +0 -49
- package/esm2015/views/year.js +0 -50
- package/esm2015/worktile-gantt.js +0 -16
- package/fesm2015/worktile-gantt.js +0 -2491
- package/fesm2015/worktile-gantt.js.map +0 -1
- package/gantt-dom.service.d.ts +0 -29
- package/gantt-drag-container.d.ts +0 -20
- package/gantt-item-upper.d.ts +0 -17
- package/gantt-print.service.d.ts +0 -10
- package/gantt-upper.d.ts +0 -62
- package/gantt.component.d.ts +0 -28
- package/gantt.module.d.ts +0 -2
- package/gantt.pipe.d.ts +0 -11
- package/gantt.styles.d.ts +0 -15
- package/root.component.d.ts +0 -25
- package/style.scss +0 -645
- package/table/gantt-column.component.d.ts +0 -12
- package/table/gantt-table.component.d.ts +0 -7
- package/utils/date.d.ts +0 -59
- package/utils/helpers.d.ts +0 -11
- package/views/day.d.ts +0 -14
- package/views/factory.d.ts +0 -8
- package/views/month.d.ts +0 -12
- package/views/quarter.d.ts +0 -12
- package/views/view.d.ts +0 -56
- package/views/week.d.ts +0 -12
- package/views/year.d.ts +0 -12
- package/worktile-gantt.d.ts +0 -15
- package/worktile-gantt.metadata.json +0 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Injectable, EventEmitter } from '@angular/core';
|
|
2
|
+
import { GanttDragEvent, GanttLinkDragEvent } from './class/event';
|
|
3
|
+
import { GanttItemInternal } from './class/item';
|
|
4
|
+
|
|
5
|
+
export type LinkDragFrom = 'source' | 'target';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class GanttDragContainer {
|
|
9
|
+
dragStarted = new EventEmitter<GanttDragEvent>();
|
|
10
|
+
|
|
11
|
+
dragEnded = new EventEmitter<GanttDragEvent>();
|
|
12
|
+
|
|
13
|
+
linkDragStarted = new EventEmitter<GanttLinkDragEvent>();
|
|
14
|
+
|
|
15
|
+
linkDragEntered = new EventEmitter<GanttLinkDragEvent>();
|
|
16
|
+
|
|
17
|
+
linkDragEnded = new EventEmitter<GanttLinkDragEvent>();
|
|
18
|
+
|
|
19
|
+
linkDraggingId: string;
|
|
20
|
+
|
|
21
|
+
private linkDragSource: GanttItemInternal;
|
|
22
|
+
|
|
23
|
+
private linkDragTarget: GanttItemInternal;
|
|
24
|
+
|
|
25
|
+
private linkDragFrom: LinkDragFrom;
|
|
26
|
+
|
|
27
|
+
constructor() {}
|
|
28
|
+
|
|
29
|
+
emitLinkDragStarted(from: LinkDragFrom, item: GanttItemInternal) {
|
|
30
|
+
this.linkDraggingId = item.id;
|
|
31
|
+
this.linkDragFrom = from;
|
|
32
|
+
this.linkDragSource = this.linkDragFrom === 'source' ? item : null;
|
|
33
|
+
this.linkDragTarget = this.linkDragFrom === 'target' ? item : null;
|
|
34
|
+
this.linkDragStarted.emit({
|
|
35
|
+
source: this.linkDragSource && this.linkDragSource.origin,
|
|
36
|
+
target: this.linkDragTarget && this.linkDragTarget.origin
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
emitLinkDragEntered(item: GanttItemInternal) {
|
|
41
|
+
if (this.linkDragFrom === 'source') {
|
|
42
|
+
this.linkDragTarget = item;
|
|
43
|
+
} else {
|
|
44
|
+
this.linkDragSource = item;
|
|
45
|
+
}
|
|
46
|
+
this.linkDragEntered.emit({
|
|
47
|
+
source: this.linkDragSource.origin,
|
|
48
|
+
target: this.linkDragTarget.origin
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
emitLinkDragLeaved() {
|
|
53
|
+
if (this.linkDragFrom === 'source') {
|
|
54
|
+
this.linkDragTarget = null;
|
|
55
|
+
} else {
|
|
56
|
+
this.linkDragSource = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
emitLinkDragEnded() {
|
|
61
|
+
this.linkDraggingId = null;
|
|
62
|
+
if (this.linkDragSource && this.linkDragTarget) {
|
|
63
|
+
this.linkDragSource.addLink(this.linkDragTarget.id);
|
|
64
|
+
|
|
65
|
+
this.linkDragEnded.emit({
|
|
66
|
+
source: this.linkDragSource.origin,
|
|
67
|
+
target: this.linkDragTarget.origin
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
this.linkDragSource = null;
|
|
71
|
+
this.linkDragTarget = null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Input, ElementRef, Inject, TemplateRef, Directive } from '@angular/core';
|
|
2
|
+
import { GanttItemInternal, GanttItemType } from './class';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
import { takeUntil } from 'rxjs/operators';
|
|
5
|
+
import { rangeHeight } from './gantt.styles';
|
|
6
|
+
import { GANTT_UPPER_TOKEN, GanttUpper } from './gantt-upper';
|
|
7
|
+
|
|
8
|
+
@Directive()
|
|
9
|
+
export abstract class GanttItemUpper {
|
|
10
|
+
@Input() template: TemplateRef<any>;
|
|
11
|
+
|
|
12
|
+
@Input() item: GanttItemInternal;
|
|
13
|
+
|
|
14
|
+
public firstChange = true;
|
|
15
|
+
|
|
16
|
+
public unsubscribe$ = new Subject();
|
|
17
|
+
|
|
18
|
+
constructor(protected elementRef: ElementRef<HTMLElement>, @Inject(GANTT_UPPER_TOKEN) protected ganttUpper: GanttUpper) {}
|
|
19
|
+
|
|
20
|
+
onInit() {
|
|
21
|
+
this.firstChange = false;
|
|
22
|
+
this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
23
|
+
this.setPositions();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
onChanges(): void {
|
|
28
|
+
if (!this.firstChange) {
|
|
29
|
+
this.setPositions();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private setPositions() {
|
|
34
|
+
const itemElement = this.elementRef.nativeElement;
|
|
35
|
+
itemElement.style.left = this.item.refs.x + 'px';
|
|
36
|
+
itemElement.style.top = this.item.refs.y + 'px';
|
|
37
|
+
itemElement.style.width = this.item.refs.width + 'px';
|
|
38
|
+
if (this.item.type === GanttItemType.bar) {
|
|
39
|
+
itemElement.style.height = this.ganttUpper.styles.barHeight + 'px';
|
|
40
|
+
} else if (this.item.type === GanttItemType.range) {
|
|
41
|
+
itemElement.style.height = rangeHeight + 'px';
|
|
42
|
+
} else {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
onDestroy() {
|
|
47
|
+
this.unsubscribe$.next();
|
|
48
|
+
this.unsubscribe$.complete();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Injectable, ElementRef } from '@angular/core';
|
|
2
|
+
import html2canvas from 'html2canvas';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class GanttPrintService {
|
|
6
|
+
private root: HTMLElement;
|
|
7
|
+
|
|
8
|
+
private mainContainer: HTMLElement;
|
|
9
|
+
|
|
10
|
+
constructor() {}
|
|
11
|
+
|
|
12
|
+
private setInlineStyles(targetElem: Element) {
|
|
13
|
+
const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
|
|
14
|
+
for (const svgElement of svgElements) {
|
|
15
|
+
this.recursElementChildren(svgElement);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private recursElementChildren(node: SVGSVGElement | HTMLElement) {
|
|
20
|
+
const transformProperties = [
|
|
21
|
+
'fill',
|
|
22
|
+
'color',
|
|
23
|
+
'font-size',
|
|
24
|
+
'stroke',
|
|
25
|
+
'font',
|
|
26
|
+
'text-anchor',
|
|
27
|
+
'stroke-dasharray',
|
|
28
|
+
'shape-rendering',
|
|
29
|
+
'stroke-width'
|
|
30
|
+
];
|
|
31
|
+
if (!node.style) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const styles = getComputedStyle(node);
|
|
35
|
+
for (const transformProperty of transformProperties) {
|
|
36
|
+
node.style[transformProperty] = styles[transformProperty];
|
|
37
|
+
}
|
|
38
|
+
for (const child of Array.from(node.childNodes)) {
|
|
39
|
+
this.recursElementChildren(child as SVGSVGElement);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
register(root: ElementRef<HTMLElement>) {
|
|
44
|
+
this.root = root.nativeElement;
|
|
45
|
+
this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0] as HTMLElement;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
print(name: string = 'download', ignoreElementClass?: string) {
|
|
49
|
+
const root = this.root as HTMLElement;
|
|
50
|
+
|
|
51
|
+
const mainContainer = this.mainContainer as HTMLElement;
|
|
52
|
+
// set print width
|
|
53
|
+
const printWidth = root.offsetWidth;
|
|
54
|
+
|
|
55
|
+
// set print height
|
|
56
|
+
const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
|
|
57
|
+
|
|
58
|
+
html2canvas(root, {
|
|
59
|
+
logging: false,
|
|
60
|
+
allowTaint: true,
|
|
61
|
+
useCORS: true,
|
|
62
|
+
width: printWidth,
|
|
63
|
+
height: printHeight,
|
|
64
|
+
ignoreElements: (element) => {
|
|
65
|
+
if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (element.classList.contains('gantt-calendar-today-overlay')) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
onclone: (cloneDocument: Document) => {
|
|
74
|
+
const ganttClass = root.className;
|
|
75
|
+
const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`) as HTMLElement;
|
|
76
|
+
const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container') as HTMLElement;
|
|
77
|
+
const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main') as HTMLElement;
|
|
78
|
+
const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main') as HTMLElement;
|
|
79
|
+
|
|
80
|
+
// change targetDom width
|
|
81
|
+
cloneGanttDom.style.width = `${printWidth}px`;
|
|
82
|
+
cloneGanttDom.style.height = `${printHeight}px`;
|
|
83
|
+
cloneGanttDom.style.overflow = `unset`;
|
|
84
|
+
cloneGanttContainerDom.style.backgroundColor = '#fff';
|
|
85
|
+
cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
|
|
86
|
+
cloneCalendarOverlay.setAttribute('style', `background: transparent`);
|
|
87
|
+
|
|
88
|
+
if (cloneLinksOverlay) {
|
|
89
|
+
cloneLinksOverlay.setAttribute('height', `${printHeight}`);
|
|
90
|
+
cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// setInlineStyles for svg
|
|
94
|
+
this.setInlineStyles(cloneGanttDom);
|
|
95
|
+
}
|
|
96
|
+
}).then((canvas: HTMLCanvasElement) => {
|
|
97
|
+
const link = document.createElement('a');
|
|
98
|
+
const dataUrl = canvas.toDataURL('image/png');
|
|
99
|
+
link.download = `${name}.png`;
|
|
100
|
+
link.href = dataUrl;
|
|
101
|
+
link.click();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Input,
|
|
3
|
+
TemplateRef,
|
|
4
|
+
Output,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
ContentChild,
|
|
7
|
+
ElementRef,
|
|
8
|
+
HostBinding,
|
|
9
|
+
ChangeDetectorRef,
|
|
10
|
+
NgZone,
|
|
11
|
+
SimpleChanges,
|
|
12
|
+
InjectionToken,
|
|
13
|
+
Directive
|
|
14
|
+
} from '@angular/core';
|
|
15
|
+
import { Subject } from 'rxjs';
|
|
16
|
+
import { takeUntil, take, skip } from 'rxjs/operators';
|
|
17
|
+
import {
|
|
18
|
+
GanttItem,
|
|
19
|
+
GanttGroup,
|
|
20
|
+
GanttViewType,
|
|
21
|
+
GanttLoadOnScrollEvent,
|
|
22
|
+
GanttDragEvent,
|
|
23
|
+
GanttGroupInternal,
|
|
24
|
+
GanttItemInternal,
|
|
25
|
+
GanttBarClickEvent,
|
|
26
|
+
GanttLinkDragEvent
|
|
27
|
+
} from './class';
|
|
28
|
+
import { GanttView, GanttViewOptions } from './views/view';
|
|
29
|
+
import { createViewFactory } from './views/factory';
|
|
30
|
+
import { GanttDate } from './utils/date';
|
|
31
|
+
import { GanttStyles, defaultStyles } from './gantt.styles';
|
|
32
|
+
import { uniqBy, flatten, recursiveItems, getFlatItems } from './utils/helpers';
|
|
33
|
+
import { GanttDragContainer } from './gantt-drag-container';
|
|
34
|
+
|
|
35
|
+
@Directive()
|
|
36
|
+
export abstract class GanttUpper {
|
|
37
|
+
@Input('items') originItems: GanttItem[] = [];
|
|
38
|
+
|
|
39
|
+
@Input('groups') originGroups: GanttGroup[] = [];
|
|
40
|
+
|
|
41
|
+
@Input() viewType: GanttViewType = GanttViewType.month;
|
|
42
|
+
|
|
43
|
+
@Input() start: number;
|
|
44
|
+
|
|
45
|
+
@Input() end: number;
|
|
46
|
+
|
|
47
|
+
@Input() showTodayLine = true;
|
|
48
|
+
|
|
49
|
+
@Input() draggable: boolean;
|
|
50
|
+
|
|
51
|
+
@Input() styles: GanttStyles;
|
|
52
|
+
|
|
53
|
+
@Input() viewOptions: GanttViewOptions;
|
|
54
|
+
|
|
55
|
+
@Input() disabledLoadOnScroll: boolean;
|
|
56
|
+
|
|
57
|
+
@Output() loadOnScroll = new EventEmitter<GanttLoadOnScrollEvent>();
|
|
58
|
+
|
|
59
|
+
@Output() dragStarted = new EventEmitter<GanttDragEvent>();
|
|
60
|
+
|
|
61
|
+
@Output() dragEnded = new EventEmitter<GanttDragEvent>();
|
|
62
|
+
|
|
63
|
+
@Output() barClick = new EventEmitter<GanttBarClickEvent>();
|
|
64
|
+
|
|
65
|
+
@ContentChild('bar', { static: true }) barTemplate: TemplateRef<any>;
|
|
66
|
+
|
|
67
|
+
@ContentChild('range', { static: true }) rangeTemplate: TemplateRef<any>;
|
|
68
|
+
|
|
69
|
+
@ContentChild('item', { static: true }) itemTemplate: TemplateRef<any>;
|
|
70
|
+
|
|
71
|
+
@ContentChild('group', { static: true }) groupTemplate: TemplateRef<any>;
|
|
72
|
+
|
|
73
|
+
@ContentChild('groupHeader', { static: true }) groupHeaderTemplate: TemplateRef<any>;
|
|
74
|
+
|
|
75
|
+
public linkable: boolean;
|
|
76
|
+
|
|
77
|
+
public linkDragEnded = new EventEmitter<GanttLinkDragEvent>();
|
|
78
|
+
|
|
79
|
+
public view: GanttView;
|
|
80
|
+
|
|
81
|
+
public items: GanttItemInternal[] = [];
|
|
82
|
+
|
|
83
|
+
public groups: GanttGroupInternal[] = [];
|
|
84
|
+
|
|
85
|
+
public viewChange = new EventEmitter<GanttView>();
|
|
86
|
+
|
|
87
|
+
public expandChange = new EventEmitter<void>();
|
|
88
|
+
|
|
89
|
+
public get element() {
|
|
90
|
+
return this.elementRef.nativeElement;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public firstChange = true;
|
|
94
|
+
|
|
95
|
+
public dragContainer: GanttDragContainer;
|
|
96
|
+
|
|
97
|
+
public unsubscribe$ = new Subject();
|
|
98
|
+
|
|
99
|
+
private groupsMap: { [key: string]: GanttGroupInternal };
|
|
100
|
+
|
|
101
|
+
@HostBinding('class.gantt') ganttClass = true;
|
|
102
|
+
|
|
103
|
+
constructor(protected elementRef: ElementRef<HTMLElement>, protected cdr: ChangeDetectorRef, protected ngZone: NgZone) {}
|
|
104
|
+
|
|
105
|
+
private createView() {
|
|
106
|
+
const viewDate = this.getViewDate();
|
|
107
|
+
this.view = createViewFactory(this.viewType, viewDate.start, viewDate.end, this.viewOptions);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private setupGroups() {
|
|
111
|
+
const collapsedIds = this.groups.filter((group) => group.expanded === false).map((group) => group.id);
|
|
112
|
+
this.groupsMap = {};
|
|
113
|
+
this.groups = [];
|
|
114
|
+
this.originGroups.forEach((origin) => {
|
|
115
|
+
const group = new GanttGroupInternal(origin);
|
|
116
|
+
group.expanded = !collapsedIds.includes(group.id);
|
|
117
|
+
this.groupsMap[group.id] = group;
|
|
118
|
+
this.groups.push(group);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private setupItems() {
|
|
123
|
+
this.originItems = uniqBy(this.originItems, 'id');
|
|
124
|
+
this.items = [];
|
|
125
|
+
if (this.groups.length > 0) {
|
|
126
|
+
this.originItems.forEach((origin) => {
|
|
127
|
+
const group = this.groupsMap[origin.group_id];
|
|
128
|
+
if (group) {
|
|
129
|
+
const item = new GanttItemInternal(origin, { viewType: this.viewType });
|
|
130
|
+
group.items.push(item);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
} else {
|
|
134
|
+
this.originItems.forEach((origin) => {
|
|
135
|
+
const item = new GanttItemInternal(origin, { viewType: this.viewType });
|
|
136
|
+
this.items.push(item);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private setupExpandedState() {
|
|
142
|
+
this.originItems = uniqBy(this.originItems, 'id');
|
|
143
|
+
let items: GanttItemInternal[] = [];
|
|
144
|
+
const flatOriginItems = getFlatItems(this.originItems);
|
|
145
|
+
|
|
146
|
+
if (this.items.length > 0) {
|
|
147
|
+
items = recursiveItems(this.items);
|
|
148
|
+
} else {
|
|
149
|
+
items = flatten(this.groups.map((group) => recursiveItems(group.items)));
|
|
150
|
+
}
|
|
151
|
+
items.forEach((item) => {
|
|
152
|
+
if (item.origin.expanded) {
|
|
153
|
+
const newItem = flatOriginItems.find((originItem) => originItem.id === item.id);
|
|
154
|
+
if (newItem) {
|
|
155
|
+
if (newItem.expanded === undefined) {
|
|
156
|
+
newItem.expanded = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private getViewDate() {
|
|
164
|
+
let start = this.start;
|
|
165
|
+
let end = this.end;
|
|
166
|
+
if (!this.start || !this.end) {
|
|
167
|
+
this.originItems.forEach((item) => {
|
|
168
|
+
if (item.start && !this.start) {
|
|
169
|
+
start = start ? Math.min(start, item.start) : item.start;
|
|
170
|
+
}
|
|
171
|
+
if (item.end && !this.end) {
|
|
172
|
+
end = end ? Math.max(end, item.end) : item.end;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
start: {
|
|
178
|
+
date: new GanttDate(start),
|
|
179
|
+
isCustom: this.start ? true : false
|
|
180
|
+
},
|
|
181
|
+
end: {
|
|
182
|
+
date: new GanttDate(end),
|
|
183
|
+
isCustom: this.end ? true : false
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
computeRefs() {
|
|
189
|
+
this.groups.forEach((group) => {
|
|
190
|
+
const groupItems = recursiveItems(group.items);
|
|
191
|
+
this.computeItemsRefs(...groupItems);
|
|
192
|
+
});
|
|
193
|
+
const items = recursiveItems(this.items);
|
|
194
|
+
this.computeItemsRefs(...items);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private expandGroups(expanded: boolean) {
|
|
198
|
+
this.groups.forEach((group) => {
|
|
199
|
+
group.setExpand(expanded);
|
|
200
|
+
});
|
|
201
|
+
this.expandChange.next();
|
|
202
|
+
this.cdr.detectChanges();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
onInit() {
|
|
206
|
+
this.styles = Object.assign({}, defaultStyles, this.styles);
|
|
207
|
+
this.createView();
|
|
208
|
+
this.setupGroups();
|
|
209
|
+
this.setupItems();
|
|
210
|
+
this.computeRefs();
|
|
211
|
+
this.firstChange = false;
|
|
212
|
+
|
|
213
|
+
this.ngZone.onStable.pipe(take(1)).subscribe(() => {
|
|
214
|
+
this.element.style.opacity = '1';
|
|
215
|
+
|
|
216
|
+
this.dragContainer.dragStarted.subscribe((event) => {
|
|
217
|
+
this.dragStarted.emit(event);
|
|
218
|
+
});
|
|
219
|
+
this.dragContainer.dragEnded.subscribe((event) => {
|
|
220
|
+
this.dragEnded.emit(event);
|
|
221
|
+
this.computeRefs();
|
|
222
|
+
this.detectChanges();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
this.view.start$.pipe(skip(1), takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
227
|
+
this.computeRefs();
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
onChanges(changes: SimpleChanges) {
|
|
232
|
+
if (!this.firstChange) {
|
|
233
|
+
if (changes.viewType && changes.viewType.currentValue) {
|
|
234
|
+
this.createView();
|
|
235
|
+
this.setupGroups();
|
|
236
|
+
this.setupItems();
|
|
237
|
+
this.computeRefs();
|
|
238
|
+
this.viewChange.emit(this.view);
|
|
239
|
+
}
|
|
240
|
+
if (changes.originItems || changes.originGroups) {
|
|
241
|
+
this.setupExpandedState();
|
|
242
|
+
this.setupGroups();
|
|
243
|
+
this.setupItems();
|
|
244
|
+
this.computeRefs();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
onDestroy() {
|
|
250
|
+
this.unsubscribe$.next();
|
|
251
|
+
this.unsubscribe$.complete();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
computeItemsRefs(...items: GanttItemInternal[]) {
|
|
255
|
+
items.forEach((item) => {
|
|
256
|
+
item.updateRefs({
|
|
257
|
+
width: item.start && item.end ? this.view.getDateRangeWidth(item.start.startOfDay(), item.end.endOfDay()) : 0,
|
|
258
|
+
x: item.start ? this.view.getXPointByDate(item.start) : 0,
|
|
259
|
+
y: (this.styles.lineHeight - this.styles.barHeight) / 2 - 1
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
trackBy(item: GanttGroupInternal | GanttItemInternal, index: number) {
|
|
265
|
+
return item.id || index;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
detectChanges() {
|
|
269
|
+
this.cdr.detectChanges();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
expandGroup(group: GanttGroupInternal) {
|
|
273
|
+
group.setExpand(!group.expanded);
|
|
274
|
+
this.expandChange.emit();
|
|
275
|
+
this.cdr.detectChanges();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// public functions
|
|
279
|
+
|
|
280
|
+
expandAll() {
|
|
281
|
+
this.expandGroups(true);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
collapseAll() {
|
|
285
|
+
this.expandGroups(false);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export const GANTT_UPPER_TOKEN = new InjectionToken<GanttUpper>('GANTT_UPPER_TOKEN');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<ngx-gantt-root>
|
|
2
|
+
<ng-template #sideTemplate>
|
|
3
|
+
<gantt-table [groups]="groups" [items]="items" [columns]="columns" [groupTemplate]="groupTemplate" [emptyTemplate]="tableEmptyTemplate"></gantt-table>
|
|
4
|
+
</ng-template>
|
|
5
|
+
<ng-template #mainTemplate>
|
|
6
|
+
<gantt-main
|
|
7
|
+
[groups]="groups"
|
|
8
|
+
[items]="items"
|
|
9
|
+
[groupHeaderTemplate]="groupHeaderTemplate"
|
|
10
|
+
[itemTemplate]="itemTemplate"
|
|
11
|
+
[barTemplate]="barTemplate"
|
|
12
|
+
[rangeTemplate]="rangeTemplate"
|
|
13
|
+
(barClick)="barClick.emit($event)"
|
|
14
|
+
(lineClick)="lineClick.emit($event)"
|
|
15
|
+
>
|
|
16
|
+
</gantt-main>
|
|
17
|
+
</ng-template>
|
|
18
|
+
</ngx-gantt-root>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
.gantt {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
background-color: $gantt-bg-color;
|
|
5
|
+
position: relative;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
display: flex;
|
|
8
|
+
color: $gantt-color;
|
|
9
|
+
opacity: 0;
|
|
10
|
+
|
|
11
|
+
svg {
|
|
12
|
+
overflow: visible !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.gantt-side {
|
|
16
|
+
border-right: 1px solid $gantt-border-color;
|
|
17
|
+
position: relative;
|
|
18
|
+
z-index: 3;
|
|
19
|
+
// overflow-x: scroll;
|
|
20
|
+
box-shadow: $gantt-side-shadow;
|
|
21
|
+
|
|
22
|
+
.gantt-side-header {
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
height: $gantt-header-height;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.gantt-side-container {
|
|
28
|
+
height: 100%;
|
|
29
|
+
background-color: $gantt-bg-color;
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
|
|
32
|
+
&::-webkit-scrollbar {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.gantt-container {
|
|
39
|
+
flex: 1;
|
|
40
|
+
position: relative;
|
|
41
|
+
display: flex;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
background-color: $gantt-container-background-color;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.gantt-main-container {
|
|
47
|
+
width: 100%;
|
|
48
|
+
height: calc(100% - #{$gantt-header-height});
|
|
49
|
+
flex: 1;
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: $gantt-header-height;
|
|
52
|
+
bottom: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
right: 0;
|
|
55
|
+
overflow: auto;
|
|
56
|
+
background-color: $gantt-container-background-color;
|
|
57
|
+
|
|
58
|
+
.gantt-main-groups,
|
|
59
|
+
.gantt-main-items {
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
min-height: 100%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.gantt-group {
|
|
65
|
+
height: $gantt-group-height;
|
|
66
|
+
background: $gantt-group-background-color;
|
|
67
|
+
border-bottom: 1px solid $gantt-border-color;
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.gantt-item {
|
|
72
|
+
border-bottom: 1px solid $gantt-border-color;
|
|
73
|
+
box-sizing: border-box;
|
|
74
|
+
position: relative;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|